Initial Marktplaats SDK scaffold
Clone the twdehands SDK into mrktplaats and retarget naming and defaults for app.marktplaats.nl while keeping the same request/response bodies and endpoint behavior.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package mrktplaats
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// APIError is returned when the API responds with a non-2xx status code.
|
||||
type APIError struct {
|
||||
StatusCode int
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func (e *APIError) Error() string {
|
||||
return fmt.Sprintf("mrktplaats: API error %d: %s", e.StatusCode, string(e.Body))
|
||||
}
|
||||
|
||||
// IsNotFound reports whether err is an API 404 response.
|
||||
func IsNotFound(err error) bool {
|
||||
var apiErr *APIError
|
||||
return errors.As(err, &apiErr) && apiErr.StatusCode == 404
|
||||
}
|
||||
|
||||
// IsUnauthorized reports whether err is an API 401 response.
|
||||
func IsUnauthorized(err error) bool {
|
||||
var apiErr *APIError
|
||||
return errors.As(err, &apiErr) && apiErr.StatusCode == 401
|
||||
}
|
||||
Reference in New Issue
Block a user