Documentation ¶
Index ¶
- func Bool(v bool) *bool
- func CheckResponse(r *http.Response) error
- func Int(v int) *int
- func Int64(v int64) *int64
- func String(v string) *string
- func Stringify(message interface{}) string
- type AcceptedError
- type Client
- func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, error)
- func (c *Client) Client() *http.Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error)
- type Error
- type ErrorBlock
- type ErrorResponse
- type Member
- type PersonalTokenTransport
- type Rate
- type RateLimitError
- type RateLimits
- type RawOptions
- type RawType
- type Response
- type Timestamp
- type Workspace
- type WorkspacesService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
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.
The error type will be *RateLimitError for rate limit exceeded errors, *AcceptedError for 202 Accepted status codes, and *TwoFactorAuthError for two-factor authentication errors.
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func Int64 ¶
Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.
Types ¶
type AcceptedError ¶
type AcceptedError struct { // Raw contains the response body. Raw []byte }
func (*AcceptedError) Error ¶
func (*AcceptedError) Error() string
func (*AcceptedError) Is ¶
func (ae *AcceptedError) Is(target error) bool
Is returns whether the provided error equals this error.
type Client ¶
type Client struct { // Base URL for API requests. Defaults to the public ClickUp v2 API. BaseURL should // always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating with the ClickUp API. UserAgent string // Services used for talking to different parts of the ClickUp API. Workspaces *WorkspacesService // contains filtered or unexported fields }
A Client manages communication with the ClickUp API.
func NewClient ¶
NewClient returns a new ClickUp API client. If a nil httpClient is provided, a new http.Client will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*Client) BareDo ¶
BareDo sends an API request and lets you handle the api response. If an error or API Error occurs, the error will contain more information. Otherwise you are supposed to read and close the response's Body. If rate limit is exceeded and reset time is in the future, BareDo returns *RateLimitError immediately without making a network API call.
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.
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. If v is nil, and no error hapens, the response is returned as is. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.
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.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) RateLimits ¶
RateLimits returns the rate limits for the current client.
type Error ¶
type Error struct { Resource string `json:"resource"` // resource on which the error occurred Field string `json:"field"` // field on which the error occurred Code string `json:"code"` // validation error code Message string `json:"message"` // Message describing the error. Errors with Code == "custom" will always have this set. }
func (*Error) UnmarshalJSON ¶
type ErrorBlock ¶
type ErrorBlock struct { Reason string `json:"reason,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` }
ErrorBlock contains a further explanation for the reason of an error. for more information.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message Errors []Error `json:"errors"` // more detail on individual errors // Block is only populated on certain types of errors such as code 451. Block *ErrorBlock `json:"block,omitempty"` // Most errors will also include a documentation_url field pointing // to some content that might help you resolve the error, see // https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors DocumentationURL string `json:"documentation_url,omitempty"` }
An ErrorResponse reports one or more errors caused by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
func (*ErrorResponse) Is ¶
func (r *ErrorResponse) Is(target error) bool
Is returns whether the provided error equals this error.
type Member ¶
type Member struct { User struct { ID string `json:"id"` Username string `json:"username"` Email string `json:"email"` Color string `json:"color"` ProfilePicture string `json:"profilePicture"` Initials string `json:"initials"` Role string `json:"role"` //CustomRole string??? LastActive string `json:"last_active"` DateJoined string `json:"date_joined"` DateInvited string `json:"date_invited"` } `json:"user"` InvitedBy struct { ID string `json:"id"` Username string `json:"username"` Color string `json:"color"` Email string `json:"email"` Intials string `json:"intials"` ProfilePicture string `json:"profilePicture"` } `json:"invited_by"` }
type PersonalTokenTransport ¶
type PersonalTokenTransport struct { PersonalToken string // Transport is the underlying HTTP transport to use when making requests. // It will default to http.DefaultTransport if nil. Transport http.RoundTripper }
func (*PersonalTokenTransport) Client ¶
func (t *PersonalTokenTransport) Client() *http.Client
type Rate ¶
type Rate struct { // The number of requests per hour the client is currently limited to. Limit int `json:"limit"` // The number of remaining requests the client can make this hour. Remaining int `json:"remaining"` // The time at which the current rate limit will reset. Reset Timestamp `json:"reset"` }
Rate represents the rate limit for the current client.
type RateLimitError ¶
type RateLimitError struct { Rate Rate // Rate specifies last known rate limit for the client Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message }
func (*RateLimitError) Error ¶
func (r *RateLimitError) Error() string
func (*RateLimitError) Is ¶
func (r *RateLimitError) Is(target error) bool
Is returns whether the provided error equals this error.
type RateLimits ¶
type RateLimits struct { // The rate limit for non-search API requests. Unauthenticated // requests are limited to 60 per hour. Authenticated requests are // limited to 5,000 per hour. // Core *Rate `json:"core"` // The rate limit for search API requests. Unauthenticated requests // are limited to 10 requests per minutes. Authenticated requests are // limited to 30 per minute. // Search *Rate `json:"search"` GraphQL *Rate `json:"graphql"` IntegrationManifest *Rate `json:"integration_manifest"` SourceImport *Rate `json:"source_import"` CodeScanningUpload *Rate `json:"code_scanning_upload"` ActionsRunnerRegistration *Rate `json:"actions_runner_registration"` SCIM *Rate `json:"scim"` }
RateLimits represents the rate limits for the current client.
type RawOptions ¶
type RawOptions struct {
Type RawType
}
RawOptions specifies parameters when user wants to get raw format of a response instead of JSON.
type RawType ¶
type RawType uint8
RawType represents type of raw format of a request instead of JSON.
type Timestamp ¶
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.
type WorkspacesService ¶
type WorkspacesService service