glockify

package module
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 11 Imported by: 0

README

glockify

PkgGoDev Go Report Card

Unofficial Go SDK Wrapper for Clockify.

Documentation

Index

Constants

View Source
const (
	ProjectSortColumnName       ProjectSortColumn = "NAME"
	ProjectSortColumnClientName                   = "CLIENT_NAME"
	ProjectSortColumnDuration                     = "DURATION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutomaticLock

type AutomaticLock struct {
	ChangeDay       string `json:"changeDay,omitempty"`
	DayOfMonth      string `json:"dayOfMonth,omitempty"`
	FirstDay        string `json:"firstDay,omitempty"`
	OlderThanPeriod string `json:"olderThanPeriod,omitempty"`
	OlderThanValue  string `json:"olderThanValue,omitempty"`
	Type            string `json:"type,omitempty"`
}

AutomaticLock see: https://clockify.me/developers-api#tag-Workspace

type BudgetEstimate added in v0.5.0

type BudgetEstimate struct {
	Estimate    string `json:"estimate,omitempty"`
	Type        string `json:"type,omitempty"`
	ResetOption string `json:"resetOption,omitempty"`
	Active      bool   `json:"active,omitempty"`
}

BudgetEstimate wraps Clockify's budget estimate resource. See: https://clockify.me/developers-api#tag-Project

type Client

type Client struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	WorkspaceID string `json:"workspaceId,omitempty"`
	Archived    bool   `json:"archived,omitempty"`
}

Client represent Clockify's client resource. See: https://clockify.me/developers-api#tag-Client

type ClientNode

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

ClientNode manipulating Client resource.

func (*ClientNode) Add

func (c *ClientNode) Add(workspaceID string, name string, opts ...RequestOption) (*Client, error)

Add create new Client based on fields given.

func (*ClientNode) All

func (c *ClientNode) All(workspaceID string, opts ...RequestOption) ([]Client, error)

All get all Client resource based on filter given.

func (*ClientNode) Delete

func (c *ClientNode) Delete(workspaceID string, id string, opts ...RequestOption) (*Client,
	error)

Delete existing Client.

func (*ClientNode) Get

func (c *ClientNode) Get(workspaceID string, id string, opts ...RequestOption) (*Client, error)

Get one Client by its id.

func (*ClientNode) Update

func (c *ClientNode) Update(workspaceID string, id string, opts ...RequestOption) (*Client,
	error)

Update existing Client based on fields and options given.

type ClientSortColumn added in v0.8.0

type ClientSortColumn string
const (
	ClientSortColumnName ClientSortColumn = "NAME"
)

type ClientStatus added in v0.8.0

type ClientStatus string
const (
	ClientStatusActive   ClientStatus = "ACTIVE"
	ClientStatusArchived              = "ARCHIVED"
)

Possible values of ClientStatus

type CostRate added in v0.6.0

type CostRate struct {
	Amount   string `json:"amount,omitempty"`
	Currency string `json:"currency,omitempty"`
}

CostRate wraps Clockify's cost rate resource. See: https://clockify.me/developers-api#tag-Cost

type CustomFields added in v0.5.0

type CustomFields struct {
	CustomFieldID string      `json:"customFieldId,omitempty"`
	Name          string      `json:"name,omitempty"`
	Type          string      `json:"type,omitempty"`
	Value         interface{} `json:"value,omitempty"`
	Status        string      `json:"status,omitempty"`
}

CustomFields wraps Clockify's custom fields resource. See: https://clockify.me/developers-api#tag-Project

type Endpoint

type Endpoint struct {
	Base    string
	TimeOff string
	Report  string
}

Endpoint specify main endpoints in Clockify.

type Estimate added in v0.5.0

type Estimate struct {
	Estimate string `json:"estimate,omitempty"`
	Type     string `json:"type,omitempty"`
}

Estimate wraps Clockify's estimate resource. See: https://clockify.me/developers-api#tag-Project

type EstimateType added in v0.8.0

type EstimateType string
const (
	EstimateTypeManual EstimateType = "MANUAL"
	EstimateTypeAuto                = "AUTO"
)

Possible values of EstimateType

type Glockify

type Glockify struct {
	Workspace WorkspaceNode
	Client    ClientNode
	Project   ProjectNode
	Task      TaskNode
	// contains filtered or unexported fields
}

Glockify is an entry point to access Clockify API.

