Documentation ¶
Index ¶
- Constants
- Variables
- func NewClient() *resty.Client
- func NewClientWithRetry(retries int, retryWait, timeout time.Duration) *resty.Client
- func NewDefaultClient() *resty.Client
- func WrapError(r *resty.Response, err *Error) error
- type APIConnectionError
- type APIError
- type AuthenticationError
- type BadRequestError
- type Error
- type ErrorCode
- type ForbiddenError
- type RateLimitingError
- type Response
- type User
- type UserInfo
Constants ¶
const ( // APIVersion is the version of the library. APIVersion = "v0.1.0" // APIURL is the URL of the API service backend. APIURL = "https://api.magic.link" // APISecretHeader holds the header name for api authorization. APISecretHeader = "X-Magic-Secret-Key" )
Variables ¶
var (
ErrRespQuotaExceeded = errors.New("quota exceeded")
)
Functions ¶
func NewClient ¶
func NewClient() *resty.Client
NewClient creates new backend client with default api url.
func NewClientWithRetry ¶
NewClientWithRetry creates backend client with backoff retry configuration.
func NewDefaultClient ¶
func NewDefaultClient() *resty.Client
NewDefaultClient creates backend client with default configuration of retries.
Types ¶
type APIConnectionError ¶
type APIConnectionError struct {
Err error
}
APIConnectionError occurs if request is not permitted to be executed.
func (*APIConnectionError) Error ¶
func (e *APIConnectionError) Error() string
Error serializes the error object to JSON and returns it as a string.
type APIError ¶
type APIError struct {
Err *Error
}
APIError default unrecognized by any other errors.
type AuthenticationError ¶
type AuthenticationError struct {
Err *Error
}
AuthenticationError occurs if request is not authorized to proceed.
func (*AuthenticationError) Error ¶
func (e *AuthenticationError) Error() string
Error serializes the error object to JSON and returns it as a string.
type BadRequestError ¶
type BadRequestError struct {
Err *Error
}
BadRequestError occurs with not well formed request.
func (*BadRequestError) Error ¶
func (e *BadRequestError) Error() string
Error serializes the error object to JSON and returns it as a string.
type ForbiddenError ¶
type ForbiddenError struct {
Err *Error
}
ForbiddenError occurs if request is not permitted to be executed.
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
Error serializes the error object to JSON and returns it as a string.
type RateLimitingError ¶
type RateLimitingError struct {
Err *Error
}
RateLimitError occurs when in case if API is hit with too many requests.
func (*RateLimitingError) Error ¶
func (e *RateLimitingError) Error() string
Error serializes the error object to JSON and returns it as a string.
type Response ¶
type Response struct { Data interface{} `json:"data"` ErrorCode ErrorCode `json:"error_code"` Message string `json:"message"` Status string `json:"status"` }
Default response data structure of magic backend server.
type User ¶
type User interface { GetMetadataByIssuer(issuer string) (*UserInfo, error) GetMetadataByPublicAddress(pubAddr string) (*UserInfo, error) GetMetadataByToken(didToken string) (*UserInfo, error) LogoutByIssuer(issuer string) error LogoutByPublicAddress(pubAddr string) error LogoutByToken(didToken string) error }