todoist

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTempID

func IsTempID(id ID) bool

func IsValidID

func IsValidID(id ID) bool

Types

type Client

type Client struct {
	URL        *url.URL
	HTTPClient *http.Client
	Token      string
	SyncToken  string
	CacheDir   string

	Logger    *log.Logger
	Completed *CompletedClient
	Filter    *FilterClient
	Item      *ItemClient
	Label     *LabelClient
	Project   *ProjectClient
	Relation  *RelationClient
	Note      *NoteClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint, token, sync_token, cache_dir string, logger *log.Logger) (*Client, error)

func (*Client) Commit

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

func (*Client) FullSync

func (c *Client) FullSync(ctx context.Context, commands []Command) error

func (*Client) ResetSyncToken

func (c *Client) ResetSyncToken()

func (*Client) Sync

func (c *Client) Sync(ctx context.Context, commands []Command) error

type ColorStringer

type ColorStringer interface {
	String() string
	ColorString() string
}

type Command

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

type CompletedClient

type CompletedClient struct {
	*Client
}

func (*CompletedClient) GetAll

func (c *CompletedClient) GetAll() (*CompletedItems, error)

func (*CompletedClient) GetStats

func (c *CompletedClient) GetStats() (*Stats, error)

type CompletedItems

type CompletedItems struct {
	Items    []Item         `json:"items"`
	Projects map[ID]Project `json:"projects"`
}

func (*CompletedItems) GroupByCompletedDate

func (c *CompletedItems) GroupByCompletedDate() map[string][]Item

type Due added in v0.2.0

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

type Entity

type Entity struct {
	ID        ID      `json:"id,omitempty"`
	IsDeleted IntBool `json:"is_deleted,omitempty"`
}

func (Entity) Equal

func (e Entity) Equal(entity Identifier) bool

type FileAttachment added in v0.2.0

type FileAttachment struct {
	FileName    string `json:"file_name"`
	FileSize    int    `json:"file_size"`
	FileType    string `json:"file_type"`
	FileURL     string `json:"file_url"`
	UploadState string `json:"upload_state"`
}

type Filter

type Filter struct {
	Entity
	Name       string  `json:"name"`
	Query      string  `json:"query"`
	Color      int     `json:"color"`
	ItemOrder  int     `json:"item_order"`
	IsFavorite IntBool `json:"is_favorite"`
}

func NewFilter added in v0.2.0

func NewFilter(name, query string, opts *NewFilterOpts) (*Filter, error)

func (Filter) ColorString

func (f Filter) ColorString() string

func (Filter) String

func (f Filter) String() string

type FilterClient

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

func (*FilterClient) Add

func (c *FilterClient) Add(filter Filter) (*Filter, error)

func (*FilterClient) Delete

func (c *FilterClient) Delete(id ID) error

func (FilterClient) FindByName

func (c FilterClient) FindByName(substr string) []Filter

func (*FilterClient) Get

func (c *FilterClient) Get(ctx context.Context, id ID) (*FilterGetResponse, error)

func (*FilterClient) GetAll

func (c *FilterClient) GetAll() []Filter

func (*FilterClient) Resolve

func (c *FilterClient) Resolve(id ID) *Filter

func (*FilterClient) Update

func (c *FilterClient) Update(filter Filter) (*Filter, error)

func (*FilterClient) UpdateOrders added in v0.2.0

func (c *FilterClient) UpdateOrders(filters []Filter) error

type FilterGetResponse

type FilterGetResponse struct {
	Filter Filter
}

type ID

type ID string

func GenerateTempID

func GenerateTempID() ID

func NewID

func NewID(id string) (ID, error)

func NewIDs

func NewIDs(ids []string) ([]ID, error)

func (ID) IsZero added in v0.2.0

func (i ID) IsZero() bool

func (ID) MarshalJSON

func (i ID) MarshalJSON() ([]byte, error)

func (ID) String

func (i ID) String() string

func (*ID) UnmarshalJSON

func (i *ID) UnmarshalJSON(b []byte) (err error)

type Identifier

type Identifier interface {
	Equal(id Identifier) bool
	// contains filtered or unexported methods
}

type IntBool

type IntBool bool

func (IntBool) Bool

func (i IntBool) Bool() bool

func (IntBool) MarshalJSON

func (i IntBool) MarshalJSON() ([]byte, error)

func (*IntBool) UnmarshalJSON

func (i *IntBool) UnmarshalJSON(b []byte) (err error)

type Item

