api

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TaskStatusDefault = ""
	TaskStatusDone    = "DONE"
	TaskStatusActive  = "ACTIVE"
)

Variables

View Source
var ErrorForbidden = dto.Error{Message: "Forbidden", Code: 403}

ErrorForbidden Forbidden

View Source
var ErrorMissingAPIKey = errors.New("api Key must be informed")

ErrorMissingAPIKey returned if X-Api-Key is missing

View Source
var ErrorMissingAPIURL = errors.New("api URL must be informed")

ErrorMissingAPIURL returned if base url is missing

View Source
var ErrorNotFound = dto.Error{Message: "Nothing was found", Code: 404}

ErrorNotFound Not Found

Functions

func IsValidID added in v0.36.0

func IsValidID(id string) bool

IsValidID checks if a string looks like a valid ID

Types

type AddClientParam added in v0.31.0

type AddClientParam struct {
	Workspace string
	Name      string
}

type AddProjectParam added in v0.31.0

type AddProjectParam struct {
	Workspace string
	Name      string
	ClientId  string
	Color     string
	Note      string
	Billable  bool
	Public    bool
}

type AddTaskParam added in v0.31.0

type AddTaskParam struct {
	Workspace   string
	ProjectID   string
	Name        string
	AssigneeIDs *[]string
	Estimate    *time.Duration
	Status      TaskStatus
	Billable    *bool
}

AddTaskParam param to add tasks to a project

type ChangeInvoicedParam added in v0.24.0

type ChangeInvoicedParam struct {
	Workspace    string
	TimeEntryIDs []string
	Invoiced     bool
}

type Client

type Client interface {
	// SetDebugLogger when set will output the responses of requests to the
	// logger
	SetDebugLogger(logger Logger) Client
	// SetInfoLogger when set will output which requests and params are used to
	// the logger
	SetInfoLogger(logger Logger) Client

	GetWorkspace(GetWorkspace) (dto.Workspace, error)
	GetWorkspaces(GetWorkspaces) ([]dto.Workspace, error)

	GetMe() (dto.User, error)
	GetUser(GetUser) (dto.User, error)
	WorkspaceUsers(WorkspaceUsersParam) ([]dto.User, error)

	AddClient(AddClientParam) (dto.Client, error)
	GetClients(GetClientsParam) ([]dto.Client, error)

	AddProject(AddProjectParam) (dto.Project, error)
	UpdateProject(UpdateProjectParam) (dto.Project, error)
	GetProject(GetProjectParam) (*dto.Project, error)
	GetProjects(GetProjectsParam) ([]dto.Project, error)

	AddTask(AddTaskParam) (dto.Task, error)
	DeleteTask(DeleteTaskParam) (dto.Task, error)
	GetTask(GetTaskParam) (dto.Task, error)
	GetTasks(GetTasksParam) ([]dto.Task, error)
	UpdateTask(UpdateTaskParam) (dto.Task, error)

	GetTag(GetTagParam) (*dto.Tag, error)
	GetTags(GetTagsParam) ([]dto.Tag, error)

	ChangeInvoiced(ChangeInvoicedParam) error
	CreateTimeEntry(CreateTimeEntryParam) (dto.TimeEntryImpl, error)
	DeleteTimeEntry(DeleteTimeEntryParam) error
	GetHydratedTimeEntry(GetTimeEntryParam) (*dto.TimeEntry, error)
	GetHydratedTimeEntryInProgress(GetTimeEntryInProgressParam) (*dto.TimeEntry, error)
	GetTimeEntry(GetTimeEntryParam) (*dto.TimeEntryImpl, error)
	GetTimeEntryInProgress(GetTimeEntryInProgressParam) (*dto.TimeEntryImpl, error)
	GetUserTimeEntries(GetUserTimeEntriesParam) ([]dto.TimeEntryImpl, error)
	GetUsersHydratedTimeEntries(GetUserTimeEntriesParam) ([]dto.TimeEntry, error)
	Log(LogParam) ([]dto.TimeEntry, error)
	LogRange(LogRangeParam) ([]dto.TimeEntry, error)
	UpdateTimeEntry(UpdateTimeEntryParam) (dto.TimeEntryImpl, error)
	Out(OutParam) error
}

Client will help to access Clockify API

func NewClient

func NewClient(apiKey string) (Client, error)

NewClient create a new Client, based on: https://clockify.github.io/clockify_api_docs/

func NewClientFromUrlAndKey added in v0.40.0

func NewClientFromUrlAndKey(
	apiKey,
	urlString string,
) (Client, error)

type CreateTimeEntryParam

type CreateTimeEntryParam struct {
	Workspace   string
	Start       time.Time
	End         *time.Time
	Billable    bool
	Description string
	ProjectID   string
	TaskID      string
	TagIDs      []string
}

CreateTimeEntryParam params to create a new time entry

type DeleteTaskParam added in v0.35.0

type DeleteTaskParam struct {
	Workspace string
	ProjectID string
	TaskID    string
}

DeleteTaskParam param to update tasks to a project

type DeleteTimeEntryParam added in v0.11.0

type DeleteTimeEntryParam struct {
	Workspace   string
	TimeEntryID string
}

DeleteTimeEntryParam params to update a new time entry

type EntityNotFound added in v0.36.0

