client

package
v0.0.0-...-8c17a97 Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package client is a low-level implementation of a mailgun REST client.

This package is generally not intended for package consumers.

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = false

DEBUG enables debugging - requests logged, response copied to stderr.

Functions

This section is empty.

Types

type Caller

type Caller interface {
	HTTPClient() *http.Client
	Get(uri ...string) *Request
	Post(uri ...string) *Request
	Put(uri ...string) *Request
	Delete(uri ...string) *Request
	Domain() string
	Key() string
}

Caller is the interface to a Requester.

type Error

type Error struct {
	Status     string
	StatusCode int
	fmt.Stringer
}

Error is an HTTP error from the endpoint.

func Err

func Err(e error) *Error

Err returns *Error if e is Error, nil otherwise.

func (Error) Error

func (e Error) Error() string

Error implements error.

type Pager

type Pager interface {
	SetCaller(Caller)
}

Pager is implemented by pager types.

type Request

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

Request is a client request.

func (*Request) AddForm

func (r *Request) AddForm(k, v string) *Request

AddForm adds k,v to form values.

func (*Request) AddHeader

func (r *Request) AddHeader(k, v string) *Request

AddHeader adds a header, returning Request.

func (*Request) AddQuery

func (r *Request) AddQuery(k, v string) *Request

AddQuery adds k,v to query string.

func (*Request) Decode

func (r *Request) Decode(i interface{}) error

Decode decodes the result of performing r to i.

func (*Request) Do

func (r *Request) Do() (*http.Response, error)

Do performs this Request.

func (*Request) Err

func (r *Request) Err() error

Err performs this request, returning any error.

func (*Request) Form

func (r *Request) Form() url.Values

Form returns the url.Values for this Request's form data.

func (*Request) Header

func (r *Request) Header() http.Header

Header returns the http.Header for this Request.

func (*Request) Payload

func (r *Request) Payload(reader io.Reader) *Request

Payload sets the io.Reader for this Request. Precludes Form method.

func (*Request) Query

func (r *Request) Query() url.Values

Query returns the url.Values for this Request's query string.

func (*Request) SetForm

func (r *Request) SetForm(k, v string) *Request

SetForm sets k,v to form values.

func (*Request) SetHeader

func (r *Request) SetHeader(k, v string) *Request

SetHeader sets a header, returning Request.

func (*Request) SetQuery

func (r *Request) SetQuery(k, v string) *Request

SetQuery sets k,v to query string.

type Requester

type Requester struct {
	Endpoint  string
	APIKey    string
	APIDomain string
	*http.Client
}

Requester has methods that return Requests.

func New

func New(endpoint, apikey, apidomain string) *Requester

New turns a new Requester.

func (*Requester) Delete

func (r *Requester) Delete(uri ...string) *Request

Delete returns a DELETE Request.

func (*Requester) Domain

func (r *Requester) Domain() string

Domain returns the API domain.

func (*Requester) Get

func (r *Requester) Get(uri ...string) *Request

Get returns a GET Request.

func (*Requester) HTTPClient

func (r *Requester) HTTPClient() *http.Client

HTTPClient returns the *http.Client associated with this Requester.

func (*Requester) Key

func (r *Requester) Key() string

Key returns the API key.

func (*Requester) Post

func (r *Requester) Post(uri ...string) *Request

Post returns a POST Request.

func (*Requester) Put

func (r *Requester) Put(uri ...string) *Request

Put returns a PUT Request.

Directories

Path Synopsis
Package mock implements a mock client for testing.
Package mock implements a mock client for testing.
Package pager implements the mailgun paging convention.
Package pager implements the mailgun paging convention.

Jump to

Keyboard shortcuts

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