forked from mailjet/mailjet-apiv3-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailjet_resources.go
116 lines (101 loc) · 3.4 KB
/
mailjet_resources.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package mailjet
import "net/http"
/*
** API structures
*/
// Client bundles data needed by a large number
// of methods in order to interact with the Mailjet API.
type Client struct {
apiBase string
client *httpClient
}
// Request bundles data needed to build the URL.
type Request struct {
Resource string
ID int64
AltID string
Action string
ActionID int64
}
// DataRequest bundles data needed to build the DATA URL.
type DataRequest struct {
SourceType string
SourceTypeID int64
DataType string
MimeType string
DataTypeID int64
LastID bool
}
// FullRequest is the same as a Request but with a payload.
type FullRequest struct {
Info *Request
Payload interface{}
}
// FullDataRequest is the same as a DataRequest but with a payload.
type FullDataRequest struct {
Info *DataRequest
Payload interface{}
}
// RequestOptions are functional options that modify the specified request.
type RequestOptions func(*http.Request)
// RequestResult is the JSON result sent by the API.
type RequestResult struct {
Count int
Data interface{}
Total int
}
// RequestError is the error returned by the API.
type RequestError struct {
ErrorInfo string
ErrorMessage string
StatusCode int
}
/*
** Send API structures
*/
// InfoSendMail bundles data used by the Send API.
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"`
}
// Recipient bundles data on the target of the mail.
type Recipient struct {
Email string
Name string
Vars interface{} `json:",omitempty"`
}
// Attachment bundles data on the file attached to the mail.
type Attachment struct {
ContentType string `json:"Content-Type"`
Content string
Filename string
}
// SentResult is the JSON result sent by the Send API.
type SentResult struct {
Sent []struct {
Email string
MessageID int64
}
}