type EntityNotFound struct {
	EntityName string
	ID         string
}

func (EntityNotFound) Error added in v0.36.0

func (e EntityNotFound) Error() string

func (EntityNotFound) Unwrap added in v0.36.0

func (e EntityNotFound) Unwrap() error

type GetClientsParam added in v0.31.0

type GetClientsParam struct {
	Workspace string
	Name      string
	Archived  *bool

	PaginationParam
}

GetClientsParam params to get all clients of a workspace

type GetProjectParam

type GetProjectParam struct {
	Workspace string
	ProjectID string
}

GetProjectParam params to get a Project

type GetProjectsParam

type GetProjectsParam struct {
	Workspace string
	Name      string
	Clients   []string
	Archived  *bool

	PaginationParam
}

GetProjectsParam params to get all project of a workspace

type GetTagParam

type GetTagParam struct {
	Workspace string
	TagID     string
}

GetTagParam params to find a tag

type GetTagsParam

type GetTagsParam struct {
	Workspace string
	Name      string
	Archived  *bool

	PaginationParam
}

GetTagsParam params to get all tags of a workspace

type GetTaskParam

type GetTaskParam struct {
	Workspace string
	ProjectID string
	TaskID    string
}

GetTaskParam param to get a task on a project

type GetTasksParam added in v0.23.0

type GetTasksParam struct {
	Workspace string
	ProjectID string
	Active    bool
	Name      string

	PaginationParam
}

GetTasksParam param to find tasks of a project

type GetTimeEntryInProgressParam added in v0.22.0

type GetTimeEntryInProgressParam struct {
	Workspace string
	UserID    string
}

GetTimeEntryInProgressParam params to query entries

type GetTimeEntryParam added in v0.1.7

type GetTimeEntryParam struct {
	Workspace              string
	TimeEntryID            string
	ConsiderDurationFormat bool
}

GetTimeEntryParam params to get a Time Entry

type GetUser added in v0.24.0

type GetUser struct {
	Workspace string
	UserID    string
}

GetUser params to get a user

type GetUserTimeEntriesParam added in v0.24.0

type GetUserTimeEntriesParam struct {
	Workspace      string
	UserID         string
	OnlyInProgress *bool
	Start          *time.Time
	End            *time.Time
	Description    string
	ProjectID      string

	PaginationParam
}

type GetWorkspace added in v0.18.0

type GetWorkspace struct {
	ID string
}

type GetWorkspaces added in v0.15.0

type GetWorkspaces struct {
	Name string
}

GetWorkspaces will be used to filter the workspaces

type InvalidIDError added in v0.36.0

type InvalidIDError struct {
	Field string
	ID    string
}

InvalidIDError indicates that a field should be a valid ID, but it is not

func (InvalidIDError) Error added in v0.36.0

func (e InvalidIDError) Error() string

type LogParam

type LogParam struct {
	Workspace string
	UserID    string
	Date      time.Time
	PaginationParam
}

LogParam params to query entries

type LogRangeParam added in v0.1.2

type LogRangeParam struct {
	Workspace   string
	UserID      string
	FirstDate   time.Time
	LastDate    time.Time
	Description string
	ProjectID   string
	PaginationParam
}

LogRangeParam params to query entries

type Logger

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

Logger for the Client

type OutParam

type OutParam struct {
	Workspace string
	UserID    string
	End       time.Time
}

OutParam params to end the current time entry

type PaginationParam added in v0.1.7

type PaginationParam struct {
	AllPages bool
	Page     int
	PageSize int
}

PaginationParam parameters about pagination

func AllPages added in v0.30.0

func AllPages() PaginationParam

AllPages sets the query to retrieve all pages

type QueryAppender added in v0.1.5

type QueryAppender interface {
	AppendToQuery(*url.URL) *url.URL
}

QueryAppender an interface to identify if the parameters should be sent through the query or body

type RequiredFieldError added in v0.36.0

type RequiredFieldError struct {
	Field string
}

RequiredFieldError indicates that a field should be filled, but was not

func (RequiredFieldError) Error added in v0.36.0

func (e RequiredFieldError) Error() string

type TaskStatus added in v0.35.0

type TaskStatus string

type UpdateProjectParam added in v0.40.0

type UpdateProjectParam struct {
	Workspace string
	ID        string
	Name      string
	ClientId  *string
	Color     string
	Note      *string
	Billable  *bool
	Public    *bool
	Archived  *bool
}

UpdateProjectParam sets the properties to change on a project Workspace and ID are required

type UpdateTaskParam added in v0.35.0

type UpdateTaskParam struct {
	Workspace   string
	ProjectID   string
	TaskID      string
	Name        string
	AssigneeIDs *[]string
	Estimate    *time.Duration
	Status      TaskStatus
	Billable    *bool
}

UpdateTaskParam param to update tasks to a project

type UpdateTimeEntryParam

type UpdateTimeEntryParam struct {
	Workspace   string
	TimeEntryID string
	Start       time.Time
	End         *time.Time
	Billable    bool
	Description string
	ProjectID   string
	TaskID      string
	TagIDs      []string
}

UpdateTimeEntryParam params to update a new time entry

type WorkspaceUsersParam

type WorkspaceUsersParam struct {
	Workspace string
	Email     string

	PaginationParam
}

WorkspaceUsersParam params to query workspace users

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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