todoist

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

View Source
const (
	RFC3339Date                 = "2006-01-02"
	RFC3339DateTime             = "2006-01-02T15:04:05"
	RFC3339DateTimeWithTimeZone = "2006-01-02T15:04:05Z07:00"
)
View Source
const CurrentSchemaVersion = 1

Variables

View Source
var (
	FindFailed = errors.New("Find Failed")
)
View Source
var (
	Server = "https://api.todoist.com/api/v1/"
)

Functions

func GetContentTitle

func GetContentTitle(item ContentCarrier) string

func GetContentURL

func GetContentURL(item ContentCarrier) []string

func HasURL

func HasURL(item ContentCarrier) bool

func ParseAPIError

func ParseAPIError(prefix string, resp *http.Response) error

Types

type AbstractItem added in v0.10.1

type AbstractItem interface {
	DateTime() time.Time
	GetProjectID() string
	GetLabelNames() []string
}

interface for Eval actions

type BaseItem

type BaseItem struct {
	HaveID
	HaveProjectID
	Content string `json:"content"`
	UserID  string `json:"user_id"`
}

func (BaseItem) GetContent

func (bitem BaseItem) GetContent() string

type Client

type Client struct {
	http.Client

	Store *Store
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *Config) *Client

func (*Client) AddItem

func (c *Client) AddItem(ctx context.Context, item Item) error

func (*Client) AddProject added in v0.16.0

func (c *Client) AddProject(ctx context.Context, project Project) error

func (*Client) AddSection added in v0.24.0

func (c *Client) AddSection(ctx context.Context, section Section) error

func (*Client) ArchiveSection added in v0.24.0

func (c *Client) ArchiveSection(ctx context.Context, id string) error

func (*Client) CloseItem

func (c *Client) CloseItem(ctx context.Context, ids []string) error

func (*Client) CompleteItemIDByPrefix added in v0.11.0

func (c *Client) CompleteItemIDByPrefix(prefix string) (id string, err error)

func (*Client) CompletedAll

func (c *Client) CompletedAll(ctx context.Context, r *Completed) error

func (*Client) DeleteItem

func (c *Client) DeleteItem(ctx context.Context, ids []string) error

func (*Client) DeleteSection added in v0.24.0

func (c *Client) DeleteSection(ctx context.Context, id string) error

func (*Client) ExecCommands

func (c *Client) ExecCommands(ctx context.Context, commands Commands) error

func (*Client) FilterItems added in v0.25.0

func (c *Client) FilterItems(ctx context.Context, query string, limit int) ([]Item, error)

FilterItems calls GET /api/v1/tasks/filter with the given query string, auto-paginating until exhausted (or until limit results are collected when limit > 0). limit <= 0 means "no limit, fetch all pages".

func (*Client) Log

func (c *Client) Log(format string, v ...interface{})

func (*Client) MoveItem

func (c *Client) MoveItem(ctx context.Context, item *Item, projectId string) error

func (*Client) MoveItemToSection added in v0.24.0

func (c *Client) MoveItemToSection(ctx context.Context, item *Item, sectionId string) error

func (*Client) MoveSection added in v0.24.0

func (c *Client) MoveSection(ctx context.Context, sectionID string, projectID string) error

func (*Client) QuickCommand added in v0.10.1

func (c *Client) QuickCommand(ctx context.Context, text string) error

func (*Client) ReopenItem added in v0.25.0

func (c *Client) ReopenItem(ctx context.Context, id string) error

func (*Client) ReorderSections added in v0.24.0

func (c *Client) ReorderSections(ctx context.Context, ids []string) error

func (*Client) Sync

func (c *Client) Sync(ctx context.Context) error

func (*Client) UnarchiveSection added in v0.24.0

func (c *Client) UnarchiveSection(ctx context.Context, id string) error

func (*Client) UpdateItem

func (c *Client) UpdateItem(ctx context.Context, item Item) error

