-
Notifications
You must be signed in to change notification settings - Fork 8
/
sms.go
394 lines (333 loc) · 11.4 KB
/
sms.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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
package models
import (
"bytes"
)
type SMSDestination struct {
MessageID string `json:"messageId"`
To string `json:"to" validate:"required"`
}
type SMSLanguage struct {
LanguageCode string `json:"languageCode"`
}
type SMSTime struct {
Hour int `json:"hour"`
Minute int `json:"minute"`
}
type SMSDeliveryTimeWindow struct {
Days []string `json:"days" validate:"required,min=1"`
From SMSTime `json:"from,omitempty"`
To SMSTime `json:"to,omitempty"`
}
type SMSMsg struct {
CallbackData string `json:"callbackData,omitempty"`
DeliveryTimeWindow *SMSDeliveryTimeWindow `json:"deliveryTimeWindow,omitempty"`
Destinations []SMSDestination `json:"destinations" validate:"required,min=1,dive"`
Flash bool `json:"flash,omitempty"`
From string `json:"from"`
IntermediateReport bool `json:"intermediateReport,omitempty"`
Language *SMSLanguage `json:"language,omitempty"`
NotifyContentType string `json:"notifyContentType,omitempty"`
NotifyURL string `json:"notifyUrl,omitempty"`
Regional *SMSRegional `json:"regional,omitempty"`
SendAt string `json:"sendAt,omitempty"`
Text string `json:"text"`
Transliteration string `json:"transliteration,omitempty"`
ValidityPeriod int `json:"validityPeriod,omitempty"`
}
func (s *SMSMsg) Validate() error {
return validate.Struct(s)
}
func (s *SMSMsg) Marshal() (*bytes.Buffer, error) {
return marshalJSON(s)
}
type SMSTracking struct {
BaseURL string `json:"baseUrl"`
Track string `json:"track"`
Type string `json:"type" validate:"oneof=ONE_TIME_PIN SOCIAL_INVITES"`
ProcessKey string `json:"processKey"`
}
type SMSSendingSpeedLimit struct {
Amount int `json:"amount" validate:"required"`
TimeUnit string `json:"timeUnit" validate:"oneof=MINUTE HOUR DAY"`
}
type SendSMSRequest struct {
BulkID string `json:"bulkId"`
Messages []SMSMsg `json:"messages" validate:"required,min=1,dive"`
SendingSpeedLimit *SMSSendingSpeedLimit `json:"sendingSpeedLimit,omitempty"`
Tracking *SMSTracking `json:"tracking,omitempty"`
}
func (s *SendSMSRequest) Validate() error {
return validate.Struct(s)
}
func (s *SendSMSRequest) Marshal() (*bytes.Buffer, error) {
return marshalJSON(s)
}
type SMSStatus struct {
Action string `json:"action"`
Description string `json:"description"`
GroupID int `json:"groupId"`
GroupName string `json:"groupName"`
ID int `json:"id"`
Name string `json:"name"`
}
type SMSPrice struct {
PricePerMessage float64 `json:"pricePerMessage"`
Currency string `json:"currency"`
}
type SendSMSResponse struct {
BulkID string `json:"bulkId"`
Messages []struct {
MessageID string `json:"messageId"`
Status *SMSStatus `json:"status"`
To string `json:"to"`
} `json:"messages"`
}
type GetSMSDeliveryReportsParams struct {
BulkID string
MessageID string
Limit int
}
func (g *GetSMSDeliveryReportsParams) Validate() error {
return validate.Struct(g)
}
type SMSError struct {
Description string `json:"description"`
GroupID int `json:"groupId"`
GroupName string `json:"groupName"`
ID int `json:"id"`
Name string `json:"name"`
Permanent bool `json:"permanent"`
}
type GetSMSDeliveryReportsResponse struct {
Results []struct {
BulkID string `json:"bulkId"`
CallbackData string `json:"callbackData"`
DoneAt string `json:"doneAt"`
Error SMSError `json:"error"`
From string `json:"from"`
MccMnc string `json:"mccMnc"`
MessageID string `json:"messageId"`
Price SMSPrice `json:"price"`
SentAt string `json:"sentAt"`
SmsCount int `json:"smsCount"`
Status SMSStatus `json:"status"`
To string `json:"to"`
} `json:"results"`
}
type GetSMSLogsResponse struct {
Results []struct {
BulkID string `json:"bulkId"`
MessageID string `json:"messageId"`
To string `json:"to"`
From string `json:"from"`
Text string `json:"text"`
SentAt string `json:"sentAt"`
DoneAt string `json:"doneAt"`
SmsCount int `json:"smsCount"`
MccMnc string `json:"mccMnc"`
Price SMSPrice `json:"price"`
Status SMSStatus `json:"status"`
Error SMSError `json:"error"`
} `json:"results"`
}
type GetSMSLogsParams struct {
From string
To string
BulkID []string
MessageID []string
GeneralStatus string `validate:"omitempty,oneof=ACCEPTED PENDING UNDELIVERABLE DELIVERED REJECTED EXPIRED"`
SentSince string
SentUntil string
Limit int `validate:"omitempty,min=1,max=1000"`
MCC string
MNC string
}
func (g *GetSMSLogsParams) Validate() error {
return validate.Struct(g)
}
type SMSBinary struct {
Hex string `json:"hex" validate:"required"`
DataCoding int `json:"dataCoding"`
EsmClass int `json:"esmClass"`
}
type IndiaDLT struct {
ContentTemplateID string `json:"contentTemplateId"`
PrincipalEntityID string `json:"principalEntityId" validate:"required"`
}
type SMSRegional struct {
IndiaDLT `json:"indiaDlt"`
}
type BinarySMSMsg struct {
From string `json:"from"`
Destinations []SMSDestination `json:"destinations" validate:"min=1,dive"`
Binary *SMSBinary `json:"binary"`
IntermediateReport bool `json:"intermediateReport,omitempty"`
NotifyURL string `json:"notifyUrl,omitempty"`
NotifyContentType string `json:"notifyContentType,omitempty"`
CallbackData string `json:"callbackData,omitempty"`
ValidityPeriod int `json:"validityPeriod,omitempty"`
SendAt string `json:"sendAt,omitempty"`
DeliveryTimeWindow *SMSDeliveryTimeWindow `json:"deliveryTimeWindow,omitempty"`
Regional *SMSRegional `json:"regional,omitempty"`
}
func (b *BinarySMSMsg) Validate() error {
return validate.Struct(b)
}
func (b *BinarySMSMsg) Marshal() (*bytes.Buffer, error) {
return marshalJSON(b)
}
type SendBinarySMSRequest struct {
BulkID string `json:"bulkId"`
Messages []BinarySMSMsg `json:"messages" validate:"required,min=1,dive"`
*SMSSendingSpeedLimit `json:"sendingSpeedLimit,omitempty"`
}
func (s *SendBinarySMSRequest) Validate() error {
return validate.Struct(s)
}
func (s *SendBinarySMSRequest) Marshal() (*bytes.Buffer, error) {
return marshalJSON(s)
}
type SendBinarySMSResponse struct {
BulkID string `json:"bulkId"`
Messages []struct {
To string `json:"to"`
Status SMSStatus `json:"status"`
MessageID string `json:"messageId"`
} `json:"messages"`
}
type SendSMSOverQueryParamsParams struct {
Username string `validate:"required"`
Password string `validate:"required"`
BulkID string
From string
To []string `validate:"required"`
Text string
Flash bool
Transliteration string
LanguageCode string
IntermediateReport bool
NotifyURL string
NotifyContentType string
CallbackData string
ValidityPeriod int
SendAt string
Track string
ProcessKey string
TrackingType string
IndiaDLTContentTemplateID string
IndiaDLTPrincipalEntityID string
}
func (s *SendSMSOverQueryParamsParams) Validate() error {
return validate.Struct(s)
}
type SendSMSOverQueryParamsResponse struct {
BulkID string `json:"bulkId"`
Messages []struct {
MessageID string `json:"messageId"`
Status SMSStatus `json:"status,omitempty"`
To string `json:"to"`
} `json:"messages"`
}
type PreviewSMSRequest struct {
LanguageCode string `json:"languageCode,omitempty" validate:"omitempty,oneof=TR ES PT AUTODETECT"`
Text string `json:"text" validate:"required"`
Transliteration string `json:"transliteration,omitempty" validate:"omitempty,oneof=TURKISH GREEK CYRILLIC SERBIAN_CYRILLIC CENTRAL_EUROPEAN BALTIC NON_UNICODE"` //nolint:lll
}
func (r *PreviewSMSRequest) Validate() error {
return validate.Struct(r)
}
func (r *PreviewSMSRequest) Marshal() (*bytes.Buffer, error) {
return marshalJSON(r)
}
type PreviewSMSResponse struct {
OriginalText string `json:"originalText"`
Previews []struct {
CharactersRemaining int `json:"charactersRemaining"`
Configuration struct {
Language SMSLanguage `json:"language"`
Transliteration string `json:"transliteration"`
} `json:"configuration"`
MessageCount int `json:"messageCount"`
TextPreview string `json:"textPreview"`
} `json:"previews"`
}
type GetInboundSMSParams struct {
Limit int `validate:"omitempty,min=1,max=1000"`
}
func (g *GetInboundSMSParams) Validate() error {
return validate.Struct(g)
}
type GetInboundSMSResponse struct {
MessageCount int `json:"messageCount"`
PendingMessageCount int `json:"pendingMessageCount"`
Results []struct {
CallbackData string `json:"callbackData"`
CleanText string `json:"cleanText"`
From string `json:"from"`
Keyword string `json:"keyword"`
MessageID string `json:"messageId"`
Price SMSPrice `json:"price"`
ReceivedAt string `json:"receivedAt"`
SmsCount int `json:"smsCount"`
Text string `json:"text"`
To string `json:"to"`
} `json:"results"`
}
type GetScheduledSMSParams struct {
BulkID string `validate:"required"`
}
func (g *GetScheduledSMSParams) Validate() error {
return validate.Struct(g)
}
type GetScheduledSMSResponse struct {
BulkID string `json:"bulkId"`
SendAt string `json:"sendAt"`
}
type RescheduleSMSParams struct {
BulkID string `json:"bulkId" validate:"required"`
}
func (r *RescheduleSMSParams) Validate() error {
return validate.Struct(r)
}
type RescheduleSMSRequest struct {
SendAt string `json:"sendAt" validate:"required"`
}
func (r *RescheduleSMSRequest) Validate() error {
return validate.Struct(r)
}
func (r *RescheduleSMSRequest) Marshal() (*bytes.Buffer, error) {
return marshalJSON(r)
}
type RescheduleSMSResponse struct {
BulkID string `json:"bulkId"`
SendAt string `json:"sendAt"`
}
type GetScheduledSMSStatusParams struct {
BulkID string `json:"bulkId" validate:"required"`
}
func (g *GetScheduledSMSStatusParams) Validate() error {
return validate.Struct(g)
}
type GetScheduledSMSStatusResponse struct {
BulkID string `json:"bulkId"`
Status string `json:"status"`
}
type UpdateScheduledSMSStatusParams struct {
BulkID string `json:"bulkId" validate:"required"`
}
func (u *UpdateScheduledSMSStatusParams) Validate() error {
return validate.Struct(u)
}
type UpdateScheduledSMSStatusRequest struct {
Status string `json:"status" validate:"required,oneof=PENDING PAUSED PROCESSING CANCELED FINISHED FAILED"`
}
func (u *UpdateScheduledSMSStatusRequest) Validate() error {
return validate.Struct(u)
}
func (u *UpdateScheduledSMSStatusRequest) Marshal() (*bytes.Buffer, error) {
return marshalJSON(u)
}
type UpdateScheduledSMSStatusResponse struct {
BulkID string `json:"bulkId"`
Status string `json:"status"`
}