Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted. API error responses are expected to have response body, and a JSON response body that maps to ErrorResponse.
Types ¶
type AuthError ¶
type AuthError ErrorResponse
type Client ¶
type Client struct { // Base URL for API requests. Defaults to the public API. // BaseURL should always be specified with a trailing slash. BaseURL *url.URL AccessToken string // https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/ AccountId string // https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/ // User agent used when communicating with the Harvest API. UserAgent string // https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/ // Services used for talking to different parts of the Harvest API. TimeEntries *TimeEntriesService // contains filtered or unexported fields }
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error ErrorCode string `json:"error"` // error code ErrorDescription string `json:"error_description"` // error message }
An ErrorResponse reports one or more errors caused by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ListOptions ¶
type ListOptions struct { // For paginated result sets, page of results to retrieve. Page int `url:"page,omitempty"` // For paginated result sets, the number of results to include per page. PerPage int `url:"per_page,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support offset pagination.
type Pagination ¶
type Response ¶
Response is a API response. This wraps the standard http.Response returned from API and provides convenient access to things like pagination links.
type TimeEntriesListOptions ¶
type TimeEntriesListOptions struct { From string `url:"from,omitempty"` To string `url:"to,omitempty"` ListOptions }
TimeEntriesListOptions specifies the optional parameters to the TimeEntriesService.List method.
type TimeEntriesService ¶
type TimeEntriesService service
func (*TimeEntriesService) List ¶
func (t *TimeEntriesService) List(ctx context.Context, opts *TimeEntriesListOptions) ([]*TimeEntry, *Response, error)
List lists time entries. https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/#list-all-time-entries