func (*Client) UpdateSection added in v0.24.0

func (c *Client) UpdateSection(ctx context.Context, id string, name string) error

type Command

type Command struct {
	Args   interface{} `json:"args"`
	TempID string      `json:"temp_id"`
	Type   string      `json:"type"`
	UUID   string      `json:"uuid"`
}

func NewCommand

func NewCommand(command_type string, command_args interface{}) Command

type Commands

type Commands []Command

func (Commands) UrlValues

func (commands Commands) UrlValues() url.Values

type Completed

type Completed struct {
	Items    CompletedItems `json:"items"`
	Projects interface{}    `json:"projects"`
}

type CompletedItem

type CompletedItem struct {
	BaseItem
	CompletedData string      `json:"completed_at"`
	MetaData      interface{} `json:"meta_data"`
	TaskID        string      `json:"task_id"`
}

func (CompletedItem) DateTime added in v0.10.1

func (item CompletedItem) DateTime() time.Time

func (CompletedItem) GetLabelNames added in v0.17.0

func (item CompletedItem) GetLabelNames() []string

func (CompletedItem) GetProjectID added in v0.11.0

func (item CompletedItem) GetProjectID() string

type CompletedItems

type CompletedItems []CompletedItem

type Config

type Config struct {
	AccessToken    string
	DebugMode      bool
	Color          bool
	DateFormat     string
	DateTimeFormat string
}

type ContentCarrier

type ContentCarrier interface {
	GetContent() string
}

type Deadline added in v0.25.0

type Deadline struct {
	Date string `json:"date"`
	Lang string `json:"lang,omitempty"`
}

type Due added in v0.14.0

type Due struct {
	Date        string `json:"date"`
	TimeZone    string `json:"timezone"`
	IsRecurring bool   `json:"is_recurring"`
	String      string `json:"string"`
	Lang        string `json:"lang"`
}

type ExecResult

type ExecResult struct {
	SyncToken     string                 `json:"sync_token"`
	SyncStatus    map[string]interface{} `json:"sync_status"`
	TempIdMapping interface{}            `json:"temp_id_mapping"`
}

type HaveID

type HaveID struct {
	ID string `json:"id"`
}

func (HaveID) GetID

func (carrier HaveID) GetID() string

type HaveIDs

type HaveIDs []HaveID

type HaveIndent

type HaveIndent struct {
	Indent int `json:"indent"`
}

func (HaveIndent) GetIndent

func (carrier HaveIndent) GetIndent() int

type HaveParentID

type HaveParentID struct {
	ParentID *string `json:"parent_id"`
}

func (HaveParentID) GetParentID

func (carrier HaveParentID) GetParentID() (string, error)

type HaveProjectID

type HaveProjectID struct {
	ProjectID string `json:"project_id"`
}

func (HaveProjectID) GetProjectID

func (carrier HaveProjectID) GetProjectID() string

type HaveSectionID added in v0.16.0

type HaveSectionID struct {
	SectionID string `json:"section_id"`
}

type IDCarrier

type IDCarrier interface {
	GetID() string
}

type Item

type Item struct {
	BaseItem
	HaveParentID
	HaveIndent
	HaveSectionID
	ChildItem      *Item       `json:"-"`
	BrotherItem    *Item       `json:"-"`
	Description    string      `json:"description"`
	AllDay         bool        `json:"all_day"`
	AssignedByUID  string      `json:"assigned_by_uid"`
	Checked        bool        `json:"checked"`
	Collapsed      bool        `json:"collapsed"`
	DateAdded      string      `json:"added_at"`
	DateLang       string      `json:"date_lang"`
	DateString     string      `json:"date_string"`
	DayOrder       int         `json:"day_order"`
	Due            *Due        `json:"due"`
	Deadline       *Deadline   `json:"deadline"`
	HasMoreNotes   bool        `json:"has_more_notes"`
	IsArchived     int         `json:"is_archived"`
	IsDeleted      bool        `json:"is_deleted"`
	ItemOrder      int         `json:"item_order"`
	LabelNames     []string    `json:"labels"`
	Priority       int         `json:"priority"`
	AutoReminder   bool        `json:"auto_reminder"`
	ResponsibleUID interface{} `json:"responsible_uid"`
	SyncID         interface{} `json:"sync_id"`
}

