Documentation
¶
Index ¶
- Constants
- func CalculateTotalReal(start, end time.Time) float64
- func FormatDate(t time.Time) string
- func FormatISO8601(t time.Time) string
- func FormatTaskReference(workspaceAlias string, taskNumber int) string
- func ParseDate(s string) (time.Time, error)
- func ParseISO8601(s string) (time.Time, error)
- func ParseTaskReference(ref string) (workspaceAlias string, taskNumber int, err error)
- type APIClient
- func (c *APIClient) CreateRecords(records []map[string]any) ([]MultiResult, error)
- func (c *APIClient) CreateTimeLog(workspaceAlias, workdayID string, startOn, finishOn time.Time, title string) (*TimeLog, error)
- func (c *APIClient) CreateTimeLogForDate(workspaceAlias string, date time.Time, startOn, finishOn time.Time, ...) (*TimeLog, error)
- func (c *APIClient) DeleteTimeLog(id string) error
- func (c *APIClient) GetOrCreateWorkday(workspaceAlias string, date time.Time) (*Workday, error)
- func (c *APIClient) GetRecord(id string, listOfFields string) (Record, error)
- func (c *APIClient) GetRecordByNumber(workspaceAlias, appAlias string, number int, listOfFields string) (Record, error)
- func (c *APIClient) GetWorkspaceByAlias(alias string) (*Workspace, error)
- func (c *APIClient) ListRecords(opts ListOptions) ([]Record, error)
- func (c *APIClient) ListTimeLogs(workspaceAlias, workdayID string) ([]TimeLog, error)
- func (c *APIClient) ListTimeLogsByDateRange(startDate, endDate time.Time, opts ListOptions) ([]TimeLog, error)
- func (c *APIClient) ListTimeLogsForDate(workspaceAlias string, date time.Time) ([]TimeLog, error)
- func (c *APIClient) ListUsers(opts ListOptions) ([]Record, error)
- func (c *APIClient) ListWorkdays(workspaceAlias string, startDate, endDate time.Time) ([]Workday, error)
- func (c *APIClient) RegisterWorkspace(workspace *Workspace)
- func (c *APIClient) SetAuthToken(token string)
- func (c *APIClient) UpdateRecords(records []map[string]any) ([]MultiResult, error)
- func (c *APIClient) UpdateTimeLog(id string, startOn, finishOn time.Time, title string) error
- type ListOptions
- type MultiResult
- type MultiWarning
- type Record
- type Task
- type TimeLog
- type User
- type Workday
- type Workspace
Constants ¶
const ( AppAliasTask = "TASK" AppAliasTimelog = "TIMELOG" AppAliasWorkday = "WORKDAY" AppAliasUser = "USER" )
App aliases used in scoped URLs (/w/{ws}/a/{app}/...)
const ( AppIDTask = "v2-app-task" AppIDTimelog = "v2-hr-timelog" AppIDWorkday = "v2-hr-workday" AppIDUser = "default-app-guser" )
App IDs used in API responses and record identification
const ( TransitionAdd = "add" TransitionEdit = "edit" TransitionDelete = "delete" )
Transitions for /tickets/multi operations
const ( // ISO8601Layout is the time format used by ComindWork API ISO8601Layout = "2006-01-02T15:04:05.000Z" // DateLayout is the date format used for workday dates DateLayout = "2006-01-02" )
const (
AuthPrefix = "CMW_AUTH_CODE"
)
Auth
Variables ¶
This section is empty.
Functions ¶
func CalculateTotalReal ¶
CalculateTotalReal calculates the duration in hours between start and end times
func FormatDate ¶
FormatDate formats a time.Time to the date format expected by ComindWork API
func FormatISO8601 ¶
FormatISO8601 formats a time.Time to the ISO8601 format expected by ComindWork API
func FormatTaskReference ¶
FormatTaskReference formats a workspace alias and task number into a task reference string
func ParseISO8601 ¶
ParseISO8601 parses a timestamp string from the ComindWork API
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient is the ComindWork (Extranet) API client
func (*APIClient) CreateRecords ¶
func (c *APIClient) CreateRecords(records []map[string]any) ([]MultiResult, error)
CreateRecords creates one or more records via /tickets/multi. Each record should be a flat map with workspace_alias, app_alias, and field values.
func (*APIClient) CreateTimeLog ¶
func (c *APIClient) CreateTimeLog(workspaceAlias, workdayID string, startOn, finishOn time.Time, title string) (*TimeLog, error)
CreateTimeLog creates a new timelog entry
func (*APIClient) CreateTimeLogForDate ¶
func (c *APIClient) CreateTimeLogForDate(workspaceAlias string, date time.Time, startOn, finishOn time.Time, title string) (*TimeLog, error)
CreateTimeLogForDate is a convenience method that creates a timelog for a specific date, automatically finding or creating the workday first
func (*APIClient) DeleteTimeLog ¶
DeleteTimeLog deletes a timelog entry
func (*APIClient) GetOrCreateWorkday ¶
GetOrCreateWorkday finds an existing workday for the given date or creates a new one
func (*APIClient) GetRecordByNumber ¶
func (c *APIClient) GetRecordByNumber(workspaceAlias, appAlias string, number int, listOfFields string) (Record, error)
GetRecordByNumber retrieves a single record by its workspace-scoped number.
func (*APIClient) GetWorkspaceByAlias ¶
GetWorkspaceByAlias returns a workspace by its alias from the cache
func (*APIClient) ListRecords ¶
func (c *APIClient) ListRecords(opts ListOptions) ([]Record, error)
ListRecords retrieves records using the global /tickets/list endpoint.
func (*APIClient) ListTimeLogs ¶
ListTimeLogs retrieves all timelogs for a workday
func (*APIClient) ListTimeLogsByDateRange ¶
func (c *APIClient) ListTimeLogsByDateRange(startDate, endDate time.Time, opts ListOptions) ([]TimeLog, error)
ListTimeLogsByDateRange retrieves timelogs within a date range.
func (*APIClient) ListTimeLogsForDate ¶
ListTimeLogsForDate is a convenience method that lists all timelogs for a specific date
func (*APIClient) ListUsers ¶
func (c *APIClient) ListUsers(opts ListOptions) ([]Record, error)
ListUsers retrieves user records via the /aid/default-app-guser/tickets/list endpoint.
func (*APIClient) ListWorkdays ¶
func (c *APIClient) ListWorkdays(workspaceAlias string, startDate, endDate time.Time) ([]Workday, error)
ListWorkdays retrieves workdays for a workspace within a date range
func (*APIClient) RegisterWorkspace ¶
RegisterWorkspace registers a workspace in the cache for lookup by alias
func (*APIClient) SetAuthToken ¶
SetAuthToken sets the bearer token for API authentication
func (*APIClient) UpdateRecords ¶
func (c *APIClient) UpdateRecords(records []map[string]any) ([]MultiResult, error)
UpdateRecords updates one or more records via /tickets/multi. Each record should have at least "id" and "transition" fields.
type ListOptions ¶
type ListOptions struct {
ListOfFields string // Comma-separated field names, or "ALL"
LimitRecords int // Max number of records to return (0 = server default)
Filter string // rlx filter expression
SortBy string // Sort expression, e.g. "creation_date desc"
}
ListOptions encapsulates query parameters for /tickets/list endpoints.
type MultiResult ¶
type MultiResult struct {
Created bool `json:"created,omitempty"`
Updated bool `json:"updated,omitempty"`
Successful bool `json:"successful"`
Data Record `json:"data,omitempty"`
Warnings []MultiWarning `json:"warnings,omitempty"`
TransactionID string `json:"transactionId,omitempty"`
}
MultiResult represents a single item in the response array from /tickets/multi.
type MultiWarning ¶
MultiWarning represents a warning in a MultiResult.
type Record ¶
Record represents a generic API record returned as a flat JSON object. The official API returns records with snake_case field names.
type Task ¶
type Task struct {
WorkspaceAlias string `json:"workspaceAlias"`
TaskNumber int `json:"taskNumber"`
TaskID string `json:"taskId,omitempty"`
}
Task represents a task reference parsed from "WORKSPACE/TASKnnn" format
type TimeLog ¶
type TimeLog struct {
ID string `json:"id"`
WorkdayID string `json:"workdayId"`
WorkspaceID string `json:"workspaceId"`
Title string `json:"title"`
StartOn time.Time `json:"startOn"`
FinishOn time.Time `json:"finishOn"`
TotalReal float64 `json:"totalReal"` // Duration in hours
Task *Task `json:"task,omitempty"`
UpdateDate time.Time `json:"updateDate,omitempty"`
ProjectAlias string `json:"projectAlias,omitempty"`
Number int `json:"number,omitempty"`
}
TimeLog represents a time entry in ComindWork
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Title string `json:"title,omitempty"`
}
User represents a ComindWork user/account