Documentation ¶
Index ¶
- Constants
- type ClientOptionFunc
- type Logger
- type TogglError
- type TogglHttpClient
- func (c *TogglHttpClient) DeleteRequest(endpoint string, body interface{}) (*json.RawMessage, error)
- func (c *TogglHttpClient) GetRequest(endpoint string) (*json.RawMessage, error)
- func (c *TogglHttpClient) PostRequest(endpoint string, body interface{}) (*json.RawMessage, error)
- func (c *TogglHttpClient) PutRequest(endpoint string, body interface{}) (*json.RawMessage, error)
- type TogglResponse
Constants ¶
const ( DefaultAuthPassword = "api_token" DefaultMaxRetries = 5 DefaultGzipEnabled = false DefaultUrl = "https://www.toggl.com/api/v8" DefaultVersion = "v8" SessionCookieName = "__Host-timer-session" DefaultRateLimitPerSecond = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOptionFunc ¶
type ClientOptionFunc func(*TogglHttpClient) error
ClientOptionFunc is a function that configures a Client. It is used in NewClient.
func SetErrorLogger ¶
func SetErrorLogger(l Logger) ClientOptionFunc
Custom logger to handle error messages
func SetHttpClient ¶
func SetHttpClient(httpClient *http.Client) ClientOptionFunc
SetHttpClient can be used to specify the http.Client to use when making HTTP requests to Toggl
func SetInfoLogger ¶
func SetInfoLogger(l Logger) ClientOptionFunc
Custom logger to handle info messages
func SetRateLimit ¶
func SetRateLimit(perSec int) ClientOptionFunc
SetRateLimit Set custom rate limit per second
func SetTraceLogger ¶
func SetTraceLogger(l Logger) ClientOptionFunc
Custom logger to print HTTP requests
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger specifies the interface for all log operations.
type TogglError ¶
func (*TogglError) Error ¶
func (e *TogglError) Error() string
type TogglHttpClient ¶
type TogglHttpClient struct { Url string // set of URLs passed initially to the client // contains filtered or unexported fields }
Client is an Toggl REST client. Created by calling NewClient.
func NewClient ¶
func NewClient(key string, options ...ClientOptionFunc) (*TogglHttpClient, error)
Return a new TogglHttpClient . An error is also returned when some configuration option is invalid
tc,err := gtoggl.NewClient("token")
func (*TogglHttpClient) DeleteRequest ¶
func (c *TogglHttpClient) DeleteRequest(endpoint string, body interface{}) (*json.RawMessage, error)
Utility to DELETE requests
func (*TogglHttpClient) GetRequest ¶
func (c *TogglHttpClient) GetRequest(endpoint string) (*json.RawMessage, error)
Utility to GET requests
func (*TogglHttpClient) PostRequest ¶
func (c *TogglHttpClient) PostRequest(endpoint string, body interface{}) (*json.RawMessage, error)
Utility to POST requests
func (*TogglHttpClient) PutRequest ¶
func (c *TogglHttpClient) PutRequest(endpoint string, body interface{}) (*json.RawMessage, error)
Utility to PUT requests
type TogglResponse ¶
type TogglResponse struct {
Data *json.RawMessage `json:"data"`
}