type Item struct {
	Entity
	UserID         ID      `json:"user_id,omitempty"`
	ProjectID      ID      `json:"project_id,omitempty"`
	Content        string  `json:"content"`
	Due            Due     `json:"due,omitempty"`
	Priority       int     `json:"priority,omitempty"`
	ParentID       ID      `json:"parent_id,omitempty"`
	ChildOrder     int     `json:"child_order,omitempty"`
	DayOrder       int     `json:"day_order,omitempty"`
	Collapsed      IntBool `json:"collapsed,omitempty"`
	Labels         []ID    `json:"labels,omitempty"`
	AssignedByUID  ID      `json:"assigned_by_uid,omitempty"`
	ResponsibleUID ID      `json:"responsible_uid,omitempty"`
	Checked        IntBool `json:"checked,omitempty"`
	InHistory      IntBool `json:"in_history,omitempty"`
	SyncID         int     `json:"sync_id,omitempty"`
	DateAdded      Time    `json:"date_added,omitempty"`
	CompletedDate  Time    `json:"completed_date"`
}

func NewItem added in v0.2.0

func NewItem(content string, opts *NewItemOpts) (*Item, error)

func (Item) IsChecked added in v0.1.3

func (i Item) IsChecked() bool

func (Item) IsOverDueDate

func (i Item) IsOverDueDate() bool

type ItemClient

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

func (*ItemClient) Add

func (c *ItemClient) Add(item Item) (*Item, error)

func (*ItemClient) Close

func (c *ItemClient) Close(id ID) error

func (*ItemClient) Complete

func (c *ItemClient) Complete(id ID, dateCompleted Time, forceHistory bool) error

func (*ItemClient) Delete

func (c *ItemClient) Delete(id ID) error

func (ItemClient) FindByContent

func (c ItemClient) FindByContent(substr string) []Item

func (ItemClient) FindByDueDate

func (c ItemClient) FindByDueDate(time Time) []Item

func (ItemClient) FindByProjectIDs

func (c ItemClient) FindByProjectIDs(ids []ID) []Item

func (*ItemClient) Get

func (c *ItemClient) Get(ctx context.Context, id ID) (*ItemGetResponse, error)

func (*ItemClient) GetAll

func (c *ItemClient) GetAll() []Item

func (*ItemClient) GetCompleted

func (c *ItemClient) GetCompleted(ctx context.Context, projectID ID) (*[]Item, error)

func (*ItemClient) Move

func (c *ItemClient) Move(id ID, opts *ItemMoveOpts) error

func (*ItemClient) Resolve

func (c *ItemClient) Resolve(id ID) *Item

func (*ItemClient) Uncomplete

func (c *ItemClient) Uncomplete(id ID) error

func (*ItemClient) Update

func (c *ItemClient) Update(item Item) (*Item, error)

type ItemGetResponse

type ItemGetResponse struct {
	Item    Item
	Project Project
	Notes   []Note
}

type ItemMoveOpts added in v0.2.0

type ItemMoveOpts struct {
	ParentID  ID
	ProjectID ID
}

type ItemRelations

type ItemRelations struct {
	//Users map[ID]User
	Projects map[ID]Project
	Labels   map[ID]Label
}

type Label

type Label struct {
	Entity
	Name       string  `json:"name"`
	Color      int     `json:"color"`
	ItemOrder  int     `json:"item_order"`
	IsFavorite IntBool `json:"is_favorite"`
}

func NewLabel added in v0.2.0

func NewLabel(name string, opts *NewLabelOpts) (*Label, error)

func (Label) ColorString

func (l Label) ColorString() string

func (Label) String

func (l Label) String() string

type LabelClient

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

func (*LabelClient) Add

func (c *LabelClient) Add(label Label) (*Label, error)

func (*LabelClient) Delete

func (c *LabelClient) Delete(id ID) error

func (LabelClient) FindByName

func (c LabelClient) FindByName(substr string) []Label

func (LabelClient) FindOneByName added in v0.1.3

func (c LabelClient) FindOneByName(substr string) *Label

func (*LabelClient) Get

func (c *LabelClient) Get(ctx context.Context, id ID) (*LabelGetResponse, error)

func (*LabelClient) GetAll

func (c *LabelClient) GetAll() []Label

func (*LabelClient) Resolve

func (c *LabelClient) Resolve(id ID) *Label

func (*LabelClient) Update

func (c *LabelClient) Update(label Label) (*Label, error)

func (*LabelClient) UpdateOrders added in v0.2.0

func (c *LabelClient) UpdateOrders(labels []Label) error

type LabelGetResponse

type LabelGetResponse struct {
	Label Label
}

type Labels added in v0.1.4

type Labels []Label

func (Labels) ColorString added in v0.1.4

func (ls Labels) ColorString() string

func (Labels) String added in v0.1.4

func (ls Labels) String() string

type NewFilterOpts added in v0.2.0

type NewFilterOpts struct {
	Color      int
	ItemOrder  int
	IsFavorite IntBool
}

type NewItemOpts added in v0.2.0

