asana

package
v0.0.0-...-5f6a193 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package asana is a client for Asana API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized can be returned on any call on response status code 401.
	ErrUnauthorized = errors.New("asana: unauthorized")
)

Functions

This section is empty.

Types

type CFEnumOptions

type CFEnumOptions struct {
	ID      int64  `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Color   string `json:"color,omitempty"`
	Enabled bool   `json:"enabled,omitempty"`
}

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(doer Doer) *Client

NewClient created new asana client with doer. If doer is nil then http.DefaultClient used intead.

func (*Client) AddProject

func (c *Client) AddProject(ctx context.Context, taskID int64, mu MembershipUpdate, opts *Filter) error

AddProject adds a project to a task.

https://asana.com/developers/api-reference/tasks#projects

func (*Client) AddProjectByExternalID

func (c *Client) AddProjectByExternalID(ctx context.Context, externalID string, mu MembershipUpdate, opts *Filter) error

AddProjectByExternalID adds a project to a task.

https://asana.com/developers/api-reference/tasks#projects

func (*Client) AddTag

func (c *Client) AddTag(ctx context.Context, taskID int64, tagID int64, opts *Filter) error

AddTag adds a tag to a task.

https://asana.com/developers/api-reference/tasks#tags

func (*Client) AddTagByExternalID

func (c *Client) AddTagByExternalID(ctx context.Context, externalID string, tagID int64, opts *Filter) error

AddTagByExternalID adds a tag to a task.

https://asana.com/developers/api-reference/tasks#tags

func (*Client) CreateSection

func (c *Client) CreateSection(ctx context.Context, fields map[string]interface{}, opts *Filter) (Section, error)

CreateSection creates a section.

https://asana.com/developers/api-reference/sections#create

func (*Client) CreateTask

func (c *Client) CreateTask(ctx context.Context, fields map[string]interface{}, opts *Filter) (Task, error)

CreateTask creates a task.

https://asana.com/developers/api-reference/tasks#create

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, id int64, target string) (Webhook, error)

CreateWebhook creates a webhook.

https://asana.com/developers/api-reference/webhooks#create

func (*Client) DeleteSection

func (c *Client) DeleteSection(ctx context.Context, id int64, opt *Filter) error

DeleteSection deletes a section.

https://asana.com/developers/api-reference/sections#delete

func (*Client) DeleteSectionByExternalID

func (c *Client) DeleteSectionByExternalID(ctx context.Context, externalID string, opt *Filter) error

DeleteSectionByExternalID deletes a section.

https://asana.com/developers/api-reference/sections#delete

func (*Client) DeleteTask

func (c *Client) DeleteTask(ctx context.Context, id int64, opt *Filter) error

DeleteTask deletes a task.

https://asana.com/developers/api-reference/tasks#delete

func (*Client) DeleteTaskByExternalID

func (c *Client) DeleteTaskByExternalID(ctx context.Context, externalID string, opt *Filter) error

DeleteTaskByExternalID deletes a task.

https://asana.com/developers/api-reference/tasks#delete

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, id int64) error

DeleteWebhook deletes a webhook.

https://asana.com/developers/api-reference/webhooks#delete

func (*Client) GetAuthenticatedUser

func (c *Client) GetAuthenticatedUser(ctx context.Context, opt *Filter) (User, error)

func (*Client) GetSection

func (c *Client) GetSection(ctx context.Context, id int64, opt *Filter) (Section, error)

GetSection gets a section.

https://asana.com/developers/api-reference/sections#get-single

func (*Client) GetSectionByExternalID

func (c *Client) GetSectionByExternalID(ctx context.Context, externalID string, opt *Filter) (Section, error)

GetSectionByExternalID gets a section with an external-ID.

https://asana.com/developers/api-reference/sections#get-single

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, id int64, opt *Filter) (Task, error)

GetTask gets a task.

https://asana.com/developers/api-reference/tasks#get

func (*Client) GetTaskByExternalID

func (c *Client) GetTaskByExternalID(ctx context.Context, externalID string, opt *Filter) (Task, error)

GetTaskByExternalID gets a task with an external-ID.

https://asana.com/developers/api-reference/tasks#get

func (*Client) GetUserByID

func (c *Client) GetUserByID(ctx context.Context, id int64, opt *Filter) (User, error)

func (*Client) GetWebhook

func (c *Client) GetWebhook(ctx context.Context, id int64) (Webhook, error)

GetWebhook gets a webhook.

https://asana.com/developers/api-reference/webhooks#get-single

func (*Client) ListProjectSections

func (c *Client) ListProjectSections(ctx context.Context, projectID int64, opt *Filter) ([]Section, error)

ListProjectSections gets sections in the project.

https://asana.com/developers/api-reference/sections#find-project

func (*Client) ListProjectTasks

func (c *Client) ListProjectTasks(ctx context.Context, projectID int64, opt *Filter) ([]Task, error)

ListProjectTasks gets tasks in the project.

https://asana.com/developers/api-reference/tasks#query

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, opt *Filter) ([]Project, error)

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, opt *Filter) ([]Tag, error)

func (*Client) ListTaskStories

func (c *Client) ListTaskStories(ctx context.Context, taskID int64, opt *Filter) ([]Story, error)

func (*Client) ListTasks

func (c *Client) ListTasks(ctx context.Context, opt *Filter) ([]Task, error)

ListTasks gets tasks.

https://asana.com/developers/api-reference/tasks#query

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, opt *Filter) ([]User, error)

func (*Client) ListWebhooks

func (c *Client) ListWebhooks(ctx context.Context, opt *Filter) ([]Webhook, error)

ListWebhooks gets webhooks.

https://asana.com/developers/api-reference/webhooks#get

func (*Client) ListWorkspaces

func (c *Client) ListWorkspaces(ctx context.Context, opt *Filter) ([]Workspace, error)

func (*Client) RemoveProject

func (c *Client) RemoveProject(ctx context.Context, taskID int64, mu MembershipUpdate, opts *Filter) error

RemoveProject removes a project to a task.

https://asana.com/developers/api-reference/tasks#projects

func (*Client) RemoveProjectByExternalID

func (c *Client) RemoveProjectByExternalID(ctx context.Context, externalID string, mu MembershipUpdate, opts *Filter) error

RemoveProjectByExternalID removes a project to a task.

https://asana.com/developers/api-reference/tasks#projects

func (*Client) RemoveTag

func (c *Client) RemoveTag(ctx context.Context, taskID int64, tagID int64, opts *Filter) error

RemoveTag removes a tag to a task.

https://asana.com/developers/api-reference/tasks#tags

func (*Client) RemoveTagByExternalID

func (c *Client) RemoveTagByExternalID(ctx context.Context, externalID string, tagID int64, opts *Filter) error

RemoveTagByExternalID removes a tag to a task.

https://asana.com/developers/api-reference/tasks#tags

func (*Client) Request

func (c *Client) Request(ctx context.Context, path string, opt *Filter, v interface{}) error

func (*Client) UpdateSection

func (c *Client) UpdateSection(ctx context.Context, id int64, su SectionUpdate, opt *Filter) (Section, error)

UpdateSection updates a section.

https://asana.com/developers/api-reference/sections#update

func (*Client) UpdateSectionByExternalID

func (c *Client) UpdateSectionByExternalID(ctx context.Context, externalID string, su SectionUpdate, opt *Filter) (Section, error)

UpdateSectionByExternalID updates a section.

https://asana.com/developers/api-reference/sections#update

func (*Client) UpdateTask

func (c *Client) UpdateTask(ctx context.Context, id int64, tu TaskUpdate, opt *Filter) (Task, error)

UpdateTask updates a task.

https://asana.com/developers/api-reference/tasks#update

func (*Client) UpdateTaskByExternalID

func (c *Client) UpdateTaskByExternalID(ctx context.Context, externalID string, tu TaskUpdate, opt *Filter) (Task, error)

UpdateTaskByExternalID updates a task.

https://asana.com/developers/api-reference/tasks#update

type CustomField

type CustomField struct {
	ID          int64           `json:"id,omitempty"`
	Name        string          `json:"name,omitempty"`
	Description string          `json:"description,omitempty"`
	Type        string          `json:"type,omitempty"`
	EnumOptions []CFEnumOptions `json:"enum_options,omitempty"`
	Precision   int64           `json:"precision,omitempty"`
	TextValue   string          `json:"text_value,omitempty"`
	NumberValue int64           `json:"number_value,omitempty"`
	EnumValue   CFEnumOptions   `json:"enum_value,omitempty"`
}

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer interface used for doing http calls. Use it as point of setting Auth header or custom status code error handling.

type DoerFunc

type DoerFunc func(req *http.Request) (resp *http.Response, err error)

DoerFunc implements Doer interface. Allow to transform any appropriate function "f" to Doer instance: DoerFunc(f).

func (DoerFunc) Do

func (f DoerFunc) Do(req *http.Request) (resp *http.Response, err error)

type Error

type Error struct {
	Phrase  string `json:"phrase,omitempty"`
	Message string `json:"message,omitempty"`
}

func (Error) Error

func (e Error) Error() string

type Errors

type Errors struct {
	Errors []Error
	Code   int
}

Errors always has at least 1 element when returned.

func (*Errors) Error

func (e *Errors) Error() string

type Event

type Event struct {
	// User who triggered the event.
	// Read-only.
	// NOTE: The event may be triggered by a different user than the subscriber.
	// For example, if user A subscribes to a task and user B modified it, the event’s user will be user B.
	// NOTE: Some events are generated by the system, and will have null as the user.
	// API consumers should make sure to handle this case.
	User User `json:"user,omitempty"`
	// Resource the event occurred on.
	// Read-only.
	// NOTE: The resource that triggered the event may be different from the one that the events were requested for.
	// For example, a subscription to a project will contain events for tasks contained within the project.
	Resource Resource `json:"resource,omitempty"`
	// Type of the resource that generated the event.
	// Read-only.
	// NOTE: Currently, only tasks, projects and stories generate events.
	Type string `json:"type,omitempty"`
	// Action taken that triggered the event.
	// Read-only.
	Action string `json:"action,omitempty"`
	// Parent that resource was added to or removed from. null for other event types.
	// Read-only.
	Parent Resource `json:"parent,omitempty"`
	// Timestamp when the event occurred.
	// Read-only.
	CreatedAt time.Time `json:"created_at,omitempty"`
}

type EventSummary

type EventSummary struct {
	// User who triggered the event.
	// Read-only.
	// NOTE: The event may be triggered by a different user than the subscriber.
	// For example, if user A subscribes to a task and user B modified it, the event’s user will be user B.
	// NOTE: Some events are generated by the system, and will have null as the user.
	// API consumers should make sure to handle this case.
	UserID int64 `json:"user,omitempty"`
	// Resource the event occurred on.
	// Read-only.
	// NOTE: The resource that triggered the event may be different from the one that the events were requested for.
	// For example, a subscription to a project will contain events for tasks contained within the project.
	ResourceID int64 `json:"resource,omitempty"`
	// Type of the resource that generated the event.
	// Read-only.
	// NOTE: Currently, only tasks, projects and stories generate events.
	Type string `json:"type,omitempty"`
	// Action taken that triggered the event.
	// Read-only.
	Action string `json:"action,omitempty"`
	// Parent that resource was added to or removed from. null for other event types.
	// Read-only.
	ParentID *int64 `json:"parent,omitempty"`
	// Timestamp when the event occurred.
	// Read-only.
	CreatedAt time.Time `json:"created_at,omitempty"`
}

type External

type External struct {
	ID   string      `json:"id,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

type Filter

type Filter struct {
	Archived       bool     `url:"archived,omitempty"`
	Assignee       int64    `url:"assignee,omitempty"`
	Project        int64    `url:"project,omitempty"`
	Workspace      int64    `url:"workspace,omitempty"`
	CompletedSince string   `url:"completed_since,omitempty"`
	ModifiedSince  string   `url:"modified_since,omitempty"`
	OptFields      []string `url:"opt_fields,comma,omitempty"`
	OptExpand      []string `url:"opt_expand,comma,omitempty"`
	Offset         string   `url:"offset,omitempty"`
	Limit          uint32   `url:"limit,omitempty"`
}

type Heart

type Heart struct {
	ID   int64 `json:"id,omitempty"`
	User User  `json:"user,omitempty"`
}

Heart represents a ♥ action by a user.

type Membership

type Membership struct {
	Project Project `json:"project,omitempty"`
	Section Section `json:"section,omitempty"`
}

type MembershipUpdate

type MembershipUpdate struct {
	ProjectID    int64  `json:"project,omitempty"`
	InsertAfter  *int64 `json:"insert_after,omitempty"`
	InsertBefore *int64 `json:"insert_before,omitempty"`
	Section      *int64 `json:"section,omitempty"`
}

type NextPage

type NextPage struct {
	Offset string `json:"offset,omitempty"`
	Path   string `json:"path,omitempty"`
	URI    string `json:"uri,omitempty"`
}

type Project

type Project struct {
	ID       int64  `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Archived bool   `json:"archived,omitempty"`
	Color    string `json:"color,omitempty"`
	Notes    string `json:"notes,omitempty"`
}

type Resource

type Resource struct {
	ID   int64  `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type Response

type Response struct {
	Data     interface{} `json:"data,omitempty"`
	NextPage *NextPage   `json:"next_page,omitempty"`
	Errors   []Error     `json:"errors,omitempty"`
}

type Section

type Section struct {
	ID        int64     `json:"id,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	Name      string    `json:"name,omitempty"`
	Project   Project   `json:"project,omitempty"`
	Tags      []Tag     `json:"tags,omitempty"`
	External  External  `json:"external,omitempty"`
}

type SectionUpdate

type SectionUpdate struct {
	Name *string `json:"name,omitempty"`
}

type Story

type Story struct {
	ID        int64     `json:"id,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	CreatedBy User      `json:"created_by,omitempty"`
	Hearts    []Heart   `json:"hearts,omitempty"`
	Text      string    `json:"text,omitempty"`
	Type      string    `json:"type,omitempty"` // E.g., "comment", "system".
}

type Tag

type Tag struct {
	ID    int64  `json:"id,omitempty"`
	Name  string `json:"name,omitempty"`
	Color string `json:"color,omitempty"`
	Notes string `json:"notes,omitempty"`
}

type Task

type Task struct {
	ID             int64         `json:"id,omitempty"`
	Assignee       *User         `json:"assignee,omitempty"`
	AssigneeStatus string        `json:"assignee_status,omitempty"`
	CreatedAt      time.Time     `json:"created_at,omitempty"`
	CreatedBy      User          `json:"created_by,omitempty"` // Undocumented field, but it can be included.
	Completed      bool          `json:"completed,omitempty"`
	CompletedAt    time.Time     `json:"completed_at,omitempty"`
	CustomFields   []CustomField `json:"custom_fields,omitempty"`
	Name           string        `json:"name,omitempty"`
	Hearts         []Heart       `json:"hearts,omitempty"`
	Notes          string        `json:"notes,omitempty"`
	ParentTask     *Task         `json:"parent,omitempty"`
	Projects       []Project     `json:"projects,omitempty"`
	DueOn          string        `json:"due_on,omitempty"`
	DueAt          string        `json:"due_at,omitempty"`
	Followers      []User        `json:"followers,omitempty"`
	Liked          bool          `json:"liked,omitempty"`
	NumHearts      int64         `json:"num_hearts,omitempty"`
	Hearted        bool          `json:"hearted,omitempty"`
	ModifiedAt     time.Time     `json:"modified_at,omitempty"`
	NumLikes       int64         `json:"num_likes,omitempty"`
	Tags           []Tag         `json:"tags,omitempty"`
	Memberships    []Membership  `json:"memberships,omitempty"`
	// "workspace":    map[string]interface {}{"id":13218399566047.000000,"name":"wacul.co.jp"},
	External External `json:"external,omitempty"`
}

func (*Task) GetCustomFieldValue

func (t *Task) GetCustomFieldValue(name string) (string, error)

GetCustomFieldValue Get a custom_field value from a task

type TaskUpdate

type TaskUpdate struct {
	Assignee     *string               `json:"assignee,omitempty"`
	Name         *string               `json:"name,omitempty"`
	Notes        *string               `json:"notes,omitempty"`
	Hearted      *bool                 `json:"hearted,omitempty"`
	Completed    *bool                 `json:"completed,omitempty"`
	CompletedAt  *time.Time            `json:"completed_at,omitempty"`
	CustomFields map[int64]interface{} `json:"custom_fields,omitempty"`
}

TaskUpdate is used to update a task.

type User

type User struct {
	ID         int64             `json:"id,omitempty"`
	Email      string            `json:"email,omitempty"`
	Name       string            `json:"name,omitempty"`
	Photo      map[string]string `json:"photo,omitempty"`
	Workspaces []Workspace       `json:"workspaces,omitempty"`
}

type Webhook

type Webhook struct {
	ID       int64    `json:"id,omitempty"`
	Resource Resource `json:"resource,omitempty"`
	Target   string   `json:"target,omitempty"`
	Active   bool     `json:"active,omitempty"`
}

type Workspace

type Workspace struct {
	ID           int64  `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	Organization bool   `json:"is_organization,omitempty"`
}

Jump to

Keyboard shortcuts

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