func SearchItemParents added in v0.14.0

func SearchItemParents(store *Store, item *Item) []*Item

func (Item) AddParam

func (item Item) AddParam() interface{}

func (Item) DateTime added in v0.10.1

func (item Item) DateTime() time.Time

func (Item) GetLabelNames added in v0.17.0

func (item Item) GetLabelNames() []string

func (Item) GetProjectID added in v0.11.0

func (item Item) GetProjectID() string

func (Item) LabelsString

func (item Item) LabelsString() string

func (*Item) MoveParam

func (item *Item) MoveParam(projectId string) interface{}

func (*Item) MoveToSectionParam added in v0.24.0

func (item *Item) MoveToSectionParam(sectionId string) interface{}

func (Item) UpdateParam

func (item Item) UpdateParam() interface{}

type ItemFilterResponse added in v0.25.0

type ItemFilterResponse struct {
	Results    []Item  `json:"results"`
	NextCursor *string `json:"next_cursor"`
}

type ItemOrder

type ItemOrder struct {
	Order
	ProjectOrder int `json:"project_order"`
}

type ItemOrders

type ItemOrders []ItemOrder

func (ItemOrders) Len

func (a ItemOrders) Len() int

func (ItemOrders) Less

func (a ItemOrders) Less(i, j int) bool

func (ItemOrders) Swap

func (a ItemOrders) Swap(i, j int)

type Items

type Items []Item

func (Items) At

func (a Items) At(i int) IDCarrier

func (Items) Len

func (a Items) Len() int

func (Items) Less

func (a Items) Less(i, j int) bool

func (Items) Swap

func (a Items) Swap(i, j int)

type Label

type Label struct {
	HaveID
	Color     string `json:"color"`
	IsDeleted bool   `json:"is_deleted"`
	ItemOrder int    `json:"item_order"`
	Name      string `json:"name"`
}

type Labels

type Labels []Label

func (Labels) At

func (a Labels) At(i int) IDCarrier

func (Labels) GetIDByName added in v0.12.0

func (a Labels) GetIDByName(name string) string

func (Labels) Len

func (a Labels) Len() int

func (Labels) Less

func (a Labels) Less(i, j int) bool

func (Labels) Swap

func (a Labels) Swap(i, j int)

type Order

type Order struct {
	Num  int         `json:"num"`
	ID   int         `json:"id"`
	Data interface{} `json:"-"`
}

type Orders

type Orders []Order

func (Orders) Len

func (a Orders) Len() int

func (Orders) Less

func (a Orders) Less(i, j int) bool

func (Orders) Swap

func (a Orders) Swap(i, j int)

type ParentIDCarrier

type ParentIDCarrier interface {
	GetParentID() (string, error)
}

type Project

type Project struct {
	HaveID
	HaveParentID
	HaveIndent
	Collapsed      bool     `json:"collapsed"`
	Color          string   `json:"color"`
	HasMoreNotes   bool     `json:"has_more_notes"`
	InboxProject   bool     `json:"inbox_project"`
	IsArchived     bool     `json:"is_archived"`
	IsDeleted      bool     `json:"is_deleted"`
	ItemOrder      int      `json:"item_order"`
	Name           string   `json:"name"`
	Shared         bool     `json:"shared"`
	ChildProject   *Project `json:"-"`
	BrotherProject *Project `json:"-"`
	ViewStyle      string   `json:"view_style"`
}

func SearchProjectParents added in v0.14.0

