todoist

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: BSD-2-Clause Imports: 14 Imported by: 1

README

Todoist API in Go Go Reference

This is not original Todoist library for Go.

This library supports most if not all of the developer.todoist.com/rest/v2 REST calls.

Project Status

There is currently no major version released.

Installing

go get
$ go get -u github.com/volyanyk/todoist

Example

Getting all projects for the authenticated user
package main

import (
	"fmt"

	"github.com/volyanyk/todoist"
)

func main() {
	api := todoist.New("TOKEN")
	projects, err := api.GetProjects()
	if err != nil {
		return
	}

	fmt.Printf("%v", projects)

}

Contributing

You are more than welcome to contribute to this project. Fork and make a Pull Request, or create an Issue if you see any problem.

Before making any Pull Request please run the following:

make pr-prep

This will check/update code formatting, linting and then run all tests

License

BSD 2 Clause license

Documentation

Index

Constants

View Source
const (
	APIURL = "https://api.todoist.com/rest/v2/"
)

Variables

This section is empty.

Functions

func OptionAPIURL

func OptionAPIURL(u string) func(*Client)

Types

type AddProjectRequest

type AddProjectRequest struct {
	Name       string `json:"name"`        // Required
	ParentId   string `json:"parent_id"`   // Optional
	Color      string `json:"color"`       // Optional
	IsFavorite bool   `json:"is_favorite"` // Optional
	ViewStyle  string `json:"view_style"`  // Optional
}

type AddTaskRequest

type AddTaskRequest struct {
	Content     string   `json:"content"`
	Description string   `json:"description"`
	ProjectId   string   `json:"project_id"`
	SectionId   *string  `json:"section_id"`
	ParentId    *string  `json:"parent_id"`
	Order       int      `json:"order"`
	Labels      []string `json:"labels"`
	Priority    int      `json:"priority"`
	DueString   string   `json:"due_string"`
	DueDate     string   `json:"due_date"`
	DueDatetime string   `json:"due_datetime"`
	DueLang     string   `json:"due_lang"`
	AssigneeId  *string  `json:"assignee_id"`
}

type Attachment

