client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://app.asana.com/api/1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int           `json:"-"`
	Errors     []ErrorDetail `json:"errors"`
	RawBody    string        `json:"-"`
}

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) HelpText

func (e *APIError) HelpText() string

HelpText returns Asana's actionable help string for this error, if any.

func (*APIError) IsAuth

func (e *APIError) IsAuth() bool

IsAuth reports whether this is an authentication failure (HTTP 401).

func (*APIError) Message

func (e *APIError) Message() string

Message returns the cleanest human message Asana provided, without the "asana api: HTTP N:" prefix that Error() adds. Empty only if Asana gave neither a structured error nor a body.

type Client

type Client struct {
	BaseURL    string
	Token      string
	HTTPClient *http.Client
	Verbose    bool
}

func New

func New(token string) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, query url.Values, body interface{}) (*Response, error)

Do wraps body in Asana's `{"data": ...}` envelope before sending.

func (*Client) DoRaw

func (c *Client) DoRaw(ctx context.Context, method, path string, query url.Values, rawBody []byte) (*Response, error)

DoRaw sends rawBody verbatim — caller is responsible for any envelope wrapping.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query url.Values, out interface{}) error

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body, out interface{}) error

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body, out interface{}) error

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
	Help    string `json:"help,omitempty"`
}

type NextPage

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

type Response

type Response struct {
	Data     json.RawMessage `json:"data"`
	NextPage *NextPage       `json:"next_page,omitempty"`
}

Jump to

Keyboard shortcuts

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