api

package
v0.42.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TaskStatusDefault = ""
	TaskStatusDone    = "DONE"
	TaskStatusActive  = "ACTIVE"
)
View Source
const (
	// EstimateMethodNone dont estimate the project
	EstimateMethodNone = EstimateMethod("none")
	// EstimateMethodTime estimate by time
	EstimateMethodTime = EstimateMethod("time")
	// EstimateMethodBudget estimate by budget
	EstimateMethodBudget = EstimateMethod("budget")
)
View Source
const (
	EstimateTypeProject = EstimateType("project")
	EstimateTypeTask    = EstimateType("task")
)
View Source
const (
	EstimateResetOptionDefault = EstimateType("")
	EstimateResetOptionMonthly = EstimateResetOption("monthly")
)

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)

	// GetProjects get all project of a workspace
	GetProjects(GetProjectsParam) ([]dto.Project, error)
	// GetProject get a single Project, if exists
	GetProject(GetProjectParam) (*dto.Project, error)
	// AddProject creates a new project
	AddProject(AddProjectParam) (dto.Project, error)
	// UpdateProject changes basic information about the project
	UpdateProject(UpdateProjectParam) (dto.Project, error)
	// UpdateProjectUserCostRate will update the hourly rate of a user on a
	// project
	UpdateProjectUserBillableRate(UpdateProjectUserRateParam) (
		dto.Project, error)
	// UpdateProjectUserCostRate will update the cost of a user on a project
	UpdateProjectUserCostRate(UpdateProjectUserRateParam) (
		dto.Project, error)
	// UpdateProjectEstimate change how the estime of a project is measured
	UpdateProjectEstimate(UpdateProjectEstimateParam) (dto.Project, error)
	// UpdateProjectMemberships changes who has access to add time entries to
	// the project
	UpdateProjectMemberships(UpdateProjectMembershipsParam) (dto.Project, error)
	// UpdateProjectTemplate changes if a project is a template or not
	UpdateProjectTemplate(UpdateProjectTemplateParam) (dto.Project, error)
	// DeleteProject removes a project forever
	DeleteProject(DeleteProjectParam) (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 DeleteProjectParam added in v0.42.0

type DeleteProjectParam struct {
	Workspace string
	ProjectID string
}

DeleteProjectParam identifies which project to delete

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 EstimateMethod added in v0.42.0

type EstimateMethod string

EstimateMethod are methods to estimate projects (none, budget and time)

type EstimateResetOption added in v0.42.0

type EstimateResetOption string

EstimateResetOption defines the period in which the estimates reset

type EstimateType added in v0.42.0

type EstimateType string

EstimateType sets if the estimate is for the role project or per task

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
	Hydrate   bool
}

GetProjectParam params to get a Project

type GetProjectsParam

type GetProjectsParam struct {
	Workspace string
	Name      string
	Clients   []string
	Archived  *bool
	Hydrate   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
	TagIDs         []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 InvalidOptionError added in v0.42.0

type InvalidOptionError struct {
	Field   string
	Options []string
}

InvalidOptionError indicates that the parameter has a limited set of valid values, and the one used is not one of them (see Options for the valid ones)

func (*InvalidOptionError) Error added in v0.42.0

func (i *InvalidOptionError) 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
	TagIDs      []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 UpdateMembership added in v0.42.0

type UpdateMembership struct {
	UserOrGroupID    string
	HourlyRateAmount int64
}

UpdateMembership represents the membership of a User or User Group to a project

type UpdateProjectEstimateParam added in v0.42.0

type UpdateProjectEstimateParam struct {
	Workspace   string
	ProjectID   string
	Method      EstimateMethod
	Type        EstimateType
	ResetOption EstimateResetOption
	Estimate    int64
}

UpdateProjectEstimateParam holds parameters to change project estimate

type UpdateProjectMembershipsParam added in v0.42.0

type UpdateProjectMembershipsParam struct {
	Workspace   string
	ProjectID   string
	Memberships []UpdateMembership
}

UpdateProjectMembershipsParam will change which users and groups have access to the project

type UpdateProjectParam added in v0.40.0

type UpdateProjectParam struct {
	Workspace string
	ProjectID 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 UpdateProjectTemplateParam added in v0.42.0

type UpdateProjectTemplateParam struct {
	Workspace string
	ProjectID string
	Template  bool
}

UpdateProjectTemplateParam sets which project will be updated,and if it will became a template or not

type UpdateProjectUserRateParam added in v0.42.0

type UpdateProjectUserRateParam struct {
	Workspace string
	ProjectID string
	UserID    string
	Amount    uint
	Since     *time.Time
}

UpdateProjectUserRateParam sets the parameters to update the billable/cost rate, if Since is not nil, then all time entries after that time will be updated to new rate

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