Documentation
¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) NewRequestForm(urlStr string, data url.Values) (*http.Request, error)
- func (c *Client) YoAll(apiToken string) (*http.Response, error)
- type ErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the response for errors. A response is considered an error if it is outside the 200 range.
Types ¶
type Client ¶
func NewClient ¶
NewClient returns a new Yo API client. If client is nil, then http.DefaultClient is used.
func (*Client) NewRequest ¶
NewRequest creates a new API request. urlStr can either be an relative or absolute url. If it's relative, the it's resolved to the BaseURL of the Client. If body is provided, then it is encoded as JSON and included in the request body.
func (*Client) NewRequestForm ¶
NewRequestForm creates a new API request that POSTs a form. urlStr can either be a relative or absolute url. If it's relative, then it's resolved to the BaseURL of the Client. data's keys and values are encoded to the request body.
type ErrorResponse ¶
ErrorResponse reports one or more errors returned from an API request.
TODO: Acutally report one or more errors instead of just have the response. Can't currently do this because I don't have an API token.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
