asana

package
v0.0.0-...-1fc4830 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 11 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 AddProjectTask

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

type AddTaskSection

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

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) AddProjectTask

func (c *Client) AddProjectTask(
	ctx context.Context,
	id string,
	addProjectTask AddProjectTask,
	fields map[string]string,
	opts *Filter,
) error

AddProjectTask adds a project to a task

https://developers.asana.com/docs/add-a-project-to-a-task

func (*Client) AddTaskSection

func (c *Client) AddTaskSection(
	ctx context.Context,
	id string,
	addTaskSection AddTaskSection,
	fields map[string]string,
	opts *Filter,
) error

https://developers.asana.com/docs/add-task-to-section

func (*Client) CreateTask

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

CreateTask creates a task.

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

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 string, opt *Filter) (Section, error)

func (*Client) GetTask

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

func (*Client) GetUserByID

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

func (*Client) ListProjectSections

func (c *Client) ListProjectSections(ctx context.Context, id string, opt *Filter) (Sections, error)

func (*Client) ListProjectTasks

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

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 string, opt *Filter) ([]Story, error)

func (*Client) ListTasks

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

func (*Client) ListUsers

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

func (*Client) ListWorkspaces

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

func (*Client) Request

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

func (*Client) UpdateTask

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

UpdateTask updates a task.

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

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 []Error

Errors always has at least 1 element when returned.

func (Errors) Error

func (e Errors) Error() string

type Filter

type Filter struct {
	Archived       bool     `url:"archived,omitempty"`
	Assignee       string   `url:"assignee,omitempty"`
	Project        string   `url:"project,omitempty"`
	Workspace      string   `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"`
}

type Heart

type Heart struct {
	ID   string `json:"gid,omitempty"`
	User User   `json:"user,omitempty"`
}

Heart represents a ♥ action by a user.

type Project

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

type Response

type Response struct {
	Data   interface{} `json:"data,omitempty"`
	Errors Errors      `json:"errors,omitempty"`
}

type Section

type Section struct {
	ID           string    `json:"gid,omitempty"`
	ResourceType string    `json:"resource_type"`
	Name         string    `json:"name,omitempty"`
	CreatedAt    time.Time `json:"created_at,omitempty"`
	Projects     []Project `json:"projects,omitempty"`
	Project      Project   `json:"project,omitempty"`
}

type Sections

type Sections []Section

type Story

type Story struct {
	ID        string    `json:"gid,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    string `json:"gid,omitempty"`
	Name  string `json:"name,omitempty"`
	Color string `json:"color,omitempty"`
	Notes string `json:"notes,omitempty"`
}

type Task

type Task struct {
	ID             string    `json:"gid,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"`
	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"`
}

type TaskUpdate

type TaskUpdate struct {
	Notes     *string `json:"notes,omitempty"`
	Hearted   *bool   `json:"hearted,omitempty"`
	Completed *bool   `json:"completed,omitempty"`
}

TaskUpdate is used to update a task.

type User

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

type Workspace

type Workspace struct {
	ID           string `json:"gid,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