clockify

package module
v0.0.0-...-6b361b2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 10 Imported by: 0

README

go-clockify

A Go library for accessing the Clockify API

Installation

Include github.com/kinoba/go-clockify as a dependency in your code. The library imports as clockify.

Documentation

Overview

Package clockify provides an API for interacting with the Clockify time tracking service.

See https://clockify.me/developers-api for more information on Clockify's REST API.

Index

Constants

View Source
const (
	ClockifyAPI    = "https://api.clockify.me/api/v1"
	DefaultAppName = "go-clockify"
)

Clockify service constants

Variables

View Source
var (

	// AppName is the application name used when creating timers.
	AppName = DefaultAppName
)

Functions

func DisableLog

func DisableLog()

DisableLog disables output to stderr

func EnableLog

func EnableLog()

EnableLog enables output to stderr

Types

type Account

type Account struct {
	// APIToken        string      `json:"api_token"`
	ID          string          `json:"id"`
	Name        string          `json:"name"`
	Email       string          `json:"email"`
	Workspaces  []Workspace     `json:"workspaces"`
	Clients     []Client        `json:"clients"`
	Projects    []Project       `json:"projects"`
	Tasks       []Task          `json:"tasks"`
	Tags        []Tag           `json:"tags"`
	TimeEntries []TimeEntry     `json:"time_entries"`
	Settings    AccountSettings `json:"settings"`
}

Account represents a user account.

type AccountSettings

type AccountSettings struct {
	WeekStart  string `json:"weekStart"`
	TimeZone   string `json:"timeZone"`
	TimeFormat string `json:"timeFormat"`
	DateFormat string `json:"dateFormat"`
}

AccountSettings represents a user account settings.

type Client

type Client struct {
	Wid  string `json:"workspaceId"`
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Client represents a client.

type Project

type Project struct {
	Wid string `json:"workspaceId"`
	ID  string `json:"id"`
	// Cid             int        `json:"cid"`
	Name     string `json:"name"`
	Active   bool   `json:"archived"`
	Billable bool   `json:"billable"`
}

Project represents a project.

func (*Project) IsActive

func (p *Project) IsActive() bool

IsActive indicates whether a project exists and is active

type Session

type Session struct {
	APIToken string
}

Session represents an active connection to the Clockify REST API.

func OpenSession

func OpenSession(apiToken string) Session

OpenSession opens a session using an existing API token.

func (*Session) ContinueTimeEntry

func (session *Session) ContinueTimeEntry(timer TimeEntry, duronly bool) (TimeEntry, error)

ContinueTimeEntry continues a time entry by creating a new entry with the same description. The new entry will have the same description and project ID as the existing one.

func (*Session) DeleteTimeEntry

func (session *Session) DeleteTimeEntry(workspaceID, timeEntryID string) ([]byte, error)

DeleteTimeEntry deletes a time entry.

func (*Session) GetAccount

func (session *Session) GetAccount() (Account, error)

GetAccount returns a user's account information, including a list of active projects and timers.

func (*Session) GetProjects

func (session *Session) GetProjects(workspaceID string) (projects []Project, err error)

GetProjects allows to query for all projects in a workspace

func (*Session) GetTimeEntry

func (session *Session) GetTimeEntry(workspaceID, timeEntryID string) (TimeEntry, error)

GetTimeEntry returns the time entry

func (*Session) StartTimeEntry

func (session *Session) StartTimeEntry(workspaceID string, timeEntryRequest TimeEntryRequest) (TimeEntry, error)

StartTimeEntry creates a new time entry.

func (*Session) StopTimeEntry

func (session *Session) StopTimeEntry(workspaceID, userID string) (TimeEntry, error)

StopTimeEntry stops a running time entry.

type Tag

type Tag struct {
	Wid  string `json:"workspaceId"`
	ID   string `json:"id"`
	Name string `json:"name"`
}

Tag represents a tag.

type Task

type Task struct {
	Pid  string `json:"projectId"`
	ID   string `json:"id"`
	Name string `json:"name"`
}

Task represents a task.

type TimeEntry

type TimeEntry struct {
	Wid          string       `json:"workspaceId,omitempty"`
	ID           string       `json:"id,omitempty"`
	Pid          string       `json:"pid"`
	Tid          string       `json:"taskId"`
	Description  string       `json:"description,omitempty"`
	TimeInterval TimeInterval `json:"timeInterval"`
	Tags         []string     `json:"tagIds"`
	Billable     bool         `json:"billable"`
}

TimeEntry represents a single time entry.

type TimeEntryRequest

type TimeEntryRequest struct {
	Start       string   `json:"start,omitempty"`
	Pid         string   `json:"projectId,omitempty"`
	Tid         string   `json:"taskId,omitempty"`
	Description string   `json:"description,omitempty"`
	End         string   `json:"end,omitempty"`
	Tags        []string `json:"tagIds,omitempty"`
	Billable    bool     `json:"billable,omitempty"`
}

TimeEntryRequest represents a single time entry request.

type TimeInterval

type TimeInterval struct {
	Duration string     `json:"duration"`
	Stop     *time.Time `json:"end,omitempty"`
	Start    *time.Time `json:"start,omitempty"`
}

TimeInterval represents a time interval.

type Workspace

type Workspace struct {
	ID              string `json:"id"`
	RoundingMinutes int    `json:"rounding_minutes"`
	// Rounding        int    `json:"rounding"`
	Name string `json:"name"`
}

Workspace represents a user workspace.

Directories

Path Synopsis
The toggl command will display a user's Clockify account information.
The toggl command will display a user's Clockify account information.

Jump to

Keyboard shortcuts

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