func New

func New(apiKey string, opts ...Option) *Glockify

New instantiate Glockify with apiKey given.

type HourlyRate

type HourlyRate struct {
	Amount   int    `json:"amount,omitempty"`
	Currency string `json:"currency,omitempty"`
}

HourlyRate see: https://clockify.me/developers-api#tag-Workspace

type Memberships

type Memberships struct {
	HourlyRate       HourlyRate `json:"hourlyRate,omitempty"`
	MembershipStatus string     `json:"membershipStatus,omitempty"`
	MembershipType   string     `json:"membershipType,omitempty"`
	TargetID         string     `json:"targetId,omitempty"`
	UserID           string     `json:"userId,omitempty"`
}

Memberships see: https://clockify.me/developers-api#tag-Workspace

type Option

type Option func(*Glockify)

Option control parameter that can given when creating new Glockify.

func WithEndpoint

func WithEndpoint(endpoint Endpoint) Option

WithEndpoint set endpoint when creating new Glockify.

type Project added in v0.5.0

type Project struct {
	ID             string         `json:"id,omitempty"`
	Name           string         `json:"name,omitempty"`
	HourlyRate     HourlyRate     `json:"hourlyRate,omitempty"`
	ClientID       string         `json:"clientId,omitempty"`
	Client         string         `json:"client,omitempty"`
	WorkspaceID    string         `json:"workspaceId,omitempty"`
	Billable       bool           `json:"billable,omitempty"`
	Memberships    []Memberships  `json:"memberships,omitempty"`
	Color          string         `json:"color,omitempty"`
	Estimate       Estimate       `json:"estimate,omitempty"`
	Archived       bool           `json:"archived,omitempty"`
	Tasks          []Tasks        `json:"tasks,omitempty"`
	Note           string         `json:"note,omitempty"`
	Duration       string         `json:"duration,omitempty"`
	CostRate       int            `json:"costRate,omitempty"`
	TimeEstimate   TimeEstimate   `json:"timeEstimate,omitempty"`
	BudgetEstimate BudgetEstimate `json:"budgetEstimate"`
	CustomFields   []CustomFields `json:"customFields,omitempty"`
	Public         bool           `json:"public,omitempty"`
	Template       bool           `json:"template,omitempty"`
	Favorite       bool           `json:"favorite,omitempty"`
}

Project represent Clockify's project resource. See: https://clockify.me/developers-api#tag-Project

type ProjectNode added in v0.5.0

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

ProjectNode manipulating Project resource.

func (*ProjectNode) Add added in v0.5.0

func (p *ProjectNode) Add(workspaceID string, name string, opts ...RequestOption) (*Project,
	error)

Add create new Project based on fields given.

func (*ProjectNode) All added in v0.5.0

func (p *ProjectNode) All(workspaceID string, opts ...RequestOption) ([]Project, error)

All get all Project resource based on filter given.

func (*ProjectNode) Delete added in v0.5.0

func (p *ProjectNode) Delete(workspaceID string, id string, opts ...RequestOption) (*Project,
	error)

Delete existing Project.

func (*ProjectNode) Get added in v0.5.0

func (p *ProjectNode) Get(workspaceID string, id string, opts ...RequestOption) (*Project, error)

Get one Project by its id.

func (*ProjectNode) Update added in v0.5.0

func (p *ProjectNode) Update(workspaceID string, id string, opts ...RequestOption) (*Project,
	error)

Update existing Project based on fields and options given.

func (*ProjectNode) UpdateEstimate added in v0.5.0

func (p *ProjectNode) UpdateEstimate(workspaceID string, id string,
	opts ...RequestOption) (*Project, error)

UpdateEstimate update existing Project's estimate based on fields and options given.

func (*ProjectNode) UpdateMemberships added in v0.5.0

func (p *ProjectNode) UpdateMemberships(workspaceID string, id string,
	opts ...RequestOption) (*Project, error)

UpdateMemberships update existing Project's memberships based on fields given.

func (*ProjectNode) UpdateTemplate added in v0.5.0

func (p *ProjectNode) UpdateTemplate(workspaceID string, id string,
	opts ...RequestOption) (*Project, error)

UpdateTemplate update existing Project's template based on fields options given.

type ProjectSortColumn added in v0.8.0

type ProjectSortColumn string

type RequestOption added in v0.8.0

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

func WithArchiveProjects added in v0.8.0

