ghttp

package module
v0.0.0-...-6046681 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2017 License: MIT Imports: 11 Imported by: 0

README

Toggl-Http-Client

Toggl-Http-Client is a toggl client for the Go programming language.

Build Status Go Report Card GoDoc Coverage Status license

Example:

go get gopkg.in/dougEfresh/toggl-http-client.v8

Documentation

Overview

Package gtoggl access to toggl REST API

Example:

        import "gopkg.in/dougEfresh/gtoggl.v8"
        import "ggopkg.in/dougEfresh/toggl-timeentry.v8"

        func main() {
	    thc, err := gtoggl.NewClient("token")
	    ...
	    tc, err := gtimeentry.NewClient(thc)
	    ...
	    timeentry,err := tc.Get(1)
	    if err == nil {
		panic(err)
	    }
	}

Index

Constants

View Source
const (
	DefaultAuthPassword = "api_token"
	DefaultMaxRetries   = 5
	DefaultGzipEnabled  = false
	DefaultUrl          = "https://www.toggl.com/api/v8"
	DefaultVersion      = "v8"
	SessionCookieName   = "toggl_api_session_new"

	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

func SetURL

func SetURL(url string) ClientOptionFunc

SetURL defines the base URL. See DefaultUrl

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger specifies the interface for all log operations.

type TogglError

type TogglError struct {
	Code   int
	Status string
	Msg    string
}

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL