toggl

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_TIME_ENTRY_DURATION = 60 // seconds
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientGateway

type ClientGateway interface {
	Get(filter *GetClientOpts) (TogglClients, error)
}

type ClientService

type ClientService struct {
	ClientGateway ClientGateway
}

func NewClientService

func NewClientService(clientGateway ClientGateway) ClientService

func (*ClientService) Get added in v0.3.0

func (c *ClientService) Get(filter *GetClientOpts) (TogglClients, error)

type ClientsByName

type ClientsByName TogglClients

ByName implements sort.Interface based on the Name field of TogglClientElement.

func (ClientsByName) Len

func (a ClientsByName) Len() int

func (ClientsByName) Less

func (a ClientsByName) Less(i, j int) bool

func (ClientsByName) Swap

func (a ClientsByName) Swap(i, j int)

type DaySection

type DaySection struct {
	Date             time.Time
	IntervalSections []*IntervalSection
}

func NewDaySection

func NewDaySection() *DaySection

func (*DaySection) Duration

func (d *DaySection) Duration() float64

type GetClientOpts added in v0.3.0

type GetClientOpts struct {
	Name string
}

type GetProjectsOpts

type GetProjectsOpts struct {
	Name            string
	IncludeArchived bool
	ClientID        int64
}

type GetTimeOpts added in v0.3.0

type GetTimeOpts struct {
	Start time.Time
	End   time.Time
}

type GtAutoTaskRequest added in v0.0.22

type GtAutoTaskRequest struct {
	ID        int       `json:"id"`
	IsTicket  bool      `json:"isTicket"`
	Date      time.Time `json:"date"`
	StartTime string    `json:"startTime"`
	Duration  float64   `json:"duration"`
	Summary   string    `json:"summary"`
	Project   string    `json:"project"`
}

type IntervalSection

type IntervalSection struct {
	StartDateTime time.Time
	EndDateTime   time.Time
	Description   string
	Duration      float64
}

func (*IntervalSection) DurationS

func (i *IntervalSection) DurationS() string

type JsonReport added in v0.0.22

type JsonReport struct {
}

func NewJsonReport added in v0.0.22

func NewJsonReport() JsonReport

func (*JsonReport) Generate added in v0.0.22

func (*JsonReport) Generate(report *Report) (*[]byte, error)

type NewTogglTimeEntry added in v0.3.0

type NewTogglTimeEntry struct {
	Billable    bool     `json:"billable,omitempty"`    // Whether the time entry is marked as billable. Optional, default false.
	CreatedWith string   `json:"created_with"`          // Must be provided when creating a time entry and should identify the service/application used to create it.
	Description string   `json:"description,omitempty"` // Time entry description. Optional.
	Duration    int64    `json:"duration"`              // Time entry duration. For running entries should be negative, preferable -1.
	ProjectID   int64    `json:"project_id,omitempty"`  // Project ID. Optional.
	Start       string   `json:"start"`                 // Start time in UTC, required for creation. Format: 2006-01-02T15:04:05Z.
	Stop        string   `json:"stop,omitempty"`        // Stop time in UTC, can be omitted if it's still running or created with "duration". If "stop" and "duration" are provided, values must be consistent (start + duration == stop).
	TagAction   string   `json:"tag_action,omitempty"`  // Can be "add" or "delete". Used when updating an existing time entry.
	TagIDs      []int    `json:"tag_ids,omitempty"`     // IDs of tags to add/remove.
	Tags        []string `json:"tags,omitempty"`        // Names of tags to add/remove. If name does not exist as tag, one will be created automatically.
	WorkspaceID int64    `json:"workspace_id"`          // Workspace ID. Required.
}

https://developers.track.toggl.com/docs/api/time_entries#post-timeentries

type ProjectGateway

type ProjectGateway interface {
	Get(filter *GetProjectsOpts) (TogglProjects, error)
	Create(projectName string, clientID int64) error
}

type ProjectKey

type ProjectKey struct {
	Client    string
	Project   string
	ProjectID int64
}

type ProjectSection

type ProjectSection struct {
	TaskID      int
	IsTask      bool
	ClientID    string
	ProjectID   string
	Client      string
	Project     string
	DaySections []*DaySection
}

func NewProjectSection

func NewProjectSection() *ProjectSection

func (*ProjectSection) Duration

func (p *ProjectSection) Duration() float64

type ProjectService

type ProjectService struct {
	ProjectGateway ProjectGateway
}

func NewProjectService

func NewProjectService(projectGateway ProjectGateway) ProjectService

func (*ProjectService) Create added in v0.3.0

func (p *ProjectService) Create(projectName string, clientID int64) error

func (*ProjectService) Get added in v0.3.0

func (*ProjectService) HasValidName added in v0.3.0

func (p *ProjectService) HasValidName(name string) bool

func (*ProjectService) ParseProjectTitle

func (p *ProjectService) ParseProjectTitle(project string) (ProjectTitle, error)

type ProjectTitle

type ProjectTitle struct {
	Client   string
	Project  string
	IsTask   bool
	TaskID   int
	TicketID string
}

type ProjectsByName

type ProjectsByName TogglProjects

ProjectsByName implements sort.Interface based on the Name field of TogglClientElement.

func (ProjectsByName) Len

func (a ProjectsByName) Len() int

func (ProjectsByName) Less

func (a ProjectsByName) Less(i, j int) bool

