client

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTable

func CreateTable(f *os.File, cols []string) *tabwriter.Writer

CreateTable with column headers and return a row writer

func FormatDate

func FormatDate(d DueDate, dateFmt string) (string, error)

func GetFields

func GetFields(val interface{}, cols []string, dateFmt string) []string

GetFields from a column list using reflection

func PrintLabels

func PrintLabels(f *os.File, labels []Label, cols []string, sortCol string, dateFmt string)

PrintLabels after sorting, with column headers

func PrintProjects

func PrintProjects(f *os.File, projects []Project, cols []string, sortCol string, dateFmt string)

PrintProjects after sorting, with column headers

func PrintTasks

func PrintTasks(f *os.File, tasks []Task, cols []string, sortCol string, dateFmt string)

PrintTasks in a table

func SortByField

func SortByField(rows interface{}, column string)

SortByField sorts the given slice of rows by the selected column

func Tabulate

func Tabulate(cols []string) []interface{}

Tabulate an array of column names by inserting tabs between each and converting to a Printf-compatible slice

Types

type Client

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

Client for API

func New

func New(config *config.Config) *Client

New client

func (*Client) AddTask

func (c *Client) AddTask(task Task) ([]Task, error)

AddTask creates a new task

func (*Client) BuildFilter

func (c *Client) BuildFilter(required []string, optional []string) string

func (*Client) CloseTask

func (c *Client) CloseTask(task Task) error

CloseTask marks an existing task as complete, by ID

func (*Client) Columns

func (c *Client) Columns(cmdColumns []string, rootColumns []string, configColumns []string) []string

Columns to display based on command, config, and flags

func (*Client) Config

func (c *Client) Config() *config.Config

Config used by this client

func (*Client) FindLabel

func (c *Client) FindLabel(name string) (Label, error)

FindLabel by name

func (*Client) FindProject

func (c *Client) FindProject(name string) (Project, error)

FindProject by name

func (*Client) Get

func (c *Client) Get(parts ...string) (body []byte, status int, err error)

func (*Client) GetLabels

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

GetLabels from API

func (*Client) GetProjects

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

GetProjects from API

func (*Client) GetTasks

func (c *Client) GetTasks(project string, required []string, optional []string) ([]Task, error)

GetTasks lists incomplete and recurring tasks

func (*Client) Request

func (c *Client) Request() *resty.Request

Request an API endpoint with authorization

func (*Client) Resolve

func (c *Client) Resolve(parts ...string) string

Resolve a partial path as an API endpoint

func (*Client) Sort

func (c *Client) Sort(cmdSort string, rootSort string, configSort string) string

Sort column based on command, config, and flags

type DueDate

type DueDate struct {
	Date     string `json:"date" yaml:"date"`
	DateTime string `json:"datetime" yaml:"datetime"`
	Timezone string `json:"timezone" yaml:"timezone"`
}

type Label

type Label struct {
	ID    int    `json:"id" yaml:"id"`
	Name  string `json:"name" yaml:"name"`
	Order int    `json:"order" yaml:"order"`
}

Label model https://developer.todoist.com/rest/v8/#labels

func ParseLabels

func ParseLabels(data []byte) ([]Label, error)

ParseLabels from a byte array

type Project

type Project struct {
	ID     int    `json:"id" yaml:"id"`
	Indent int    `json:"indent" yaml:"indent"`
	Name   string `json:"name" yaml:"name"`
	Order  int    `json:"order" yaml:"order"`
}

Project model https://developer.todoist.com/rest/v8/#projects

func ParseProjects

func ParseProjects(data []byte) ([]Project, error)

ParseProjects from byte array

type Task

type Task struct {
	Content  string  `json:"content" yaml:"content"`
	Due      DueDate `json:"due" yaml:"due"`
	ID       int     `json:"id" yaml:"id,omitempty"`
	Labels   []int   `json:"label_ids" yaml:"label_ids"`
	Order    int     `json:"order" yaml:"order,omitempty"`
	Priority int     `json:"priority" yaml:"priority,omitempty"`
	Project  int     `json:"project_id" yaml:"project_id"`
}

Task model https://developer.todoist.com/rest/v8/#tasks

func ParseTasks

func ParseTasks(data []byte) ([]Task, error)

ParseTasks from a byte array

Jump to

Keyboard shortcuts

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