Documentation ¶
Index ¶
- Constants
- func CACerts() *x509.CertPool
- func LazyCreateNewTransport(c *Client) *http.Transport
- func NewTransport() *http.Transport
- func ParseGoalResponse(data []byte) (*goal.Goal, error)
- func ParseHeartbeatResponses(data []byte) ([]heartbeat.Result, error)
- func ParseSummaryResponse(data []byte) (*summary.Summary, error)
- type BasicAuth
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Goal(id string) (*goal.Goal, error)
- func (c *Client) SendDiagnostics(plugin string, diagnostics ...diagnostic.Diagnostic) error
- func (c *Client) SendHeartbeats(heartbeats []heartbeat.Heartbeat) ([]heartbeat.Result, error)
- func (c *Client) Today() (*summary.Summary, error)
- type Err
- type ErrAuth
- type ErrBadRequest
- type Option
- func WithAuth(auth BasicAuth) (Option, error)
- func WithDisableSSLVerify() Option
- func WithHostname(hostname string) Option
- func WithNTLM(creds string) (Option, error)
- func WithNTLMRequestRetry(creds string) (Option, error)
- func WithProxy(proxyURL string) (Option, error)
- func WithSSLCertFile(filepath string) (Option, error)
- func WithSSLCertPool(caCertPool *x509.CertPool) (Option, error)
- func WithTimeout(timeout time.Duration) Option
- func WithTimezone(timezone string) Option
- func WithUserAgent(plugin string) Option
- func WithUserAgentUnknownPlugin() Option
Constants ¶
const ( // BaseURL is the base url of the wakatime api. BaseURL = "https://api.wakatime.com/api/v1" // DefaultTimeoutSecs is the default timeout used for requests to the wakatime api. DefaultTimeoutSecs = 120 )
Variables ¶
This section is empty.
Functions ¶
func CACerts ¶ added in v1.7.4
CACerts returns a root cert pool with the system's cacerts and LetsEncrypt's root certs.
func LazyCreateNewTransport ¶ added in v1.18.1
LazyCreateNewTransport uses the client's Transport if exists, or creates a new one.
func NewTransport ¶ added in v1.7.4
NewTransport initializes a new http.Transport.
func ParseGoalResponse ¶
ParseGoalResponse parses the wakatime api response into goal.Goal.
func ParseHeartbeatResponses ¶
ParseHeartbeatResponses parses the aggregated responses returned by the heartbeat bulk endpoint.
Types ¶
type BasicAuth ¶
BasicAuth contains authentication data.
func (BasicAuth) HeaderValue ¶
HeaderValue returns the value for Authorization header.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the wakatime api.
func (*Client) Do ¶
Do executes c.doFunc(), which in turn allows wrapping c.client.Do() and manipulating the request behavior of the api client.
func (*Client) Goal ¶
Goal fetches goal for the given goal id.
ErrRequest is returned upon request failure with no received response from api. ErrAuth is returned upon receiving a 401 Unauthorized api response. Err is returned on any other api response related error.
func (*Client) SendDiagnostics ¶ added in v1.18.1
func (c *Client) SendDiagnostics(plugin string, diagnostics ...diagnostic.Diagnostic) error
SendDiagnostics sends diagnostics to the WakaTime api.
func (*Client) SendHeartbeats ¶ added in v1.18.1
SendHeartbeats sends a bulk of heartbeats to the wakatime api and returns the result. The API does not guarantuee the setting of the Heartbeat property of the result. On certain errors, like 429/too many heartbeats, this is omitted and not set.
ErrRequest is returned upon request failure with no received response from api. ErrAuth is returned upon receiving a 401 Unauthorized api response. Err is returned on any other api response related error.
type ErrBadRequest ¶ added in v1.28.6
type ErrBadRequest string
ErrBadRequest represents a 400 response from the API.
func (ErrBadRequest) Error ¶ added in v1.28.6
func (e ErrBadRequest) Error() string
Error method to implement error interface.
type Option ¶
type Option func(*Client)
Option is a functional option for Client.
func WithDisableSSLVerify ¶
func WithDisableSSLVerify() Option
WithDisableSSLVerify disables verification of insecure certificates.
func WithHostname ¶
WithHostname sets the X-Machine-Name header to the passed in hostname.
func WithNTLMRequestRetry ¶
WithNTLMRequestRetry will, upon request failure, retry with ntlm authentication.
func WithSSLCertFile ¶
WithSSLCertFile overrides the default CA certs file to trust specified cert file.
func WithSSLCertPool ¶
WithSSLCertPool overrides the default CA cert pool to trust specified cert pool.
func WithTimeout ¶
WithTimeout configures a timeout for all requests.
func WithTimezone ¶ added in v1.31.0
WithTimezone sets the TimeZone header to the passed in timezone.
func WithUserAgent ¶
WithUserAgent sets the User-Agent header on all requests, including the passed in value for plugin.
func WithUserAgentUnknownPlugin ¶
func WithUserAgentUnknownPlugin() Option
WithUserAgentUnknownPlugin sets the User-Agent header on all requests, including default value for plugin.