func (ProjectsByName) Swap

func (a ProjectsByName) Swap(i, j int)

type Report

type Report struct {
	StartDate       time.Time
	EndDate         time.Time
	ProjectSections []*ProjectSection
}

func NewReport

func NewReport(sd, ed time.Time) (*Report, error)

func (*Report) Duration

func (r *Report) Duration() float64

type ReportBuilder added in v0.0.22

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

func NewReportBuilder added in v0.0.22

func NewReportBuilder(timeService TimeService, projectService ProjectService) ReportBuilder

func (*ReportBuilder) BuildReport added in v0.0.22

func (r *ReportBuilder) BuildReport(sd, ed time.Time) (*Report, error)

type ReportRange

type ReportRange int
const (
	Today ReportRange = iota
	Yesterday
	LastWeek
	ThisWeek
	Custom
	EYesterday
)

type ReportService

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

func NewReportService

func NewReportService(timeService TimeService, projectService ProjectService) ReportService

func (*ReportService) BuildJsonReport added in v0.0.22

func (r *ReportService) BuildJsonReport(model *Report) (*[]byte, error)

func (*ReportService) BuildReport added in v0.0.22

func (r *ReportService) BuildReport(sd, ed time.Time) (*Report, error)

func (*ReportService) BuildStringReport added in v0.0.22

func (r *ReportService) BuildStringReport(model *Report) (*string, error)

type StringReport added in v0.0.22

type StringReport struct {
}

func NewStringReport added in v0.0.22

func NewStringReport() StringReport

func (*StringReport) Generate added in v0.0.22

func (*StringReport) Generate(r *Report) *string

type TimeEntryGateway

type TimeEntryGateway interface {
	Get(start, end time.Time) (TogglTimeEntries, error)
	Add(timeEntry *NewTogglTimeEntry) error
	GetCurrent() (*TogglTimeEntry, error)
	Stop(entryID int64) error
	EditDesc(entryID int64, desc string) error
}

type TimeService

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

func NewTimeService

func NewTimeService(timeEntryGateway TimeEntryGateway, clientService ClientService, projectService ProjectService) TimeService

func (*TimeService) Add added in v0.3.0

func (t *TimeService) Add(entry *NewTogglTimeEntry) error

func (*TimeService) EditDesc added in v0.6.0

func (t *TimeService) EditDesc(desc string) error

func (*TimeService) Get added in v0.3.0

func (t *TimeService) Get(start, end time.Time) (TogglTimeEntries, error)

func (*TimeService) ResumeLast added in v0.5.0

func (t *TimeService) ResumeLast() error

func (*TimeService) Stop added in v0.4.0

func (t *TimeService) Stop() error

type TogglClientElement

type TogglClientElement struct {
	ID       int64  `json:"id"`
	Wid      int64  `json:"wid"`
	Archived bool   `json:"archived"`
	Name     string `json:"name"`
	At       string `json:"at"`
}

type TogglClients

type TogglClients []*TogglClientElement

type TogglProjectElement

type TogglProjectElement struct {
	ID                  int64       `json:"id"`
	WorkspaceID         int64       `json:"workspace_id"`
	ClientID            int64       `json:"client_id"`
	Name                string      `json:"name"`
	IsPrivate           bool        `json:"is_private"`
	Active              bool        `json:"active"`
	At                  string      `json:"at"`
	CreatedAt           string      `json:"created_at"`
	ServerDeletedAt     interface{} `json:"server_deleted_at"`
	Color               string      `json:"color"`
	Billable            interface{} `json:"billable"`
	Template            interface{} `json:"template"`
	AutoEstimates       interface{} `json:"auto_estimates"`
	EstimatedHours      interface{} `json:"estimated_hours"`
	Rate                interface{} `json:"rate"`
	RateLastUpdated     interface{} `json:"rate_last_updated"`
	Currency            interface{} `json:"currency"`
	Recurring           bool        `json:"recurring"`
	RecurringParameters interface{} `json:"recurring_parameters"`
	CurrentPeriod       interface{} `json:"current_period"`
	FixedFee            interface{} `json:"fixed_fee"`
	ActualHours         int64       `json:"actual_hours"`

	// Derived
	Client string
}

type TogglProjects

type TogglProjects []*TogglProjectElement

type TogglTimeEntries

type TogglTimeEntries []*TogglTimeEntry

type TogglTimeEntry

type TogglTimeEntry struct {
	ID              int64       `json:"id"`
	WorkspaceID     int64       `json:"workspace_id"`
	ProjectID       int64       `json:"project_id"`
	TaskID          int64       `json:"task_id"`
	Billable        bool        `json:"billable"`
	Start           time.Time   `json:"start"`
	Stop            time.Time   `json:"stop"`
	Duration        int64       `json:"duration"` // in seconds, running entries contain a negative duration
	Description     string      `json:"description"`
	ServerDeletedAt interface{} `json:"server_deleted_at"`

	// derived fields
	Client   string
	ClientID int64
	Project  string
}

Online documentation: https://developers.track.toggl.com/docs/api/time_entries/index.html#response-1

type UpdateTogglTimeEntryDesc added in v0.6.0

type UpdateTogglTimeEntryDesc struct {
	Description string `json:"description"`
}

Directories

Path Synopsis
Implements the ClientGateway by reading from a file
Implements the ClientGateway by reading from a file

Jump to

Keyboard shortcuts

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