todoist

package
v0.0.0-...-8e970c3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2016 License: MIT Imports: 9 Imported by: 0

README

todoist Package

Provides methods and types for interacting with the Todoist.com REST API.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllDataRequest = defaultParamsForAllResources([]string{"all"})

Request for all data.

View Source
var AllItemsRequest = defaultParamsForAllResources([]string{"items"})

Request for all items.

View Source
var AllProjectsAndItemsRequest = defaultParamsForAllResources([]string{"projects", "items"})

Request for all projects and items.

View Source
var UserRequest = defaultParamsForAllResources([]string{"user"})

Request for user account info.

Functions

This section is empty.

Types

type Client

type Client struct {
	Token      string
	SyncApiUrl string
}

Todoist Sync API client. Carries a token corresponding to a user's session and acts on a base API URL.

func NewDefaultClient

func NewDefaultClient(token string) *Client

Creates a client pointed to the default Todoist Sync API URL.

func (Client) MakeRequest

func (c Client) MakeRequest(req RequestParams, res Responser) (err error)

Performs the given request, providing the response in the passed in object. Response objects must know how to parse themselves from JSON and validate. Will short-circuit and return an error if one occurred during the request.

type Item

type Item struct {
	Id        int
	Content   string
	Indent    int
	Archived  int `json:"is_archived"`
	Deleted   int `json:"is_deleted"`
	ProjectId int `json:"project_id"`
	Project   *Project
}

Represents an Item.

func ItemWithId

func ItemWithId(items []*Item, id int) *Item

Returns the item with the given id, if any.

func (Item) String

func (i Item) String() string

Adhere to Stringer interface.

type Project

type Project struct {
	Id       int
	Name     string
	Indent   int
	Items    []*Item
	Archived int `json:"is_archived"`
	Deleted  int `json:"is_deleted"`
}

Represents a Project.

func ProjectWithId

func ProjectWithId(projects []*Project, id int) *Project

Returns the project with the given id, if any.

func (Project) String

func (p Project) String() string

Adhere to Stringer interface.

type ReadResult

type ReadResult struct {
	Items    []*Item
	Projects []*Project
	User     *User
}

Represents a read request result.

func (*ReadResult) UnmarshalJson

func (r *ReadResult) UnmarshalJson(bytes []byte) error

Unpacks a read result from a JSON representation. Ensures this type adheres to JsonUnmarshaler.

func (*ReadResult) ValidateResponse

func (r *ReadResult) ValidateResponse() error

Validate reads.

type RequestParams

type RequestParams url.Values

Represents a Sync API request type.

func CloseProjectRequest

func CloseProjectRequest(id int) RequestParams

Request to close a project.

func CompleteItemRequest

func CompleteItemRequest(id int) RequestParams

Request to complete an item.

func CreateItemRequest

func CreateItemRequest(content string, projectId int) RequestParams

Request to create an item.

func CreateProjectRequest

func CreateProjectRequest(name string) RequestParams

Request to create a project.

type ResponseUnmarshaler

type ResponseUnmarshaler interface {
	UnmarshalJson(bytes []byte) error
}

Describes a type that may be unmarshaled via JSON response data.

type ResponseValidator

type ResponseValidator interface {
	ValidateResponse() error
}

Describes a type that determines if the response was valid.

type Responser

type Responser interface {
	ResponseValidator
	ResponseUnmarshaler
}

A full response object.

type User

type User struct {
	FullName       string  `json:"full_name"`
	Email          string  `json:"email"`
	CompletedToday int     `json:"completed_today"`
	NextWeek       int     `json:"next_week"`
	CompletedCount int     `json:"completed_count"`
	Karma          float64 `json:"karma"`
}

Represents a User.

type WriteResult

type WriteResult struct {
	SyncStatus map[string]string `json:"sync_status"`
}

Represents a write request result.

func (*WriteResult) UnmarshalJson

func (r *WriteResult) UnmarshalJson(bytes []byte) error

Unpacks a write result from a JSON representation. Ensures this type adheres to JsonUnmarshaler.

func (*WriteResult) ValidateResponse

func (r *WriteResult) ValidateResponse() error

Validate writes.

Jump to

Keyboard shortcuts

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