Documentation ¶
Index ¶
- Constants
- Variables
- func Date(year int, month time.Month, day int) time.Time
- func GetBaseURL(rawURL string) string
- func InferYear(month time.Month, windowInMonths int, dt time.Time) int
- func SundayOfTheWeek(t time.Time) time.Time
- func WeekNo(t time.Time) int
- type AutoTasker
- type CaptureOptions
- type Credentials
- type RequestEntry
- type TimeEntries
- func (entries TimeEntries) ByDate(date time.Time) TimeEntries
- func (a TimeEntries) ById(id int) TimeEntries
- func (a TimeEntries) DistinctIds() []int
- func (a TimeEntries) DistinctWeekNos() []int
- func (a TimeEntries) GroupByWeekNo() map[int]TimeEntries
- func (t TimeEntries) Len() int
- func (t TimeEntries) Less(i, j int) bool
- func (entries TimeEntries) PrintSummary()
- func (t TimeEntries) SortByDateAndTime()
- func (a TimeEntries) SplitEntries() (TimeEntries, TimeEntries)
- func (t TimeEntries) Swap(i, j int)
- type TimeEntry
Constants ¶
const ( // Base URL for AutoTask. URI_AUTOTASK = "https://www.autotask.net" // Format string for ticket detail URL, expects the base URL and ticketID. URI_TICKET_DETAIL = "%s/Mvc/ServiceDesk/TicketDetail.mvc?ticketID=%d" // Format string for task detail URL, expects the base URL and taskID. URI_TASK_DETAIL = "%s/Mvc/Projects/TaskDetail.mvc?taskID=%d" // Suffix for the landing URL, used for waiting. URI_LANDING_SUFFIX = "/Mvc/Framework/Navigation.mvc/Landing" // Format string for the landing URL, expects the base URL. URI_LANDING = "%s/" + URI_LANDING_SUFFIX )
Constants for specific AutoTask URIs.
Variables ¶
var BaseURL string = URI_AUTOTASK
BaseURL is the default base URL for AutoTask operations.
Functions ¶
func Date ¶
Date is a utility function to create a date with time set to midnight and the local timezone.
func GetBaseURL ¶
GetBaseURL extracts the base URL (scheme and host) from the given raw URL string. If parsing fails, it logs the error and returns an empty string.
func InferYear ¶
InferYear infers the most likely year for a given month, based on a reference date and a window in months.
func SundayOfTheWeek ¶
SundayOfTheWeek returns the date of the Sunday of the week based on a provided date.
Types ¶
type AutoTasker ¶
type AutoTasker interface { // CaptureTimes captures time entries based on the provided options. CaptureTimes(entries TimeEntries, opts CaptureOptions) error }
AutoTasker is an interface for capturing time entries.
type CaptureOptions ¶
type CaptureOptions struct { Credentials Credentials // Authentication details. DryRun bool // If true, does a dry run without actual capture. UserDisplayName string // Display name of the user in AutoTask, this available under the user profile. This value is used to find time entries for the user. BrowserType string // Type of the browser to use, e.g., "chromium", "firefox" and "webkit". Headless bool // If true, browser operates in headless mode. DateFormat string // Format for date representation. DayFormat string // Format for day representation. }
CaptureOptions defines the options for the CaptureTimes method.
type Credentials ¶
Credentials holds the authentication details, currently unused in this snippet.
type RequestEntry ¶
type RequestEntry struct { Id int `json:"id"` IsTicket bool `json:"isTicket"` Date time.Time `json:"date"` StartTime string `json:"startTime"` Duration float32 `json:"duration"` Summary string `json:"summary"` Project string `json:"project"` }
RequestEntry represents a single entry as received in a JSON request.
func UnmarshalToRequestEntries ¶
func UnmarshalToRequestEntries(data []byte) ([]RequestEntry, error)
UnmarshalToRequestEntries converts JSON data into a slice of RequestEntry.
type TimeEntries ¶
type TimeEntries []*TimeEntry
func UnmarshalToTimeEntries ¶
func UnmarshalToTimeEntries(data []byte, dateFormat string) (TimeEntries, error)
UnmarshalToTimeEntries converts JSON data into a TimeEntries.
func (TimeEntries) ByDate ¶
func (entries TimeEntries) ByDate(date time.Time) TimeEntries
ByDate retrieves all entries that match a given date
func (TimeEntries) ById ¶
func (a TimeEntries) ById(id int) TimeEntries
ById retrieves entries based on their Id
func (TimeEntries) DistinctIds ¶
func (a TimeEntries) DistinctIds() []int
DistinctIds returns a list of distinct Ids from the TimeEntries
func (TimeEntries) DistinctWeekNos ¶
func (a TimeEntries) DistinctWeekNos() []int
DistinctWeekNos returns a slice of distinct week numbers
func (TimeEntries) GroupByWeekNo ¶
func (a TimeEntries) GroupByWeekNo() map[int]TimeEntries
GroupByWeekNo groups the TimeEntries based on their week number
func (TimeEntries) Len ¶
func (t TimeEntries) Len() int
func (TimeEntries) Less ¶
func (t TimeEntries) Less(i, j int) bool
func (TimeEntries) PrintSummary ¶
func (entries TimeEntries) PrintSummary()
PrintSummary prints a summary table of the time entries.
func (TimeEntries) SortByDateAndTime ¶ added in v0.0.11
func (t TimeEntries) SortByDateAndTime()
SortByDateAndTime sorts the entries by their Date and StartTimeStr
func (TimeEntries) SplitEntries ¶
func (a TimeEntries) SplitEntries() (TimeEntries, TimeEntries)
SplitEntries splits the TimeEntries into two lists based on their IsTicket flag, the first list contains tickets, the second contains tasks
func (TimeEntries) Swap ¶
func (t TimeEntries) Swap(i, j int)
type TimeEntry ¶
type TimeEntry struct { Id int IsTicket bool // if not a ticket, it's a task Date time.Time DateStr string StartTimeStr string Duration float32 // in hours Summary string Project string // Derived properties Exists bool Submitted bool Error error DurationHours int DurationMinutes float32 DurationHoursStr string DurationMinutesStr string WeekNo int WeekPeerLocator interface{} }