toggl

package
v0.0.0-...-cf5f3dd Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_AGENT   string = "https://github.com/nikoheikkila/hours"
	BASE_URL     string = "https://api.track.toggl.com/reports/api/v2"
	CONTENT_TYPE string = "application/json"
	PASSWORD     string = "api_token"
)
View Source
const (
	DATE_LAYOUT    string = "02.01.2006"
	NO_CLIENT      string = "No Client"
	NO_PROJECT     string = "No Project"
	NO_DESCRIPTION string = "No Description"
)

Variables

View Source
var (
	Client           HTTPClient
	ErrMissingToken  error = errors.New("missing Toggl API token for the client")
	ErrEmptyResponse error = errors.New("empty response from Toggl API")
)

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Token     string `yaml:"api_token"`
	Workspace string `yaml:"workspace_id"`
}

func LoadConfiguration

func LoadConfiguration() (*Configuration, error)

type DetailedReport

type DetailedReport struct {
	TotalGrand      int `json:"total_grand"`
	TotalBillable   int `json:"total_billable"`
	TotalCount      int `json:"total_count"`
	PerPage         int `json:"per_page"`
	TotalCurrencies []struct {
		Currency string  `json:"currency"`
		Amount   float32 `json:"amount"`
	} `json:"total_currencies"`
	Data []TimeEntry `json:"data"`
}

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Message string `json:"message"`
		Tip     string `json:"tip"`
		Code    int    `json:"code"`
	} `json:"error"`
}

type HTTPClient

type HTTPClient interface {
	Do(request *http.Request) (*http.Response, error)
}

type TimeEntry

type TimeEntry struct {
	Id          int       `json:"id"`
	ProjectId   int       `json:"pid"`
	TeamId      int       `json:"tid"`
	UserId      int       `json:"uid"`
	Description string    `json:"description"`
	Start       time.Time `json:"start"`
	End         time.Time `json:"end"`
	Updated     time.Time `json:"updated"`
	Duration    int64     `json:"dur"`
	User        string    `json:"user"`
	UseStop     bool      `json:"use_stop"`
	Client      string    `json:"client"`
	Project     string    `json:"project"`
	Color       string    `json:"project_color"`
	HexColor    string    `json:"project_hex_color"`
	Task        string    `json:"task"`
	Billable    float32   `json:"billable"`
	IsBillable  bool      `json:"is_billable"`
	Currency    string    `json:"cur"`
	Tags        []string  `json:"tags"`
}

func (*TimeEntry) FormatEndDate

func (e *TimeEntry) FormatEndDate() string

func (*TimeEntry) FormatHours

func (e *TimeEntry) FormatHours() string

func (*TimeEntry) FormatStartDate

func (e *TimeEntry) FormatStartDate() string

func (*TimeEntry) GetClient

func (e *TimeEntry) GetClient() string

func (*TimeEntry) GetDescription

func (e *TimeEntry) GetDescription() string

func (*TimeEntry) GetHours

func (e *TimeEntry) GetHours() float64

func (*TimeEntry) GetProject

func (e *TimeEntry) GetProject() string

type TogglClient

type TogglClient struct {
	// contains filtered or unexported fields
}

func New

func New(configuration *Configuration) *TogglClient

func (*TogglClient) Entries

func (c *TogglClient) Entries(start, end string) ([]TimeEntry, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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