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 ¶
- Variables
- type APIError
- type Client
- func (c *Client) Delete(ctx context.Context, list, id string) error
- func (c *Client) Insert(ctx context.Context, list string, f Fields, parent, previous string) (Task, error)
- func (c *Client) Lists(ctx context.Context) ([]List, error)
- func (c *Client) Move(ctx context.Context, list, id, parent, previous string) (Task, error)
- func (c *Client) Patch(ctx context.Context, list, id string, f Fields) (Task, error)
- func (c *Client) Tasks(ctx context.Context, list string, updatedMin time.Time) ([]Task, error)
- type Fields
- type Link
- type List
- type Options
- type Task
Constants ¶
This section is empty.
Variables ¶
var ( 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) HTTPStatus ¶ added in v0.6.0
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 (*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).
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 ¶
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. |