func SearchProjectParents(store *Store, project *Project) []*Project

func (Project) AddParam added in v0.16.0

func (project Project) AddParam() interface{}

type ProjectIDCarrier

type ProjectIDCarrier interface {
	GetProjectID() string
}

type Projects

type Projects []Project

func (Projects) At

func (a Projects) At(i int) IDCarrier

func (Projects) GetIDByName added in v0.11.0

func (a Projects) GetIDByName(name string) string

func (Projects) GetIDsByName added in v0.11.0

func (a Projects) GetIDsByName(name string, isAll bool) []string

func (Projects) Len

func (a Projects) Len() int

func (Projects) Less

func (a Projects) Less(i, j int) bool

func (Projects) Swap

func (a Projects) Swap(i, j int)

type Repository

type Repository interface {
	Len() int
	At(int) IDCarrier
}

type Section added in v0.16.0

type Section struct {
	HaveID
	HaveProjectID
	Collapsed    bool   `json:"collapsed"`
	Name         string `json:"name"`
	IsArchived   bool   `json:"is_archived"`
	IsDeleted    bool   `json:"is_deleted"`
	SectionOrder int    `json:"section_order"`
}

func (Section) AddParam added in v0.24.0

func (section Section) AddParam() interface{}

type Sections added in v0.16.0

type Sections []Section

func (Sections) Active added in v0.24.0

func (a Sections) Active() Sections

func (Sections) GetIDByName added in v0.24.0

func (a Sections) GetIDByName(name, projectID string) string

type Store

type Store struct {
	CollaboratorStates []interface{} `json:"collaborator_states"`
	Collaborators      []interface{} `json:"collaborators"`
	DayOrders          interface{}   `json:"day_orders"`
	DayOrdersTimestamp string        `json:"day_orders_timestamp"`
	Filters            []struct {
		ID         string `json:"id"`          // The ID of the filter.
		Name       string `json:"name"`        // The name of the filter.
		Query      string `json:"query"`       // The query to search for. Examples of searches can be found in the Todoist help page.
		Color      string `json:"color"`       // The color of the filter icon. Refer to the name column in the Colors guide for more info.
		ItemOrder  int    `json:"item_order"`  // Filter's order in the filter list (where the smallest value should place the filter at the top).
		IsDeleted  bool   `json:"is_deleted"`  // Whether the filter is marked as deleted (a true or false value).
		IsFavorite bool   `json:"is_favorite"` // Whether the filter is a favorite (a true or false value).
		IsFrozen   bool   `json:"is_frozen"`   // Filters from a canceled subscription cannot be changed. This is a read-only attribute (a true or false value).
	} `json:"filters"`
	FullSync          bool   `json:"full_sync"`
	Items             Items  `json:"items"`
	Labels            Labels `json:"labels"`
	LiveNotifications []struct {
		CompletedTasks   int     `json:"completed_tasks"`
		Created          string  `json:"created_at"`
		DateReached      string  `json:"date_reached"`
		ID               string  `json:"id"`
		IsDeleted        bool    `json:"is_deleted"`
		KarmaLevel       int     `json:"karma_level"`
		NotificationKey  string  `json:"notification_key"`
		NotificationType string  `json:"notification_type"`
		PromoImg         string  `json:"promo_img"`
		SeqNo            int64   `json:"seq_no"`
		TopProcent       float32 `json:"top_procent"`
	} `json:"live_notifications"`
	LiveNotificationsLastReadID string        `json:"live_notifications_last_read_id"`
	Locations                   []interface{} `json:"locations"`
	Notes                       []struct {
		Content        string      `json:"content"`
		FileAttachment interface{} `json:"file_attachment"`
		ID             string      `json:"id"`
		IsArchived     int         `json:"is_archived"`
		IsDeleted      bool        `json:"is_deleted"`
		ItemID         string      `json:"item_id"`
		Posted         string      `json:"posted_at"`
		PostedUID      string      `json:"posted_uid"`
		ProjectID      *string     `json:"project_id"`
		UidsToNotify   interface{} `json:"uids_to_notify"`
	} `json:"notes"`
	ProjectNotes []interface{} `json:"project_notes"`
	Projects     Projects      `json:"projects"`
	Sections     Sections      `json:"sections"`
	Reminders    []struct {
		DateLang     string      `json:"date_lang"`
		Due          *Due        `json:"due"`
		ID           string      `json:"id"`
		IsDeleted    bool        `json:"is_deleted"`
		ItemID       string      `json:"item_id"`
		MinuteOffset int         `json:"minute_offset"`
		NotifyUID    string      `json:"notify_uid"`
		Service      interface{} `json:"service"`
		Type         string      `json:"type"`
	} `json:"reminders"`
	SyncToken     string              `json:"sync_token"`
	SchemaVersion int                 `json:"schema_version"`
	TempIDMapping struct{}            `json:"temp_id_mapping"`
	User          User                `json:"user"`
	RootItem      *Item               `json:"-"`
	RootProject   *Project            `json:"-"`
	ItemMap       map[string]*Item    `json:"-"`
	ProjectMap    map[string]*Project `json:"-"`
	LabelMap      map[string]*Label   `json:"-"`
	SectionMap    map[string]*Section `json:"-"`
}

