Documentation ¶
Overview ¶
Package mailjet provides methods for interacting with the last version of the Mailjet API. The goal of this component is to simplify the usage of the MailJet API for GO developers.
For more details, see the full API Documentation at http://dev.mailjet.com/
Index ¶
- Constants
- Variables
- func SetDebugOutput(w io.Writer)
- type Attachment
- type Client
- func (c *Client) APIKeyPrivate() string
- func (c *Client) APIKeyPublic() string
- func (c *Client) Client() *http.Client
- func (mj *Client) Delete(mr *Request) (err error)
- func (mj *Client) DeleteData(mdr *DataRequest) (err error)
- func (mj *Client) Get(mr *Request, resp interface{}, options ...RequestOptions) (err error)
- func (mj *Client) GetData(mdr *DataRequest, res interface{}, options ...RequestOptions) (err error)
- func (c *Client) List(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error)
- func (mj *Client) ListData(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error)
- func (mj *Client) Post(fmr *FullRequest, resp interface{}, options ...RequestOptions) (err error)
- func (mj *Client) PostData(fmdr *FullDataRequest, res interface{}, options ...RequestOptions) (err error)
- func (mj *Client) Put(fmr *FullRequest, onlyFields []string, options ...RequestOptions) (err error)
- func (mj *Client) PutData(fmr *FullDataRequest, onlyFields []string, options ...RequestOptions) (err error)
- func (mj *Client) SendMail(data *InfoSendMail) (res *SentResult, err error)
- func (mj *Client) SendMailSMTP(info *InfoSMTP) (err error)
- func (c *Client) SetClient(client *http.Client)
- type DataRequest
- type FullDataRequest
- type FullRequest
- type InfoSMTP
- type InfoSendMail
- type Recipient
- type Request
- type RequestError
- type RequestOptions
- type RequestResult
- type SentResult
- type SortOrder
Constants ¶
const ( LevelNone = iota // No debug. LevelDebug // Debug without body. LevelDebugFull // Debug with body. )
These are the different level of debug.
const ( UserAgentBase = "mailjet-api-v3-go" UserAgentVersion = "2.0.1" )
User-Agent is formated as "UserAgentBase/UserAgentVersion;runtime.Version()".
const ( SortDesc = SortOrder(iota) SortAsc )
These are the two possible order.
const ( HostSMTP = "in-v3.mailjet.com" PortSMTP = 587 )
Hostname and port for the SMTP client.
Variables ¶
var DebugLevel int
DebugLevel defines the verbosity of the debug.
var NbAttempt = 5
NbAttempt defines the number of attempt for a request as long as StatusCode == 500.
Functions ¶
func SetDebugOutput ¶
SetDebugOutput sets the output destination for the debug.
Types ¶
type Attachment ¶
Attachment bundles data on the file attached to the mail.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client bundles data needed by a large number of methods in order to interact with the Mailjet API.
func NewMailjetClient ¶
NewMailjetClient returns a new MailjetClient using an public apikey and an secret apikey to be used when authenticating to API.
func (*Client) APIKeyPrivate ¶
APIKeyPrivate returns the secret key.
func (*Client) APIKeyPublic ¶
APIKeyPublic returns the public key.
func (*Client) DeleteData ¶
func (mj *Client) DeleteData(mdr *DataRequest) (err error)
DeleteData is used to delete a data resource.
func (*Client) Get ¶
func (mj *Client) Get(mr *Request, resp interface{}, options ...RequestOptions) (err error)
Get issues a GET to view a resource specifying an id and stores the result in the value pointed to by res. Filters can be add via functional options. Without an specified ID in MailjetRequest, it is the same as List.
func (*Client) GetData ¶
func (mj *Client) GetData(mdr *DataRequest, res interface{}, options ...RequestOptions) (err error)
GetData issues a GET to view a resource specifying an id and stores the result in the value pointed to by res. Filters can be add via functional options. Without an specified SourceTypeID in MailjetDataRequest, it is the same as ListData.
func (*Client) List ¶
func (c *Client) List(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error)
List issues a GET to list the specified resource and stores the result in the value pointed to by res. Filters can be add via functional options.
func (*Client) ListData ¶
func (mj *Client) ListData(resource string, resp interface{}, options ...RequestOptions) (count, total int, err error)
ListData issues a GET to list the specified data resource and stores the result in the value pointed to by res. Filters can be add via functional options.
func (*Client) Post ¶
func (mj *Client) Post(fmr *FullRequest, resp interface{}, options ...RequestOptions) (err error)
Post issues a POST to create a new resource and stores the result in the value pointed to by res. Filters can be add via functional options.
func (*Client) PostData ¶
func (mj *Client) PostData(fmdr *FullDataRequest, res interface{}, options ...RequestOptions) (err error)
PostData issues a POST to create a new data resource and stores the result in the value pointed to by res. Filters can be add via functional options.
func (*Client) Put ¶
func (mj *Client) Put(fmr *FullRequest, onlyFields []string, options ...RequestOptions) (err error)
Put is used to update a resource. Fields to be updated must be specified by the string array onlyFields. If onlyFields is nil, all fields except these with the tag read_only, are updated. Filters can be add via functional options.
func (*Client) PutData ¶
func (mj *Client) PutData(fmr *FullDataRequest, onlyFields []string, options ...RequestOptions) (err error)
PutData is used to update a data resource. Fields to be updated must be specified by the string array onlyFields. If onlyFields is nil, all fields except these with the tag read_only, are updated. Filters can be add via functional options.
func (*Client) SendMail ¶
func (mj *Client) SendMail(data *InfoSendMail) (res *SentResult, err error)
SendMail send mail via API.
func (*Client) SendMailSMTP ¶
SendMailSMTP send mail via SMTP.
type DataRequest ¶
type DataRequest struct { SourceType string SourceTypeID int64 DataType string MimeType string DataTypeID int64 LastID bool }
DataRequest bundles data needed to build the DATA URL.
type FullDataRequest ¶
type FullDataRequest struct { Info *DataRequest Payload interface{} }
FullDataRequest is the same as a DataRequest but with a payload.
type FullRequest ¶
type FullRequest struct { Info *Request Payload interface{} }
FullRequest is the same as a Request but with a payload.
type InfoSMTP ¶
type InfoSMTP struct { From string Recipients []string Header textproto.MIMEHeader Content []byte }
InfoSMTP contains mandatory informations to send a mail via SMTP.
type InfoSendMail ¶
type InfoSendMail struct { FromEmail string FromName string Sender string `json:",omitempty"` Recipients []Recipient `json:",omitempty"` To string `json:",omitempty"` Cc string `json:",omitempty"` Bcc string `json:",omitempty"` Subject string TextPart string `json:"Text-part,omitempty"` HTMLPart string `json:"Html-part,omitempty"` Attachments []Attachment `json:",omitempty"` InlineAttachments []Attachment `json:"Inline_attachments,omitempty"` MjPrio int `json:"Mj-prio,omitempty"` MjCampaign string `json:"Mj-campaign,omitempty"` MjDeduplicateCampaign bool `json:"Mj-deduplicatecampaign,omitempty"` MjCustomID string `json:"Mj-CustomID,omitempty"` MjTemplateID string `json:"Mj-TemplateID,omitempty"` MjTemplateErrorReporting string `json:"MJ-TemplateErrorReporting,omitempty"` MjTemplateLanguage string `json:"Mj-TemplateLanguage,omitempty"` MjTemplateErrorDeliver string `json:"MJ-TemplateErrorDeliver,omitempty"` MjEventPayLoad string `json:"Mj-EventPayLoad,omitempty"` Headers map[string]string `json:",omitempty"` Vars interface{} `json:",omitempty"` Messages []InfoSendMail `json:",omitempty"` }
InfoSendMail bundles data used by the Send API.
type RequestError ¶
RequestError is the error returned by the API.
type RequestOptions ¶
RequestOptions are functional options that modify the specified request.
func Filter ¶
func Filter(key, value string) RequestOptions
Filter applies a filter with the defined key and value.
func Sort ¶
func Sort(value string, order SortOrder) RequestOptions
Sort applies the Sort filter to the request.
type RequestResult ¶
RequestResult is the JSON result sent by the API.
type SentResult ¶
SentResult is the JSON result sent by the Send API.