gtasks

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gtasks is a client of the Google Tasks API (v1) for pimsync (docs/design/pim.md, Tasks): task lists, tasks with their JSON kept as sent, and the writes Frostmail makes. It is tested against gtaskstest.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized is a 401: the access token was refused.
	ErrUnauthorized = errors.New("gtasks: unauthorized")
	// ErrNotFound is a 404: the list or task is gone.
	ErrNotFound = errors.New("gtasks: not found")
)

Errors the API answers with; other failures are *APIError.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  int
	Message string // the error's message from Google's JSON, when there is one
}

APIError is any other answer that is not 2xx.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) HTTPStatus added in v0.6.0

func (e *APIError) HTTPStatus() int

HTTPStatus is the response's status (internal/activity's classifier).

type Client

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

Client speaks to the API at a base URL (…/tasks/v1, with or without a trailing slash).

func New

func New(base string, opts Options) *Client

New returns a Client.

func (*Client) Delete

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

Delete deletes a task (and, on Google's side, its subtasks).

func (*Client) Insert

func (c *Client) Insert(ctx context.Context, list string, f Fields, parent, previous string) (Task, error)

Insert adds a task under parent ("" for the top level) after previous ("" for the first place).

func (*Client) Lists

func (c *Client) Lists(ctx context.Context) ([]List, error)

Lists returns every task list, following pages.

func (*Client) Move

func (c *Client) Move(ctx context.Context, list, id, parent, previous string) (Task, error)

Move puts a task under parent after previous.

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, list, id string, f Fields) (Task, error)

Patch changes the fields f sets.

func (*Client) Tasks

func (c *Client) Tasks(ctx context.Context, list string, updatedMin time.Time) ([]Task, error)

Tasks returns a list's tasks updated at or after updatedMin (every task when it is zero), completed, hidden and deleted ones included, following pages, in the API's order.

type Fields

type Fields struct {
	Title *string
	Notes *string
	// Due is YYYY-MM-DD, or "" to clear it.
	Due       *string
	Completed *bool
}

Fields are what Insert and Patch send; nil fields are left out, so a Patch keeps them.

type Link struct {
	Type        string `json:"type"`
	Description string `json:"description"`
	Link        string `json:"link"`
}

Link is a task's link; a task made from a Gmail message links to it.

type List

type List struct {
	ID      string    `json:"id"`
	Title   string    `json:"title"`
	Updated time.Time `json:"updated"`
}

List is a task list.

type Options

type Options struct {
	// HTTP sends requests; nil uses a client with a 30-second timeout.
	HTTP *http.Client
	// Token gives the bearer token for each request.
	Token func(ctx context.Context) (string, error)
	// UserAgent is sent with every request when set.
	UserAgent string
}

Options configure a Client.

type Task

type Task struct {
	ID    string
	Title string
	Notes string
	// Completed is set when the status is "completed".
	Completed   bool
	CompletedAt time.Time // zero unless completed
	// Due is the due date, YYYY-MM-DD, or "": Google keeps only the date.
	Due         string
	Parent      string
	Position    string
	Updated     time.Time
	Deleted     bool
	Hidden      bool
	Links       []Link
	WebViewLink string
	// Raw is the task's JSON as the API sent it.
	Raw []byte
}

Task is a task as the API sent it.

Directories

Path Synopsis
Package gtaskstest is an in-process Google Tasks API (v1) for tests, as davtest is for DAV (docs/design/pim.md, Testing): task lists and tasks in memory with Google's JSON, paging, updatedMin, hidden and deleted tasks, positions among siblings, a bearer token, and hooks to change tasks as another client would and to make requests fail.
Package gtaskstest is an in-process Google Tasks API (v1) for tests, as davtest is for DAV (docs/design/pim.md, Testing): task lists and tasks in memory with Google's JSON, paging, updatedMin, hidden and deleted tasks, positions among siblings, a bearer token, and hooks to change tasks as another client would and to make requests fail.

Jump to

Keyboard shortcuts

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