type Attachment struct {
	ResourceType string `json:"resource_type"`
	FileUrl      string `json:"file_url"`
	FileType     string `json:"file_type"`
	FileName     string `json:"file_name"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(token string, options ...Option) *Client

func (*Client) AddComment

func (api *Client) AddComment(param *NewCommentParameters) (*Comment, error)

func (*Client) AddCommentContext

func (api *Client) AddCommentContext(params *NewCommentParameters, context context.Context) (*Comment, error)

func (*Client) AddLabel

func (api *Client) AddLabel(request LabelRequest) (*Label, error)

func (*Client) AddLabelContext

func (api *Client) AddLabelContext(addLabelRequest LabelRequest, context context.Context) (*Label, error)

func (*Client) AddProject

func (api *Client) AddProject(request AddProjectRequest) (*Project, error)

func (*Client) AddProjectContext

func (api *Client) AddProjectContext(addProjectRequest AddProjectRequest, context context.Context) (*Project, error)

func (*Client) AddSection

func (api *Client) AddSection(param *SectionParameters) (*Section, error)

func (*Client) AddSectionContext

func (api *Client) AddSectionContext(params *SectionParameters, context context.Context) (*Section, error)

func (*Client) AddTask

func (api *Client) AddTask(request AddTaskRequest) (*Task, error)

func (*Client) AddTaskContext

func (api *Client) AddTaskContext(addTaskRequest AddTaskRequest, context context.Context) (*Task, error)

func (*Client) CloseTask

func (api *Client) CloseTask(id string) (*TodoistResponse, error)

func (*Client) CloseTaskContext

func (api *Client) CloseTaskContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) Debug

func (api *Client) Debug() bool

func (*Client) Debugf

func (api *Client) Debugf(format string, v ...interface{})

func (*Client) Debugln

func (api *Client) Debugln(v ...interface{})

func (*Client) DeleteCommentById

func (api *Client) DeleteCommentById(id string) (*TodoistResponse, error)

func (*Client) DeleteCommentByIdContext

func (api *Client) DeleteCommentByIdContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) DeleteLabelById

func (api *Client) DeleteLabelById(id string) (*TodoistResponse, error)

func (*Client) DeleteLabelByIdContext

func (api *Client) DeleteLabelByIdContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) DeleteProjectById

func (api *Client) DeleteProjectById(id string) (*TodoistResponse, error)

func (*Client) DeleteProjectByIdContext

func (api *Client) DeleteProjectByIdContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) DeleteSectionById

func (api *Client) DeleteSectionById(id string) (*TodoistResponse, error)

func (*Client) DeleteSectionByIdContext

func (api *Client) DeleteSectionByIdContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) DeleteTaskById

func (api *Client) DeleteTaskById(id string) (*TodoistResponse, error)

func (*Client) DeleteTaskByIdContext

func (api *Client) DeleteTaskByIdContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) GetActiveTaskById

func (api *Client) GetActiveTaskById(id string) (*Task, error)

func (*Client) GetActiveTaskByIdContext

func (api *Client) GetActiveTaskByIdContext(id string, context context.Context) (*Task, error)

func (*Client) GetActiveTasks

func (api *Client) GetActiveTasks(getActiveTasksRequest GetActiveTasksRequest) (*[]Task, error)

func (*Client) GetActiveTasksContext

func (api *Client) GetActiveTasksContext(request GetActiveTasksRequest, context context.Context) (*[]Task, error)

func (*Client) GetAllCommentsByProjectId

func (api *Client) GetAllCommentsByProjectId(projectId string) (*[]Comment, error)

func (*Client) GetAllCommentsByTaskId

func (api *Client) GetAllCommentsByTaskId(taskId string) (*[]Comment, error)

func (*Client) GetAllCommentsContext

func (api *Client) GetAllCommentsContext(projectId string, taskId string, context context.Context) (*[]Comment, error)

func (*Client) GetCommentById

func (api *Client) GetCommentById(id string) (*Comment, error)

func (*Client) GetCommentByIdContext

func (api *Client) GetCommentByIdContext(id string, context context.Context) (*Comment, error)

func (*Client) GetLabelById

func (api *Client) GetLabelById(id string) (*Label, error)

func (*Client) GetLabelByIdContext

func (api *Client) GetLabelByIdContext(id string, context context.Context) (*Label, error)

func (*Client) GetLabels

func (api *Client) GetLabels() (*[]Label, error)

func (*Client) GetLabelsContext

func (api *Client) GetLabelsContext(context context.Context) (*[]Label, error)

func (*Client) GetProjectById

func (api *Client) GetProjectById(id string) (*Project, error)

func (*Client) GetProjectByIdContext

func (api *Client) GetProjectByIdContext(id string, context context.Context) (*Project, error)

func (*Client) GetProjectCollaborators

func (api *Client) GetProjectCollaborators(id string) (*[]Collaborator, error)

func (*Client) GetProjectCollaboratorsContext

func (api *Client) GetProjectCollaboratorsContext(id string, context context.Context) (*[]Collaborator, error)

func (*Client) GetProjects

func (api *Client) GetProjects() (*[]Project, error)

func (*Client) GetProjectsContext

func (api *Client) GetProjectsContext(context context.Context) (*[]Project, error)

func (*Client) GetSectionById

func (api *Client) GetSectionById(id string) (*Section, error)

func (*Client) GetSectionByIdContext

func (api *Client) GetSectionByIdContext(id string, context context.Context) (*Section, error)

func (*Client) GetSectionCollaboratorsContext

func (api *Client) GetSectionCollaboratorsContext(id string, context context.Context) (*[]Collaborator, error)

func (*Client) GetSectionsByProjectId

func (api *Client) GetSectionsByProjectId(projectId string) (*[]Section, error)

func (*Client) GetSectionsByProjectIdContext

func (api *Client) GetSectionsByProjectIdContext(projectId string, context context.Context) (*[]Section, error)

func (*Client) GetSharedLabels

func (api *Client) GetSharedLabels() (*[]Label, error)

func (*Client) GetSharedLabelsContext

func (api *Client) GetSharedLabelsContext(context context.Context) (*[]Label, error)

func (*Client) RemoveSharedLabel

func (api *Client) RemoveSharedLabel(name string) (*TodoistResponse, error)

func (*Client) RemoveSharedLabelContext

func (api *Client) RemoveSharedLabelContext(name string, context context.Context) (*TodoistResponse, error)

func (*Client) RenameLabel

func (api *Client) RenameLabel(oldName string, newName string) (*TodoistResponse, error)

func (*Client) RenameLabelContext

func (api *Client) RenameLabelContext(oldName string, newName string, context context.Context) (*TodoistResponse, error)

func (*Client) ReopenTask

func (api *Client) ReopenTask(id string) (*TodoistResponse, error)

func (*Client) ReopenTaskContext

func (api *Client) ReopenTaskContext(id string, context context.Context) (*TodoistResponse, error)

func (*Client) UpdateComment

func (api *Client) UpdateComment(id string, content string) (*Comment, error)

func (*Client) UpdateCommentContext

func (api *Client) UpdateCommentContext(id string, content string, context context.Context) (*Comment, error)

func (*Client) UpdateLabel

func (api *Client) UpdateLabel(id string, request LabelRequest) (*Label, error)

func (*Client) UpdateLabelContext

func (api *Client) UpdateLabelContext(id string, updateLabelRequest LabelRequest, context context.Context) (*Label, error)

func (*Client) UpdateProject

func (api *Client) UpdateProject(id string, updateProjectRequest UpdateProjectRequest) (*Project, error)

func (*Client) UpdateProjectContext

func (api *Client) UpdateProjectContext(id string, updateProjectRequest UpdateProjectRequest, context context.Context) (*Project, error)

func (*Client) UpdateSection

func (api *Client) UpdateSection(projectId string, name string) (*Section, error)

func (*Client) UpdateSectionContext

func (api *Client) UpdateSectionContext(sectionId string, name string, context context.Context) (*Section, error)

func (*Client) UpdateTask

func (api *Client) UpdateTask(id string, updateTaskRequest UpdateTaskRequest) (*Task, error)

func (*Client) UpdateTaskContext

func (api *Client) UpdateTaskContext(id string, updateTaskRequest UpdateTaskRequest, context context.Context) (*Task, error)

type Collaborator

type Collaborator struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

type CollaboratorsResponse

type CollaboratorsResponse struct {
	Collaborators []Collaborator
	TodoistResponse
}

type Comment

type Comment struct {
	Content    string      `json:"content"`
	Id         string      `json:"id"`
	PostedAt   string      `json:"posted_at"`
	ProjectId  string      `json:"project_id"`
	TaskId     string      `json:"task_id"`
	Attachment *Attachment `json:"attachment"`
}

type CommentResponse

type CommentResponse struct {
	Comment Comment
	TodoistResponse
}

type CommentsResponse

type CommentsResponse struct {
	Comments []Comment
	TodoistResponse
}

type Debug

type Debug interface {
	Debug() bool

	Debugf(format string, v ...interface{})
	Debugln(v ...interface{})
}

type Due

type Due struct {
	Date        string `json:"date"`
	IsRecurring bool   `json:"is_recurring"`
	Datetime    string `json:"datetime"`
	String      string `json:"string"`
	Timezone    string `json:"timezone"`
}

type ErrorResponse

type ErrorResponse struct {
	Err string
}

func (ErrorResponse) Error

func (t ErrorResponse) Error() string

type GetActiveTasksRequest

type GetActiveTasksRequest struct {
	ProjectId string   `json:"project_id"` // Optional
	SectionId string   `json:"section_id"` // Optional
	Label     string   `json:"label"`      // Optional
	Filter    string   `json:"filter"`     // Optional
	Lang      string   `json:"lang"`       // Optional
	Ids       []string `json:"ids"`        // Optional
}

type Label

type Label struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Color      string `json:"color"`
	Order      int    `json:"order"`
	IsFavorite bool   `json:"is_favorite"`
}

type LabelRequest

type LabelRequest struct {
	Name       string `json:"name"`        // Required / Optional
	Color      string `json:"color"`       // Optional
	Order      int    `json:"order"`       // Optional
	IsFavorite bool   `json:"is_favorite"` // Optional
}

type LabelResponse

type LabelResponse struct {
	Label Label
	TodoistResponse
}

type LabelsResponse

type LabelsResponse struct {
	Labels []Label
	TodoistResponse
}

type NewCommentParameters

type NewCommentParameters struct {
	TaskId     string     `json:"task_id"`
	Content    string     `json:"content"`
	Attachment Attachment `json:"attachment"`
}

type Option

type Option func(*Client)

type Project

type Project struct {
	ID             string `json:"id"`
	ParentId       string `json:"parent_id"`
	Order          int    `json:"order"`
	Color          string `json:"color"`
	Name           string `json:"name"`
	CommentCount   int    `json:"comment_count"`
	IsShared       bool   `json:"is_shared"`
	IsFavorite     bool   `json:"is_favorite"`
	IsInboxProject bool   `json:"is_inbox_project"`
	IsTeamInbox    bool   `json:"is_team_inbox"`
	Url            string `json:"url"`
	ViewStyle      string `json:"view_style"`
}

type ProjectResponse

type ProjectResponse struct {
	Project Project
	TodoistResponse
}

type ProjectsResponse

type ProjectsResponse struct {
	Projects []Project
	TodoistResponse
}

type RateLimitedError

type RateLimitedError struct {
	RetryAfter time.Duration
}

func (*RateLimitedError) Error

func (e *RateLimitedError) Error() string

func (*RateLimitedError) Retryable

func (e *RateLimitedError) Retryable() bool

type Section

type Section struct {
	ID        string `json:"id"`
	ProjectId string `json:"project_id"`
	Order     int    `json:"order"`
	Name      string `json:"name"`
}

type SectionParameters

type SectionParameters struct {
	ProjectId string `json:"project_id"`
	Name      string `json:"name"`
	Order     int    `json:"order"`
}

type SectionResponse

type SectionResponse struct {
	Section Section
	TodoistResponse
}

type SectionsResponse

type SectionsResponse struct {
	Sections []Section
	TodoistResponse
}

type StatusCodeError

type StatusCodeError struct {
	Code   int
	Status string
}

func (StatusCodeError) Error

func (t StatusCodeError) Error() string

func (StatusCodeError) HTTPStatusCode

func (t StatusCodeError) HTTPStatusCode() int

func (StatusCodeError) Retryable

func (t StatusCodeError) Retryable() bool

type Task

type Task struct {
	Id           string `json:"id"`
	AssignerId   any    `json:"assigner_id"`
	AssigneeId   any    `json:"assignee_id"`
	ProjectId    string `json:"project_id"`
	SectionId    string `json:"section_id"`
	ParentId     any    `json:"parent_id"`
	Order        int    `json:"order"`
	Content      string `json:"content"`
	Description  string `json:"description"`
	IsCompleted  bool   `json:"is_completed"`
	Labels       []any  `json:"labels"`
	Priority     int    `json:"priority"`
	CommentCount int    `json:"comment_count"`
	CreatorId    string `json:"creator_id"`
	CreatedAt    string `json:"created_at"`
	Due          *Due   `json:"due"`
	Url          string `json:"url"`
}

type Task1 added in v1.0.2

type Task1 struct {
	CreatorId    string   `json:"creator_id"`
	CreatedAt    string   `json:"created_at"`
	AssigneeId   *string  `json:"assignee_id"`
	AssignerId   *string  `json:"assigner_id"`
	CommentCount int      `json:"comment_count"`
	IsCompleted  bool     `json:"is_completed"`
	Content      string   `json:"content"`
	Description  string   `json:"description"`
	Due          *Due     `json:"due"`
	Id           string   `json:"id"`
	Labels       []string `json:"labels"`
	Order        int      `json:"order"`
	Priority     int      `json:"priority"`
	ProjectId    string   `json:"project_id"`
	SectionId    string   `json:"section_id"`
	ParentId     string   `json:"parent_id"`
	Url          string   `json:"url"`
}

type TaskResponse

type TaskResponse struct {
	Task Task
	TodoistResponse
}

type TasksResponse

type TasksResponse struct {
	Tasks []Task
	TodoistResponse
}

type TodoistResponse

type TodoistResponse struct {
	Ok    bool   `json:"ok"`
	Error string `json:"error"`
}

func (TodoistResponse) Err

func (t TodoistResponse) Err() error

type UpdateProjectRequest

type UpdateProjectRequest struct {
	Name       string `json:"name"`        // Required
	Color      string `json:"color"`       // Optional
	IsFavorite bool   `json:"is_favorite"` // Optional
	ViewStyle  string `json:"view_style"`  // Optional
}

type UpdateTaskRequest

type UpdateTaskRequest struct {
	Content     string   `json:"content"`      // Optional
	Description string   `json:"description"`  // Optional
	Labels      []string `json:"labels"`       // Optional
	Priority    int      `json:"priority"`     // Optional
	DueString   string   `json:"due_string"`   // Optional
	DueDate     string   `json:"due_date"`     // Optional
	DueDatetime string   `json:"due_datetime"` // Optional
	DueLang     string   `json:"due_lang"`     // Optional
	AssigneeId  string   `json:"assignee_id"`  // Optional
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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