func (*Store) ConstructItemTree added in v0.14.0

func (s *Store) ConstructItemTree()

func (*Store) FindItem added in v0.14.0

func (s *Store) FindItem(id string) *Item

func (*Store) FindLabel added in v0.14.0

func (s *Store) FindLabel(id string) *Label

func (*Store) FindProject added in v0.14.0

func (s *Store) FindProject(id string) *Project

func (*Store) FindSection added in v0.16.0

func (s *Store) FindSection(id string) *Section

type User

type User struct {
	AutoReminder      int         `json:"auto_reminder"`
	AvatarBig         string      `json:"avatar_big"`
	AvatarMedium      string      `json:"avatar_medium"`
	AvatarS640        string      `json:"avatar_s640"`
	AvatarSmall       string      `json:"avatar_small"`
	BusinessAccountID interface{} `json:"business_account_id"`
	CompletedCount    int         `json:"completed_count"`
	CompletedToday    int         `json:"completed_today"`
	DailyGoal         int         `json:"daily_goal"`
	DateFormat        int         `json:"date_format"`
	Email             string      `json:"email"`
	Features          struct {
		Beta             int  `json:"beta"`
		GoldTheme        bool `json:"gold_theme"`
		HasPushReminders bool `json:"has_push_reminders"`
		Restriction      int  `json:"restriction"`
	} `json:"features"`
	FullName       string  `json:"full_name"`
	ID             string  `json:"id"`
	ImageID        string  `json:"image_id"`
	InboxProjectID string  `json:"inbox_project_id"`
	IsBizAdmin     bool    `json:"is_biz_admin"`
	IsPremium      bool    `json:"is_premium"`
	JoinDate       string  `json:"joined_at"`
	Karma          float32 `json:"karma"`
	KarmaTrend     string  `json:"karma_trend"`
	NextWeek       int     `json:"next_week"`
	PremiumUntil   string  `json:"premium_until"`
	SortOrder      int     `json:"sort_order"`
	StartDay       int     `json:"start_day"`
	StartPage      string  `json:"start_page"`
	ThemeID        string  `json:"theme_id"`
	TimeFormat     int     `json:"time_format"`
	Token          string  `json:"token"`
	TzInfo         struct {
		GmtString string `json:"gmt_string"`
		Hours     int    `json:"hours"`
		IsDst     int    `json:"is_dst"`
		Minutes   int    `json:"minutes"`
		Timezone  string `json:"timezone"`
	} `json:"tz_info"`
}

Jump to

Keyboard shortcuts

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