func WithArchiveProjects(archiveProjects bool) RequestOption

WithArchiveProjects set whether archiving client will result in archiving all projects of given client. Default to false.

func WithArchived added in v0.8.0

func WithArchived(archived bool) RequestOption

WithArchived when applied to All request, its filter response by active/archived state, and defaulted to false. When applied to Update request, its set entity state to active/archived, and defaulted to not set.

func WithAssigneeIDs added in v0.8.0

func WithAssigneeIDs(ids []string) RequestOption

WithAssigneeIDs set assignees for this task.

func WithBillable added in v0.8.0

func WithBillable(billable bool) RequestOption

WithBillable when applied to All, its filter response by its billable state. When applied to Update its set entity billable state.

func WithBudgetEstimate added in v0.8.0

func WithBudgetEstimate(estimate BudgetEstimate) RequestOption

WithBudgetEstimate set project's budget estimate.

func WithClientID added in v0.8.0

func WithClientID(id string) RequestOption

WithClientID set project's client id.

func WithClientSortColumn added in v0.8.0

func WithClientSortColumn(sortColumn ClientSortColumn) RequestOption

WithClientSortColumn set fields you want to sort against.

func WithClientStatus added in v0.8.0

func WithClientStatus(status ClientStatus) RequestOption

WithClientStatus filter projects returned with client state.

func WithClients added in v0.8.0

func WithClients(ids []string) RequestOption

WithClients if set, projects will be filtered by client IDs. Filter behaviour depends on the WithContainsClient.

func WithColor added in v0.8.0

func WithColor(color string) RequestOption

WithColor set project's color. It's in hex format, ex: #ffffff for white.

func WithContainsClient added in v0.8.0

func WithContainsClient(containsClient bool) RequestOption

WithContainsClient if set to true, WithClients filter will be inclusion, otherwise it will be exclusion. Default to true.

func WithContainsUser added in v0.8.0

func WithContainsUser(containsClient bool) RequestOption

WithContainsUser if set to true, WithUsers filter will be inclusion, otherwise it will be exclusion. Default to true.

func WithContext added in v0.8.0

func WithContext(ctx context.Context) RequestOption

WithContext set request context. Default to context.Background.

func WithEstimate added in v0.8.0

func WithEstimate(estimate string) RequestOption

WithEstimate set task estimate in Clockify time format. Eg: "PT2H" for 2 hour.

func WithEstimateType added in v0.8.0

func WithEstimateType(estimateType EstimateType) RequestOption

WithEstimateType EstimateTypeManual: type enables one fixed estimate for the whole project. EstimateTypeAuto: type enables task-based project estimate, and estimate duration doesn't matter.

func WithHourlyRate added in v0.8.0

func WithHourlyRate(rate HourlyRate) RequestOption

WithHourlyRate set project's hourly rates.

func WithHydrated added in v0.8.0

func WithHydrated(hydrated bool) RequestOption

WithHydrated if set to true, projects returned will contain custom fields, task and memberships. Default to false.

func WithIsActive added in v0.8.0

func WithIsActive(isActive bool) RequestOption

WithIsActive filter task by active state.

func WithIsPublic added in v0.8.0

func WithIsPublic(isPublic bool) RequestOption

WithIsPublic set project's permission state.

func WithIsTemplate added in v0.8.0

func WithIsTemplate(isTemplate bool) RequestOption

WithIsTemplate when applied to ProjectNode.All, it's filter projects returned whether it's used for template. When applied to ProjectNode.UpdateTemplate it's set whether project used for template.

func WithMemberships added in v0.8.0

func WithMemberships(memberships Memberships) RequestOption

WithMemberships set project's membership state.

func WithName added in v0.8.0

func WithName(name string) RequestOption

WithName when applied to All request, its filter response by its name. When applied to Update its set entity name.

func WithNote added in v0.8.0

func WithNote(note string) RequestOption

WithNote set project's note.

func WithPage added in v0.8.0

func WithPage(page int) RequestOption

WithPage set request's page. Default to 1.

func WithPageSize added in v0.8.0

func WithPageSize(pageSize int) RequestOption

WithPageSize set length of items returned from request. Default to 50. Maximum value is 5000.

func WithProjectSortColumn added in v0.8.0

func WithProjectSortColumn(sortColumn ProjectSortColumn) RequestOption

WithProjectSortColumn set fields you want to sort against.

