client

package
v0.0.0-...-f05d2e9 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2015 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserError

func UserError(err error) usererrors.UserError

UserError returns the underlying UserError returned by the client request if the error was generated from a UserError response. Otherwise, it returns nil.

Types

type Client

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

func New

func New(baseURL *url.URL, httpClient *http.Client) *Client

func (*Client) Authorize

func (c *Client) Authorize() error

func (*Client) CreateConversation

func (c *Client) CreateConversation(convo *say.Conversation) error

func (*Client) CreateLine

func (c *Client) CreateLine(convoID string, line *say.Line) error

func (*Client) CreateUser

func (c *Client) CreateUser() (*auth.User, error)

func (*Client) DeleteConversation

func (c *Client) DeleteConversation(id string) error

func (*Client) DeleteLine

func (c *Client) DeleteLine(convoID, lineID string) error

func (*Client) DeleteMood

func (c *Client) DeleteMood(name string) error

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON-decoded and stored in the value pointed to by v. If a known usererror response is returned, the error will be a UserError with the correct underlying type.

func (*Client) GetAnimals

func (c *Client) GetAnimals() ([]string, error)

func (*Client) GetConversation

func (c *Client) GetConversation(id string) (*say.Conversation, error)

func (*Client) GetLine

func (c *Client) GetLine(convoID, lineID string) (*say.Line, error)

func (*Client) GetMood

func (c *Client) GetMood(name string) (*say.Mood, error)

func (*Client) ListConversations

func (c *Client) ListConversations(params ListParams) *ConversationIter

func (*Client) ListMoods

func (c *Client) ListMoods(params ListParams) *MoodIter

func (*Client) NewRequest

func (c *Client) NewRequest(rt Route, rtVars Vars, form *url.Values) (*http.Request, error)

func (*Client) SetAuthorization

func (c *Client) SetAuthorization(auth string)

func (*Client) SetMood

func (c *Client) SetMood(mood *say.Mood) error

func (*Client) UserExists

func (c *Client) UserExists(id string) (bool, error)

type ConversationIter

type ConversationIter struct {
	*Iter
}

ConversationIter is an iterator for lists of Conversations. The embedded Iter carries methods with it; see its documentation for details.

func (*ConversationIter) Conversation

func (it *ConversationIter) Conversation() say.Conversation

Conversation returns the most recent Conversation visited by a call to Next.

type Iter

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

func (*Iter) Current

func (it *Iter) Current() interface{}

Current returns the most recent item visited by a call to Next.

func (*Iter) Err

func (it *Iter) Err() error

Err returns the error, if any, that caused the Iter to stop. It must be inspected after Next returns false.

func (*Iter) Next

func (it *Iter) Next() bool

Next advances the Iter to the next item in the list, which will then be available through the Current method. It returns false when the iterator stops at the end of the list or an error is encountered.

type ListParams

type ListParams struct {
	After  string `url:"ending_after"`
	Before string `url:"starting_before"`
	Limit  int
}

type MoodIter

type MoodIter struct {
	*Iter
}

MoodIter is an iterator for lists of Moods. The embedded Iter carries methods with it; see its documentation for details.

func (*MoodIter) Mood

func (it *MoodIter) Mood() say.Mood

Mood returns the most recent Mood visited by a call to Next.

type Route

type Route interface {
	// HTTPMethods must return exactly one method unless the additional
	// methodsa are only one of OPTIONS and HEAD.
	HTTPMethods() map[string]struct{}

	// URLPath should return the correct path for an API route
	// given a complete list of path variables.
	URLPath(map[pattern.Variable]string) (string, error)
}

Route describes an API route for building client requests

type TestClient

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

func NewTestClient

func NewTestClient(cfg *app.Configuration) (*TestClient, error)

NewTestClient initializes a TestClient instance with an embedded copy of the app. This will modify your passed Configuration to incorporate testing default values. For non-stub configurations, this will initialize a new database and store the DSN in the Configuration.

func (*TestClient) Close

func (c *TestClient) Close() error

type Vars

type Vars interface {
	Vars() map[pattern.Variable]string
}

Vars emits a mapping from path variable names to values for constructing a URL path with Route.URLPath.

Jump to

Keyboard shortcuts

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