Documentation ¶
Index ¶
- Variables
- func ChildProjectIDs(projects []Project) map[string][]string
- func GroupTasksByProjectID(tasks []Task) map[string][]Task
- func PrettyPrintJson(src []byte)
- func ProjectByID(projects []Project) map[string]Project
- func VarToJsonString(v interface{}) string
- func WriteContentToFile(content []byte, fileName string) (err error)
- type APIErrorResponse
- type Comment
- type PersonalLabel
- type Project
- type Task
- type TaskDue
- type TaskParameters
- type TodoistClient
- func (c *TodoistClient) Get(urlString string, query url.Values) (body []byte, err error)
- func (c *TodoistClient) GetActiveTask(id int) (response Task, err error)
- func (c *TodoistClient) GetActiveTasks(p *TaskParameters) (response []Task, err error)
- func (c *TodoistClient) GetAllPersonalLabels() (response []PersonalLabel, err error)
- func (c *TodoistClient) GetAllProjects() ([]Project, error)
- func (c *TodoistClient) GetAllSharedLabels() (response []string, err error)
- func (c *TodoistClient) GetPersonalLabel(id string) (response PersonalLabel, err error)
- func (c *TodoistClient) GetProject(project_id string) (Project, error)
- func (c *TodoistClient) GetTaskComments(id int64) (response []Comment, err error)
- func (c *TodoistClient) Put(urlString string, query url.Values, data io.Reader) (body []byte, err error)
Constants ¶
This section is empty.
Variables ¶
var ColorToHex = map[string]string{
"berry_red": "#b8256f",
"red": "#db4035",
"orange": "#ff9933",
"yellow": "#fad000",
"olive_green": "#afb83b",
"lime_green": "#7ecc49",
"green": "#299438",
"mint_green": "#6accbc",
"teal": "#158fad",
"sky_blue": "#14aaf5",
"light_blue": "#96c3eb",
"blue": "#4073ff",
"grape": "#884dff",
"violet": "#af38eb",
"lavendar": "#eb96eb",
"magenta": "#e05194",
"salmon": "#ff8d85",
"charcoal": "#808080",
"grey": "#b8b8b8",
"taupe": "#ccac93",
}
ColorToHex maps color ids for a project, label, or filter, to a hex value.
var PriorityToHexColor = [...]string{
1: "#000000",
2: "#246fe0",
3: "#eb8909",
4: "#d1453b",
}
PriorityToHexColor maps task priority (1=p4, ..., 4=p1) to a hex value.
Functions ¶
func ChildProjectIDs ¶
ChildProjectIDs returns a map of child IDs for each parent ID. An empty parent ID contains all the top level projects.
func GroupTasksByProjectID ¶
GroupTasksByProjectID groups Tasks by their Project ID.
func PrettyPrintJson ¶
func PrettyPrintJson(src []byte)
func ProjectByID ¶
ProjectByID returns a map to allow lookup of projects by ID.
func VarToJsonString ¶
func VarToJsonString(v interface{}) string
VarToJsonString converts any varaible (interface{}) to an indented JSON string.
Only public (capitalized) fields will be visible.
func WriteContentToFile ¶
WriteContent writes the []byte content to a file
Types ¶
type APIErrorResponse ¶
type APIErrorResponse struct {
Err string
}
APIErrorResponse contains a single property named error.
func (*APIErrorResponse) Error ¶
func (e *APIErrorResponse) Error() string
Error return a string representation of the error
type Comment ¶
type Comment struct { // Comment id. ID int64 `json:"id"` // Comment�s task id (for task comments). TaskID int64 `json:"task_id,omitempty"` // Comment�s project id (for project comments). ProjectID int64 `json:"project_id,omitempty"` // Date and time when comment was added, RFC3339 format in UTC. Posted time.Time `json:"posted"` // Comment content. Content string `json:"content"` // Attachment file (optional). Attachment struct { // The name of the file. FileName string `json:"file_name,omitempty"` // MIME type (i.e. text/plain, image/png). FileType string `json:"file_type,omitempty"` // The URL where the file is located (a string value // representing an HTTP URL). Note that we don�t cache // the remote content on our servers and stream or expose // files directly from third party resources. In particular // this means that you should avoid providing links to // non-encrypted (plain HTTP) resources, as exposing this // files in Todoist may issue a browser warning. FileURL string `json:"file_url,omitempty"` FileSize int64 `json:"file_size,omitempty"` UploadState string `json:"upload_state,omitempty"` ResourceType string `json:"resource_type"` SiteName string `json:"site_name,omitempty"` Description string `json:"description,omitempty"` Title string `json:"title,omitempty"` URL string `json:"url,omitempty"` FavIcon string `json:"favicon,omitempty"` } `json:"attachment"` }
type PersonalLabel ¶
type PersonalLabel struct { ID string `json:"id"` Name string `json:"name"` Color string `json:"color"` Order int `json:"order"` IsFavorite bool `json:"is_favorite"` }
A PersonalLabel represents a Todoist personal label. See https://developer.todoist.com/rest/v2/?shell#labels for more details.
type Project ¶
type Project struct { ID string `json:"id"` Name string `json:"name"` Color string `json:"color"` ParentID *string `json:"parent_id"` Order int `json:"order"` CommentCount int `json:"comment_count"` IsFavorite bool `json:"is_favorite"` IsInboxProject bool `json:"is_inbox_project"` IsTeamInbox bool `json:"is_team_inbox"` ViewStyle string `json:"view_style"` URL string `json:"url"` }
A Project represents a Todoist Project. See https://developer.todoist.com/rest/v2/?shell#projects for more details.
type Task ¶
type Task struct { ID string `json:"id"` ProjectID string `json:"project_id"` SectionID string `json:"section_id,omitempty"` Content string `json:"content"` Description string `json:"description,omitempty"` IsCompleted bool `json:"is_completed"` Labels []string `json:"labels,omitempty"` ParentID string `json:"parent,omitempty"` Order int `json:"order"` Priority int `json:"priority"` Due *TaskDue `json:"due,omitempty"` URL string `json:"url,omitempty"` CommentCount int `json:"comment_count,omitempty"` CreatedAt time.Time `json:"created_at"` CreatorID string `json:"creator_id"` AssigneeID string `json:"assignee_id,omitempty"` AssignerID string `json:"assigner_id,omitempty"` Duration int `json:"duration"` DurationUnit string `json:"duration_unit"` }
type TaskDue ¶
type TaskParameters ¶
type TaskParameters struct { ProjectID string SectionID string Label string Filter string Lang string IDs []int64 }
See https://developer.todoist.com/rest/v2/?shell#get-active-tasks
type TodoistClient ¶
type TodoistClient struct {
// contains filtered or unexported fields
}
TodoistClient is a client connection to the Todoist REST API. See https://developer.todoist.com/rest/v2/#overview
func New ¶
func New(tokenFileName string, id string, secret string, scopes []string) *TodoistClient
New creates an initialized TodoistClient using the token from tokenFileName.
If tokenFileName doesn't exist, then a token is requested and saved in the file.
The current approach assumes the client runs on a host without a browser. The user is instructed to vist a URL to login and authorize the client. Once the login is successful, the user must copy the response URL and provide to the client program.
The token is requested for offline access, which should include a refresh token to allow access for a long period of time.
clientID and clientSecret must be an application registered with the Todoist App Console
func (*TodoistClient) Get ¶
Get executes the Todoist REST API call, returning the response body. Query parmeters can be included to specify and control the amount of data returned in a response. See https://developer.todoist.com/rest/v2/#overview
func (*TodoistClient) GetActiveTask ¶
func (c *TodoistClient) GetActiveTask(id int) (response Task, err error)
GetActiveTask returns an active (non-completed) task by id.
func (*TodoistClient) GetActiveTasks ¶
func (c *TodoistClient) GetActiveTasks(p *TaskParameters) (response []Task, err error)
GetActiveTasks returns an array containing all active tasks.
func (*TodoistClient) GetAllPersonalLabels ¶
func (c *TodoistClient) GetAllPersonalLabels() (response []PersonalLabel, err error)
GetAllLabels returns a JSON-encoded array containing all user labels.
func (*TodoistClient) GetAllProjects ¶
func (c *TodoistClient) GetAllProjects() ([]Project, error)
GetProjects returns all user projects.
func (*TodoistClient) GetAllSharedLabels ¶
func (c *TodoistClient) GetAllSharedLabels() (response []string, err error)
GetAllSharedLabels returns a JSON-encoded array containing all shared labels.
func (*TodoistClient) GetPersonalLabel ¶
func (c *TodoistClient) GetPersonalLabel(id string) (response PersonalLabel, err error)
GetPersonalLabel returns a label by ID.
func (*TodoistClient) GetProject ¶
func (c *TodoistClient) GetProject(project_id string) (Project, error)
GetProject returns the project for the given project_id.
func (*TodoistClient) GetTaskComments ¶
func (c *TodoistClient) GetTaskComments(id int64) (response []Comment, err error)
func (*TodoistClient) Put ¶
func (c *TodoistClient) Put(urlString string, query url.Values, data io.Reader) (body []byte, err error)
Put executes the Todist REST API call, returning the response body.
Query parmeters can be included to specify and control the amount of data returned in a response.
Exact query parameters varies from one API operation to another.
More information can be found at https://docs.microsoft.com/en-us/graph/query-parameters