func WithSortOrder added in v0.8.0

func WithSortOrder(sortOrder SortOrderValue) RequestOption

WithSortOrder set sorting behaviour. Default to SortOrderDescending.

func WithStatus added in v0.8.0

func WithStatus(status TaskStatus) RequestOption

WithStatus set task state.

func WithStrictNameSearch added in v0.8.0

func WithStrictNameSearch(on bool) RequestOption

WithStrictNameSearch if set to true, WithName filter will be exact match, meanwhile if set to false, partial search is executed.

func WithTaskSortColumn added in v0.8.0

func WithTaskSortColumn(sortColumn TaskSortColumn) RequestOption

WithTaskSortColumn set fields you want to sort against.

func WithTimeEstimate added in v0.8.0

func WithTimeEstimate(estimate TimeEstimate) RequestOption

WithTimeEstimate set project's time estimate.

func WithUserStatus added in v0.8.0

func WithUserStatus(status UserStatus) RequestOption

WithUserStatus filter projects returned with user state.

func WithUsers added in v0.8.0

func WithUsers(ids []string) RequestOption

WithUsers if set, projects will be filtered by user IDs who have access. Filter behaviour depends on the WithContainsUser.

type Round

type Round struct {
	Minutes string `json:"minutes,omitempty"`
	Round   string `json:"round,omitempty"`
}

Round see: https://clockify.me/developers-api#tag-Workspace

type SortOrderValue added in v0.8.0

type SortOrderValue string
const (
	SortOrderAscending  SortOrderValue = "ASCENDING"
	SortOrderDescending                = "DESCENDING"
)

Possible value for SortOrderValue

type Task added in v0.6.0

type Task struct {
	AssigneeIds []string   `json:"assigneeIds,omitempty"`
	Estimate    string     `json:"estimate,omitempty"`
	ID          string     `json:"id,omitempty"`
	Name        string     `json:"name,omitempty"`
	ProjectID   string     `json:"projectId,omitempty"`
	Billable    bool       `json:"billable,omitempty"`
	HourlyRate  HourlyRate `json:"hourlyRate,omitempty"`
	CostRate    CostRate   `json:"costRate,omitempty"`
	Status      string     `json:"status,omitempty"`
}

Task represents Clockify's task resource. See: https://clockify.me/developers-api#tag-Task

type TaskNode added in v0.6.0

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

TaskNode manipulating Task resource.

func (*TaskNode) Add added in v0.6.0

func (t *TaskNode) Add(workspaceID string, projectID string, name string,
	opts ...RequestOption) (*Task, error)

Add create new Task based on fields given.

func (*TaskNode) All added in v0.6.0

func (t *TaskNode) All(workspaceID string, projectID string, opts ...RequestOption) ([]Task,
	error)

All get all Task resource based on filter given.

func (*TaskNode) Delete added in v0.6.0

func (t *TaskNode) Delete(workspaceID string, projectID string, id string,
	opts ...RequestOption) (*Task, error)

Delete existing Task.

func (*TaskNode) Get added in v0.6.0

func (t *TaskNode) Get(workspaceID string, projectID string, id string,
	opts ...RequestOption) (*Task, error)

Get one Task by its id.

func (*TaskNode) Update added in v0.6.0

func (t *TaskNode) Update(workspaceID string, projectID string, id string,
	opts ...RequestOption) (*Task, error)

Update existing Task based on fields and options given.

type TaskSortColumn added in v0.8.0

type TaskSortColumn string
const (
	TaskSortColumnID   TaskSortColumn = "ID"
	TaskSortColumnName                = "NAME"
)

Possible value of TaskSortColumn

type TaskStatus added in v0.8.0

type TaskStatus string
const (
	TaskStatusActive TaskStatus = "ACTIVE"
	TaskStatusDone              = "DONE"
)

type Tasks added in v0.5.0

type Tasks struct {
	ID           string   `json:"id,omitempty"`
	Name         string   `json:"name,omitempty"`
	ProjectID    string   `json:"projectId,omitempty"`
	AssigneeIds  []string `json:"assigneeIds,omitempty"`
	AssigneeID   string   `json:"assigneeId,omitempty"`
	UserGroupIds []string `json:"userGroupIds,omitempty"`
	Estimate     string   `json:"estimate,omitempty"`
	Status       string   `json:"status,omitempty"`
	Duration     int      `json:"duration,omitempty"`
	Billable     bool     `json:"billable,omitempty"`
	HourlyRate   int      `json:"hourlyRate,omitempty"`
	CostRate     int      `json:"costRate,omitempty"`
}