type NewItemOpts struct {
	ProjectID       ID
	Due             Due
	Priority        int
	ParentID        ID
	ChildOrder      int
	DayOrder        int
	Collapsed       IntBool
	Labels          []ID
	AssignedByUID   ID
	ResponsibleUID  ID
	AutoReminder    bool
	AutoParseLabels bool
}

type NewLabelOpts added in v0.2.0

type NewLabelOpts struct {
	Color      int
	ItemOrder  int
	IsFavorite IntBool
}

type NewNoteOpts added in v0.2.0

type NewNoteOpts struct {
	FileAttachment FileAttachment
	UIDsToNotify   []ID
}

type NewProjectOpts added in v0.2.0

type NewProjectOpts struct {
	Color      int
	ParentID   ID
	ChildOrder int
	IsFavorite IntBool
}

type NoColorString

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

func NewNoColorString

func NewNoColorString(s string) NoColorString

func (NoColorString) ColorString

func (n NoColorString) ColorString() string

func (NoColorString) String

func (n NoColorString) String() string

type Note

type Note struct {
	Entity
	PostedUID      ID              `json:"posted_uid"`
	ItemID         ID              `json:"item_id"`
	ProjectID      ID              `json:"project_id"`
	Content        string          `json:"content"`
	FileAttachment FileAttachment  `json:"file_attachment"`
	UIDsToNotify   []ID            `json:"uids_to_notify"`
	Posted         Time            `json:"posted"`
	Reactions      map[string][]ID `json:"reactions"`
}

func NewNote added in v0.2.0

func NewNote(id ID, content string, opts *NewNoteOpts) (*Note, error)

type NoteClient

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

NoteClient encapsulate client operations for notes.

func (NoteClient) Add added in v0.2.0

func (c NoteClient) Add(note Note) (*Note, error)

func (NoteClient) Delete added in v0.2.0

func (c NoteClient) Delete(id ID) error

func (NoteClient) GetAllForItem

func (c NoteClient) GetAllForItem(itemID ID) []Note

GetAllForItem returns all the cached notes that belong to the given item.

func (NoteClient) GetAllForProject

func (c NoteClient) GetAllForProject(projectID ID) []Note

GetAllForProject returns all the cached notes that belong to the given project.

func (NoteClient) Update added in v0.2.0

func (c NoteClient) Update(note Note) (*Note, error)

type Project

type Project struct {
	Entity
	Name         string  `json:"name"`
	Color        int     `json:"color"`
	ChildOrder   int     `json:"child_order"`
	ParentID     ID      `json:"parent_id"`
	Collapsed    IntBool `json:"collapsed"`
	Shared       bool    `json:"shared"`
	IsArchived   IntBool `json:"is_archived"`
	IsFavorite   IntBool `json:"is_favorite"`
	InboxProject bool    `json:"inbox_project"`
	TeamInbox    bool    `json:"team_inbox"`
}

func NewProject added in v0.2.0

func NewProject(name string, opts *NewProjectOpts) (*Project, error)

func (Project) ColorString

func (p Project) ColorString() string

func (Project) String

func (p Project) String() string

type ProjectClient

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

func (*ProjectClient) Add

func (c *ProjectClient) Add(project Project) (*Project, error)

func (*ProjectClient) Archive

func (c *ProjectClient) Archive(id ID) error

func (*ProjectClient) Delete

func (c *ProjectClient) Delete(id ID) error

func (ProjectClient) FindByName

func (c ProjectClient) FindByName(substr string) []Project

func (ProjectClient) FindOneByName added in v0.1.3

func (c ProjectClient) FindOneByName(substr string) *Project

func (*ProjectClient) Get

func (*ProjectClient) GetAll

func (c *ProjectClient) GetAll() []Project

func (*ProjectClient) GetArchived

func (c *ProjectClient) GetArchived(ctx context.Context) (*[]Project, error)

func (*ProjectClient) GetData

func (c *ProjectClient) GetData(ctx context.Context, id ID) (*ProjectGetDataResponse, error)

func (*ProjectClient) Move added in v0.2.0

func (c *ProjectClient) Move(id, parentID ID) error

func (*ProjectClient) Reorder added in v0.2.0

func (c *ProjectClient) Reorder(projects []Project) error

func (*ProjectClient) Resolve

func (c *ProjectClient) Resolve(id ID) *Project

func (*ProjectClient) Unarchive

func (c *ProjectClient) Unarchive(id ID) error

func (*ProjectClient) Update

func (c *ProjectClient) Update(project Project) (*Project, error)

type ProjectGetDataResponse

type ProjectGetDataResponse struct {
	Project Project
	Items   []Item
}

type ProjectGetResponse

type ProjectGetResponse struct {
	Project Project
	Notes   []Note
}

type RelationClient

type RelationClient struct {
	*Client
}

func (RelationClient) Items

func (c RelationClient) Items(items []Item) ItemRelations

