Documentation ¶
Index ¶
- Variables
- func SetLogger(logger *zap.Logger)
- func WrapQuote(s string) string
- type Authorizer
- type Client
- type Error
- type ListResponse
- type NoopAuthorizer
- type ResponseWrapper
- func GET[T any](client Client, queryTransformer func(query url.Values)) (*ResponseWrapper[T], error)
- func POST[T any](client Client, queryTransformer func(query url.Values)) (*ResponseWrapper[T], error)
- func ParseResponse[T any](responseBody io.Reader) (*ResponseWrapper[T], error)
- func PerformRequest[T any](req *http.Request) (*ResponseWrapper[T], error)
- type TestServer
- type ValueTransformer
Constants ¶
This section is empty.
Variables ¶
View Source
var ERRORS = map[int]string{
100: "unknown error.",
101: "missing api, version, or method parameter",
102: "the requested API does not exist",
103: "the requested method does not exist",
104: "the requested version does not support the functionality",
105: "the logged in session does not have permission",
106: "session timeout",
107: "session interrupted by duplicated login",
108: "failed to upload file",
109: "the network connection is unstable or the system is busy",
110: "the network connection is unstable or the system is busy",
111: "the network connection is unstable or the system is busy",
114: "lost parameters for this API",
115: "not allowed to upload a file",
116: "not allowed to perform for a demo site.",
117: "the network connection is unstable or the system is busy",
118: "the network connection is unstable or the system is busy",
119: "invalid session",
150: "request source IP does not match the login IP",
400: "No such account or incorrect password",
401: "Disabled account",
402: "Denied permission",
403: "2-factor authentication code required",
404: "Failed to authenticate 2-factor authentication code",
406: "Enforce to authenticate with 2-factor authentication code",
407: "Blocked IP source",
408: "Expired password cannot change",
409: "Expired password",
410: "Password must be changed",
}
Functions ¶
Types ¶
type Authorizer ¶
type Client ¶
type Client interface { NewGET(transformer ValueTransformer) (*http.Request, error) NewPOST(transformer ValueTransformer) (*http.Request, error) }
func NewClient ¶
func NewClient(baseURL string, authorizer Authorizer) Client
type ListResponse ¶
type NoopAuthorizer ¶
type NoopAuthorizer struct { }
func (NoopAuthorizer) Apply ¶
func (noop NoopAuthorizer) Apply(_ url.Values)
type ResponseWrapper ¶
type ResponseWrapper[T any] struct { Data T `json:"data"` Error Error `json:"error"` Success bool `json:"success"` }
func ParseResponse ¶
func ParseResponse[T any](responseBody io.Reader) (*ResponseWrapper[T], error)
func PerformRequest ¶
func PerformRequest[T any](req *http.Request) (*ResponseWrapper[T], error)
type TestServer ¶
type TestServer struct { Requests []*http.Request HTTPServer *httptest.Server // contains filtered or unexported fields }
func FakeServerHandler ¶
func FakeServerHandler() *TestServer
func (*TestServer) AddRoute ¶
func (t *TestServer) AddRoute(httpMethod, api, apiMethod string, handler http.HandlerFunc)
func (*TestServer) ServeHTTP ¶
func (t *TestServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)
func (*TestServer) Session ¶
func (t *TestServer) Session() string
type ValueTransformer ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.