mailgun

package module
Version: v0.0.0-...-b886059 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2015 License: MPL-2.0 Imports: 8 Imported by: 173

README

mailgun

This package provides the mailgun package which offers an interface to the Mailgun V2 API.

It's intentionally designed to make heavy use of built-ins and strings in place of custom data structures and proper types. It also only implements specific endpoints, and doesn't have full API coverage.

For those reasons, I recommend looking elsewhere if you just need a standard mailgun API client.

Documentation

The full documentation is available on Godoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Authentication key
	ApiKey string

	// URL to the API to use
	URL string

	// HttpClient is the client to use. Default will be
	// used if not provided.
	Http *http.Client
}

Client provides a client to the Mailgun API

func NewClient

func NewClient(key string) (*Client, error)

NewClient returns a new mailgun client, requires an api key.

func (*Client) CreateDomain

func (c *Client) CreateDomain(opts *CreateDomain) (string, error)

CreateDomain creates a domain from the parameters specified and returns an error if it fails. If no error and the name is returned, the Domain was succesfully created.

func (*Client) DestroyDomain

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

DestroyDomain destroys a domain by the ID specified and returns an error if it fails. If no error is returned, the Domain was succesfully destroyed.

func (*Client) NewRequest

func (c *Client) NewRequest(params map[string]string, method string, endpoint string) (*http.Request, error)

Creates a new request with the params

func (*Client) RetrieveDomain

func (c *Client) RetrieveDomain(name string) (DomainResponse, error)

RetrieveDomain gets a domain and records by the ID specified and returns a DomainResponse and an error. An error will be returned for failed requests with a nil DomainResponse.

type CreateDomain

type CreateDomain struct {
	Name         string // Name of the domain
	SmtpPassword string
	SpamAction   string // one of disabled or tag
	Wildcard     bool
}

CreateDomain contains the request parameters to create a new domain.

type Domain

type Domain struct {
	Name         string `json:"name"`
	SmtpLogin    string `json:"smtp_login"`
	SmtpPassword string `json:"smtp_password"`
	SpamAction   string `json:"spam_action"`
	Wildcard     bool   `json:"wildcard"`
}

Domain is used to represent a retrieved Domain. All properties are set as strings.

func (*Domain) StringWildcard

func (d *Domain) StringWildcard() string

type DomainResponse

type DomainResponse struct {
	Domain           Domain            `json:"domain"`
	SendingRecords   []SendingRecord   `json:"sending_dns_records"`
	ReceivingRecords []ReceivingRecord `json:"receiving_dns_records"`
}

type MailgunError

type MailgunError struct {
	Message string `json:"message"`
}

MailgunError is the error format that they return to us if there is a problem

type ReceivingRecord

type ReceivingRecord struct {
	Priority   string `json:"priority"`
	RecordType string `json:"record_type"`
	Valid      string `json:"valid"`
	Value      string `json:"value"`
}

type SendingRecord

type SendingRecord struct {
	Name       string `json:"name"`
	RecordType string `json:"record_type"`
	Valid      string `json:"valid"`
	Value      string `json:"value"`
}

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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