type Reminder

type Reminder struct {
	Entity
	NotifyUID  ID     `json:"notify_uid"`
	ItemID     ID     `json:"item_id"`
	Service    string `json:"service"`
	Type       string `json:"type"`
	Due        Due    `json:"due"`
	MmOffset   int    `json:"mm_offset"`
	Name       string `json:"name"`
	LocLat     string `json:"loc_lat"`
	LocLong    string `json:"loc_long"`
	LocTrigger string `json:"loc_trigger"`
	Radius     int    `json:"radius"`
}

type Resolver

type Resolver interface {
	Resolve(id ID) *Entity
}

type Stats

type Stats struct {
	KarmaLastUpdate float64 `json:"karma_last_update"`
	KarmaTrend      string  `json:"karma_trend"`
	DaysItems       []struct {
		Date  string `json:"date"`
		Items []struct {
			Completed int `json:"completed"`
			ID        int `json:"id"`
		} `json:"items"`
		TotalCompleted int `json:"total_completed"`
	} `json:"days_items"`
	CompletedCount     int `json:"completed_count"`
	KarmaUpdateReasons []struct {
		PositiveKarmaReasons []int   `json:"positive_karma_reasons"`
		NewKarma             float64 `json:"new_karma"`
		NegativeKarma        float64 `json:"negative_karma"`
		PositiveKarma        float64 `json:"positive_karma"`
		NegativeKarmaReasons []int   `json:"negative_karma_reasons"`
		Time                 string  `json:"time"`
	} `json:"karma_update_reasons"`
	Karma     float64 `json:"karma"`
	WeekItems []struct {
		Date  string `json:"date"`
		Items []struct {
			Completed int `json:"completed"`
			ID        int `json:"id"`
		} `json:"items"`
		TotalCompleted int `json:"total_completed"`
	} `json:"week_items"`
	KarmaGraph string `json:"karma_graph"`
	Goals      struct {
		KarmaDisabled   int `json:"karma_disabled"`
		UserID          int `json:"user_id"`
		LastDailyStreak struct {
			Count int    `json:"count"`
			Start string `json:"start"`
			End   string `json:"end"`
		} `json:"last_daily_streak"`
		VacationMode    int   `json:"vacation_mode"`
		IgnoreDays      []int `json:"ignore_days"`
		MaxWeeklyStreak struct {
			Count int    `json:"count"`
			Start string `json:"start"`
			End   string `json:"end"`
		} `json:"max_weekly_streak"`
		CurrentWeeklyStreak struct {
			Count int    `json:"count"`
			Start string `json:"start"`
			End   string `json:"end"`
		} `json:"current_weekly_streak"`
		CurrentDailyStreak struct {
			Count int    `json:"count"`
			Start string `json:"start"`
			End   string `json:"end"`
		} `json:"current_daily_streak"`
		LastWeeklyStreak struct {
			Count int    `json:"count"`
			Start string `json:"start"`
			End   string `json:"end"`
		} `json:"last_weekly_streak"`
		WeeklyGoal     int `json:"weekly_goal"`
		MaxDailyStreak struct {
			Count int    `json:"count"`
			Start string `json:"start"`
			End   string `json:"end"`
		} `json:"max_daily_streak"`
		DailyGoal int `json:"daily_goal"`
	} `json:"goals"`
}

type SyncState

type SyncState struct {
	SyncToken string `json:"sync_token"`
	FullSync  bool   `json:"full_sync"`
	// User User `json:"user"`
	Projects     []Project `json:"projects"`
	ProjectNotes []Note    `json:"project_notes"`
	Items        []Item    `json:"items"`
	Notes        []Note    `json:"notes"`
	Labels       []Label   `json:"labels"`
	Filters      []Filter  `json:"filters"`
	// DayOrders struct {} `json:"day_orders"`
	// DayOrdersTimestamp string `json:"day_orders_timestamp"`
	Reminders []Reminder `json:"reminders"`
}

type Time

type Time struct {
	time.Time
}

func Next7Days

func Next7Days() Time

func Parse

func Parse(value string) (Time, error)

func Today

func Today() Time

func (Time) After

func (t Time) After(u Time) bool

func (Time) Before

func (t Time) Before(u Time) bool

func (Time) ColorString

func (t Time) ColorString() string

func (Time) Equal

func (t Time) Equal(u Time) bool

func (Time) IsFullDay added in v0.2.0

func (t Time) IsFullDay() bool

func (Time) Local

func (t Time) Local() Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

type UUID

type UUID string

func GenerateUUID

func GenerateUUID() UUID

func (UUID) MarshalJSON

func (i UUID) MarshalJSON() ([]byte, error)

func (*UUID) UnmarshalJSON

func (i *UUID) UnmarshalJSON(b []byte) (err error)

Jump to

Keyboard shortcuts

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