Tasks wraps Clockify's tasks resource. See: https://clockify.me/developers-api#tag-Project

type TimeEstimate added in v0.5.0

type TimeEstimate struct {
	Estimate           string `json:"estimate,omitempty"`
	Type               string `json:"type,omitempty"`
	ResetOption        string `json:"resetOption,omitempty"`
	Active             bool   `json:"active,omitempty"`
	IncludeNonBillable bool   `json:"includeNonBillable,omitempty"`
}

TimeEstimate wraps Clockify's time estimate resource. See: https://clockify.me/developers-api#tag-Project

type UserStatus added in v0.8.0

type UserStatus string
const (
	UserStatusActive   UserStatus = "ACTIVE"
	UserStatusInactive            = "INACTIVE"
)

Possible values of UserStatus

type Workspace

type Workspace struct {
	ID                string            `json:"id,omitempty"`
	Name              string            `json:"name,omitempty"`
	HourlyRate        HourlyRate        `json:"hourlyRate,omitempty"`
	ImageURL          string            `json:"imageUrl,omitempty"`
	Memberships       []Memberships     `json:"memberships,omitempty"`
	WorkspaceSettings WorkspaceSettings `json:"workspaceSettings,omitempty"`
}

Workspace represent Clockify's workspace resource. See: https://clockify.me/developers-api#tag-Workspace

type WorkspaceNode

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

WorkspaceNode manipulating Workspace resource.

func (*WorkspaceNode) All

func (w *WorkspaceNode) All(opts ...RequestOption) ([]Workspace, error)

All get all Workspace resource.

type WorkspaceSettings

type WorkspaceSettings struct {
	AdminOnlyPages                     []interface{} `json:"adminOnlyPages,omitempty"`
	AutomaticLock                      AutomaticLock `json:"automaticLock,omitempty"`
	CanSeeTimeSheet                    bool          `json:"canSeeTimeSheet,omitempty"`
	CanSeeTracker                      bool          `json:"canSeeTracker,omitempty"`
	DefaultBillableProjects            bool          `json:"defaultBillableProjects,omitempty"`
	ForceDescription                   bool          `json:"forceDescription,omitempty"`
	ForceProjects                      bool          `json:"forceProjects,omitempty"`
	ForceTags                          bool          `json:"forceTags,omitempty"`
	ForceTasks                         bool          `json:"forceTasks,omitempty"`
	LockTimeEntries                    time.Time     `json:"lockTimeEntries,omitempty"`
	OnlyAdminsCreateProject            bool          `json:"onlyAdminsCreateProject,omitempty"`
	OnlyAdminsCreateTag                bool          `json:"onlyAdminsCreateTag,omitempty"`
	OnlyAdminsCreateTask               bool          `json:"onlyAdminsCreateTask,omitempty"`
	OnlyAdminsSeeAllTimeEntries        bool          `json:"onlyAdminsSeeAllTimeEntries,omitempty"`
	OnlyAdminsSeeBillableRates         bool          `json:"onlyAdminsSeeBillableRates,omitempty"`
	OnlyAdminsSeeDashboard             bool          `json:"onlyAdminsSeeDashboard,omitempty"`
	OnlyAdminsSeePublicProjectsEntries bool          `json:"onlyAdminsSeePublicProjectsEntries,omitempty"`
	ProjectFavorites                   bool          `json:"projectFavorites,omitempty"`
	ProjectGroupingLabel               string        `json:"projectGroupingLabel,omitempty"`
	ProjectPickerSpecialFilter         bool          `json:"projectPickerSpecialFilter,omitempty"`
	Round                              Round         `json:"round,omitempty"`
	TimeRoundingInReports              bool          `json:"timeRoundingInReports,omitempty"`
	TrackTimeDownToSecond              bool          `json:"trackTimeDownToSecond,omitempty"`
	IsProjectPublicByDefault           bool          `json:"isProjectPublicByDefault,omitempty"`
	FeatureSubscriptionType            string        `json:"featureSubscriptionType,omitempty"`
}

WorkspaceSettings see: https://clockify.me/developers-api#tag-Workspace

Jump to

Keyboard shortcuts

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