forked from iqquee/zeptomail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
367 lines (304 loc) · 13.2 KB
/
models.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
package zeptomail
type (
// ErrorResponse is an object for errors
ErrorResponse struct {
// It consists of code, details, message, and request_id parameters
Error map[string]interface{} `json:"error"`
// The code corresponding to the status of the request made
Code string `json:"code"`
// It consists of code, message and target parameters
Details interface{} `json:"details"`
// Reason for the error
Message string `json:"message"`
// The field that caused the error
Target string `json:"target"`
// A unique id which is generated for every request
RequestId string `json:"request_id"`
// A unique id which is generated for every request
TargetValue string `json:"target_value"`
}
// SendHTMLEmailReq is the SendHTMLEmail() request object
SendHTMLEmailReq struct {
From EmailAddress `json:"from" validate:"required"`
To []SendEmailTo `json:"to" validate:"required"`
Subject string `json:"subject" validate:"required"`
Htmlbody string `json:"htmlbody" validate:"required"`
}
// SendHTMLEmailRes is the SendHTMLEmail() response object
SendHTMLEmailRes struct {
Data []SendEmailResData `json:"data"`
Message string `json:"message"`
RequestId string `json:"request_id"`
Object string `json:"object"`
}
// SendEmailResData is the Data object for the SendHTMLEmailRes object
SendEmailResData struct {
Code string `json:"code"`
AdditionalInfo []interface{} `json:"additional_info"`
Message string `json:"message"`
}
// SendTemplatedEmailReq is the SendTemplatedEmail() request object
SendTemplatedEmailReq struct {
/*
Unique key identifier for your template.
template_alias is the alias name given to the template key. It can be used in the place of template_key.
*/
TemplateKey string `json:"template_key" validate:"required"`
/*
The email address to which bounced emails will be sent.
Allowed value - A valid bounce email address as configured in your Mail Agent.
*/
BounceAddress string `json:"bounce_address"`
// Allowed value - A valid sender email address with "address" and "name" key-value pairs
From EmailAddress `json:"from" validate:"required"`
// Allowed value - JSON object of email_address.
To []SendEmailTo `json:"to" validate:"required"`
/*
You can use merge tags to replace the placeholders with multiple values for different recipients. The merge tags of the mail to be sent. Merge Tags can be set in HTML body, text body, subject and client reference.
Merge tags are tags that are set in the string.
These tags will be replaced by the value provided in this param for that tag.
In the case of single email API, the merge tag is common for all recipients. Whereas in the case of batch emails, the merge tag is specific to each recipient.
*/
MergeInfo map[string]interface{} `json:"merge_info" validate:"required"`
// Allowed value - JSON object of reply_to email addresses.
ReplyTo EmailAddress `json:"reply_to"`
/*
You can enable or disable email click tracking here.
You can also enable email click tracking in your Mail Agent under Email Tracking section.
Note: The API setting will override the Mail Agent settings in your ZeptoMail account.
Allowed value
True - Enable email click tracking.
False - Disable email click tracking.
*/
TrackClicks bool `json:"track_clicks"`
/*
You can enable or disable email open tracking.
You can also enable email open tracking in your Mail Agent under Email Tracking section.
Note: The API setting will override the Mail Agent settings in your ZeptoMail account.
Allowed value
True - Enable email open tracking.
False - Disable email open tracking.
*/
TrackOpens bool `json:"track_client_referenceopens"`
// An identifier set by the user to track a particular transaction.
ClientReference string `json:"client_reference"`
// The additional headers to be sent in the email for your reference purposes.
MimeHeaders map[string]interface{} `json:"mime_headers"`
/*
The attachments you want to add to your transactional emails. Visit [https://www.zoho.com/zeptomail/help/file-cache.html#alink-un-sup-for] to view the list of unsupported formats.
Allowed value - JSON object of attachments.
It can either be a base64 encoded content or file_cache_key or both.
*/
Attachments []struct {
/*
The content of your attachment.
Allowed value - Base64 encoded value of a file.
*/
Content string `json:"content"`
/*
Indicates the content type in your attachment.
Allowed value
simple text message - plain / text
image file - image / jpg
*/
MimeType string `json:"mime_type"`
/*
he file name of your attachment as in the File Cache section in your Mail Agent.
Obtain file name from the File Cache section in your Mail Agent.
*/
Name string `json:"name"`
/*
The unique key for your attached files in a Mail Agent.
Obtain file_cache_key from the File Cache section in your Mail Agent.
*/
FileCacheKey string `json:"file_cache_key"`
/*
the content id used by html body for content lookup. Each content should be given a separate cid value.
Allowed value
It can either a base64 encoded content or a file_cache_key or both.
*/
Cid string `json:"cid"`
} `json:"attachments"`
}
// SendEmailTo is the object for recipient email
SendEmailTo struct {
// A valid recipient email address with "address" and "name" key-value pairs.
EmailAddress EmailAddress `json:"email_address" validate:"required"`
}
// SendBatchTemplateEmailTo is the object for send batch recipient emails
SendBatchTemplateEmailTo struct {
// A valid recipient email address with "address" and "name" key-value pairs.
EmailAddress EmailAddress `json:"email_address" validate:"required"`
/*
You can use merge tags to replace the placeholders with multiple values for different recipients. The merge tags of the mail to be sent. Merge Tags can be set in HTML body, text body, subject and client reference.
Merge tags are tags that are set in the string.
These tags will be replaced by the value provided in this param for that tag.
In the case of single email API, the merge tag is common for all recipients. Whereas in the case of batch emails, the merge tag is specific to each recipient.
*/
MergeInfo map[string]interface{} `json:"merge_info" validate:"required"`
}
// EmailAddress is an email address object
EmailAddress struct {
/*
The email address to which the recipient's email responses will be addressed.
Allowed value - A valid email address containing a domain that is verified in your Mail Agent.
*/
Address string `json:"address" validate:"required"`
// Recipient's name.
Name string `json:"name" validate:"required"`
}
// SendTemplatedEmailRes is the SendTemplatedEmail() response object
SendTemplatedEmailRes struct {
Data []struct {
Code string `json:"code"`
AdditionalInfo []interface{} `json:"additional_info"`
Message string `json:"message"`
} `json:"data"`
Message string `json:"message"`
RequestId string `json:"request_id"`
Object string `json:"object"`
}
// SendBatchTemplatedEmailReq is the SendBatchTemplatedEmail() request object
SendBatchTemplatedEmailReq struct {
/*
Unique key identifier for your template.
template_alias is the alias name given to the template key. It can be used in the place of template_key.
*/
TemplateKey string `json:"template_key" validate:"required"`
/*
The email address to which bounced emails will be sent.
Allowed value - A valid bounce email address as configured in your Mail Agent.
*/
BounceAddress string `json:"bounce_address"`
// Allowed value - A valid sender email address with "address" and "name" key-value pairs
From EmailAddress `json:"from" validate:"required"`
// Allowed value - JSON object of email_address.
To []SendBatchTemplateEmailTo `json:"to" validate:"required"`
// Allowed value - JSON object of reply_to email addresses.
ReplyTo EmailAddress `json:"reply_to"`
/*
You can enable or disable email click tracking here.
You can also enable email click tracking in your Mail Agent under Email Tracking section.
Note: The API setting will override the Mail Agent settings in your ZeptoMail account.
Allowed value
True - Enable email click tracking.
False - Disable email click tracking.
*/
TrackClicks bool `json:"track_clicks"`
/*
You can enable or disable email open tracking.
You can also enable email open tracking in your Mail Agent under Email Tracking section.
Note: The API setting will override the Mail Agent settings in your ZeptoMail account.
Allowed value
True - Enable email open tracking.
False - Disable email open tracking.
*/
TrackOpens bool `json:"track_client_referenceopens"`
// An identifier set by the user to track a particular transaction.
ClientReference string `json:"client_reference"`
// The additional headers to be sent in the email for your reference purposes.
MimeHeaders map[string]interface{} `json:"mime_headers"`
/*
The attachments you want to add to your transactional emails. Visit [https://www.zoho.com/zeptomail/help/file-cache.html#alink-un-sup-for] to view the list of unsupported formats.
Allowed value - JSON object of attachments.
It can either be a base64 encoded content or file_cache_key or both.
*/
Attachments []struct {
/*
The content of your attachment.
Allowed value - Base64 encoded value of a file.
*/
Content string `json:"content"`
/*
Indicates the content type in your attachment.
Allowed value
simple text message - plain / text
image file - image / jpg
*/
MimeType string `json:"mime_type"`
/*
he file name of your attachment as in the File Cache section in your Mail Agent.
Obtain file name from the File Cache section in your Mail Agent.
*/
Name string `json:"name"`
/*
The unique key for your attached files in a Mail Agent.
Obtain file_cache_key from the File Cache section in your Mail Agent.
*/
FileCacheKey string `json:"file_cache_key"`
/*
the content id used by html body for content lookup. Each content should be given a separate cid value.
Allowed value
It can either a base64 encoded content or a file_cache_key or both.
*/
Cid string `json:"cid"`
} `json:"attachments"`
}
// AddEmailTemplateReq is the AddEmailTemplate() response object
AddEmailTemplateReq struct {
// Name of the template
TemplateName string `json:"template_name" validate:"required"`
// Subject to be added in the email template.
Subject string `json:"subject" validate:"required"`
// The corresponding HTML content of the body in the email template.
HtmlBody string `json:"htmlbody"`
// Plain text body of the email in the template.
TextBody string `json:"textbody"`
// Unique alias for the template. It can be used instead of the template key. It can be obtained from the Edit template section in your ZeptoMail account.
TemplateAlias string `json:"template_alias"`
// Unique alias value given to the Mail Agent. It is available in the Setup info section of your Mail Agent.
MailagentAlias string `json:"_" validate:"required"`
}
// AddEmailTemplateRes is the AddEmailTemplate() request object
AddEmailTemplateRes struct {
Data []struct {
HtmlBody string `json:"htmlbody"`
UploadTime string `json:"upload_time"`
Template_name string `json:"template_name"`
Template_key string `json:"template_key"`
Template_size int `json:"template_size"`
Modified_time string `json:"modified_time"`
Subject string `json:"subject"`
} `json:"data"`
Message string `json:"message"`
Object string `json:"object"`
}
// UpdateEmailTemplateReq is the UpdateEmailTemplate() response object
UpdateEmailTemplateReq struct {
// Name of the template
TemplateName string `json:"template_name" validate:"required"`
// Subject to be added in the email template.
Subject string `json:"subject" validate:"required"`
// The corresponding HTML content of the body in the email template.
HtmlBody string `json:"htmlbody"`
// Plain text body of the email in the template.
TextBody string `json:"textbody"`
// TemplateKey is the template key.
TemplateKey string `json:"" validate:"required"`
// Unique alias value given to the Mail Agent. It is available in the Setup info section of your Mail Agent.
MailagentAlias string `json:"" validate:"required"`
}
// GetEmailTemplateReq is the GetEmailTemplate() response object
GetEmailTemplateReq struct {
Data struct {
HtmlBody string `json:"htmlbody"`
CreatedTime string `json:"created_time"`
TemplateName string `json:"template_name"`
TemplateKey string `json:"template_key"`
ModifiedTime string `json:"modified_time"`
Attachments []struct {
FileCacheKey string `json:"file_cache_key"`
ContentType string `json:"content_type"`
FileName string `json:"file_name"`
} `json:"attachments"`
Subject string `json:"subject"`
TemplateAlias string `json:"template_alias"`
SampleMergeInfo struct {
Name string `json:"name"`
Link string `json:"link"`
} `json:"sample_merge_info"`
} `json:"data"`
Message string `json:"message"`
Object string `json:"object"`
}
)