1
|
|
|
package pinpoint |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/pinpoint" |
5
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
6
|
|
|
) |
7
|
|
|
|
8
|
|
|
type AttributeDimension struct { |
|
|
|
|
9
|
|
|
Values []string |
10
|
|
|
|
11
|
|
|
// optional |
12
|
|
|
AttributeType AttributeType |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
func newAttributeDimensionMap(in map[string]SDK.AttributeDimension) map[string]AttributeDimension { |
16
|
|
|
result := make(map[string]AttributeDimension, len(in)) |
17
|
|
|
for key, val := range in { |
18
|
|
|
val := val |
19
|
|
|
result[key] = newAttributeDimension(&val) |
20
|
|
|
} |
21
|
|
|
return result |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
func newAttributeDimension(o *SDK.AttributeDimension) AttributeDimension { |
25
|
|
|
result := AttributeDimension{} |
26
|
|
|
if o == nil { |
27
|
|
|
return result |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
result.Values = o.Values |
31
|
|
|
result.AttributeType = AttributeType(o.AttributeType) |
32
|
|
|
return result |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
func attributeDimensionMapToSDK(in map[string]AttributeDimension) map[string]SDK.AttributeDimension { |
36
|
|
|
result := make(map[string]SDK.AttributeDimension, len(in)) |
37
|
|
|
for key, val := range in { |
38
|
|
|
result[key] = val.ToSDK() |
39
|
|
|
} |
40
|
|
|
return result |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
func (r AttributeDimension) ToSDK() SDK.AttributeDimension { |
|
|
|
|
44
|
|
|
o := SDK.AttributeDimension{} |
45
|
|
|
|
46
|
|
|
o.Values = r.Values |
47
|
|
|
o.AttributeType = SDK.AttributeType(r.AttributeType) |
48
|
|
|
return o |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
type CampaignCustomMessage struct { |
|
|
|
|
52
|
|
|
Data string |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
func newCampaignCustomMessage(o *SDK.CampaignCustomMessage) CampaignCustomMessage { |
56
|
|
|
result := CampaignCustomMessage{} |
57
|
|
|
if o == nil { |
58
|
|
|
return result |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if o.Data != nil { |
62
|
|
|
result.Data = *o.Data |
63
|
|
|
} |
64
|
|
|
return result |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
func (r CampaignCustomMessage) ToSDK() *SDK.CampaignCustomMessage { |
|
|
|
|
68
|
|
|
o := SDK.CampaignCustomMessage{} |
69
|
|
|
|
70
|
|
|
if r.Data != "" { |
71
|
|
|
o.Data = pointers.String(r.Data) |
72
|
|
|
} |
73
|
|
|
return &o |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
type CampaignEmailMessage struct { |
|
|
|
|
77
|
|
|
Body string |
78
|
|
|
FromAddress string |
79
|
|
|
HTMLBody string |
80
|
|
|
Title string |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
func newCampaignEmailMessage(o *SDK.CampaignEmailMessage) CampaignEmailMessage { |
84
|
|
|
result := CampaignEmailMessage{} |
85
|
|
|
if o == nil { |
86
|
|
|
return result |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if o.Body != nil { |
90
|
|
|
result.Body = *o.Body |
91
|
|
|
} |
92
|
|
|
if o.FromAddress != nil { |
93
|
|
|
result.FromAddress = *o.FromAddress |
94
|
|
|
} |
95
|
|
|
if o.HtmlBody != nil { |
96
|
|
|
result.HTMLBody = *o.HtmlBody |
97
|
|
|
} |
98
|
|
|
if o.Title != nil { |
99
|
|
|
result.Title = *o.Title |
100
|
|
|
} |
101
|
|
|
return result |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
func (r CampaignEmailMessage) ToSDK() *SDK.CampaignEmailMessage { |
|
|
|
|
105
|
|
|
o := SDK.CampaignEmailMessage{} |
106
|
|
|
|
107
|
|
|
if r.Body != "" { |
108
|
|
|
o.Body = pointers.String(r.Body) |
109
|
|
|
} |
110
|
|
|
if r.FromAddress != "" { |
111
|
|
|
o.FromAddress = pointers.String(r.FromAddress) |
112
|
|
|
} |
113
|
|
|
if r.HTMLBody != "" { |
114
|
|
|
o.HtmlBody = pointers.String(r.HTMLBody) |
115
|
|
|
} |
116
|
|
|
if r.Title != "" { |
117
|
|
|
o.Title = pointers.String(r.Title) |
118
|
|
|
} |
119
|
|
|
return &o |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
type CampaignEventFilter struct { |
|
|
|
|
123
|
|
|
Dimensions EventDimensions |
124
|
|
|
FilterType FilterType |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
func newCampaignEventFilter(o *SDK.CampaignEventFilter) CampaignEventFilter { |
128
|
|
|
result := CampaignEventFilter{} |
129
|
|
|
if o == nil { |
130
|
|
|
return result |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
result.Dimensions = newEventDimensions(o.Dimensions) |
134
|
|
|
result.FilterType = FilterType(o.FilterType) |
135
|
|
|
return result |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
func (r CampaignEventFilter) ToSDK() *SDK.CampaignEventFilter { |
|
|
|
|
139
|
|
|
o := SDK.CampaignEventFilter{} |
140
|
|
|
|
141
|
|
|
o.Dimensions = r.Dimensions.ToSDK() |
142
|
|
|
o.FilterType = SDK.FilterType(r.FilterType) |
143
|
|
|
return &o |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
type CampaignHook struct { |
|
|
|
|
147
|
|
|
LambdaFunctionName string |
148
|
|
|
Mode Mode |
149
|
|
|
WebURL string |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
func newCampaignHook(o *SDK.CampaignHook) CampaignHook { |
153
|
|
|
result := CampaignHook{} |
154
|
|
|
if o == nil { |
155
|
|
|
return result |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if o.LambdaFunctionName != nil { |
159
|
|
|
result.LambdaFunctionName = *o.LambdaFunctionName |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
result.Mode = Mode(o.Mode) |
163
|
|
|
|
164
|
|
|
if o.WebUrl != nil { |
165
|
|
|
result.WebURL = *o.WebUrl |
166
|
|
|
} |
167
|
|
|
return result |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
func (r CampaignHook) ToSDK() *SDK.CampaignHook { |
|
|
|
|
171
|
|
|
o := SDK.CampaignHook{} |
172
|
|
|
|
173
|
|
|
if r.LambdaFunctionName != "" { |
174
|
|
|
o.LambdaFunctionName = pointers.String(r.LambdaFunctionName) |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
o.Mode = SDK.Mode(r.Mode) |
178
|
|
|
|
179
|
|
|
if r.WebURL != "" { |
180
|
|
|
o.WebUrl = pointers.String(r.WebURL) |
181
|
|
|
} |
182
|
|
|
return &o |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
type CampaignLimits struct { |
|
|
|
|
186
|
|
|
Daily int64 |
187
|
|
|
MaximumDuration int64 |
188
|
|
|
MessagesPerSecond int64 |
189
|
|
|
Total int64 |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
func newCampaignLimits(o *SDK.CampaignLimits) CampaignLimits { |
193
|
|
|
result := CampaignLimits{} |
194
|
|
|
if o == nil { |
195
|
|
|
return result |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
if o.Daily != nil { |
199
|
|
|
result.Daily = *o.Daily |
200
|
|
|
} |
201
|
|
|
if o.MaximumDuration != nil { |
202
|
|
|
result.MaximumDuration = *o.MaximumDuration |
203
|
|
|
} |
204
|
|
|
if o.MessagesPerSecond != nil { |
205
|
|
|
result.MessagesPerSecond = *o.MessagesPerSecond |
206
|
|
|
} |
207
|
|
|
if o.Total != nil { |
208
|
|
|
result.Total = *o.Total |
209
|
|
|
} |
210
|
|
|
return result |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
func (r CampaignLimits) ToSDK() *SDK.CampaignLimits { |
|
|
|
|
214
|
|
|
o := SDK.CampaignLimits{} |
215
|
|
|
|
216
|
|
|
if r.Daily != 0 { |
217
|
|
|
o.Daily = pointers.Long64(r.Daily) |
218
|
|
|
} |
219
|
|
|
if r.MaximumDuration != 0 { |
220
|
|
|
o.MaximumDuration = pointers.Long64(r.MaximumDuration) |
221
|
|
|
} |
222
|
|
|
if r.MessagesPerSecond != 0 { |
223
|
|
|
o.MessagesPerSecond = pointers.Long64(r.MessagesPerSecond) |
224
|
|
|
} |
225
|
|
|
if r.Total != 0 { |
226
|
|
|
o.Total = pointers.Long64(r.Total) |
227
|
|
|
} |
228
|
|
|
return &o |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
type CampaignResponse struct { |
|
|
|
|
232
|
|
|
ApplicationID string |
233
|
|
|
ARN string |
234
|
|
|
CreationDate string |
235
|
|
|
ID string |
236
|
|
|
LastModifiedDate string |
237
|
|
|
SegmentID string |
238
|
|
|
SegmentVersion int64 |
239
|
|
|
|
240
|
|
|
AdditionalTreatments []TreatmentResource |
241
|
|
|
CustomDeliveryConfiguration CustomDeliveryConfiguration |
242
|
|
|
DefaultState CampaignStatus |
243
|
|
|
Description string |
244
|
|
|
HoldoutPercent int64 |
245
|
|
|
Hook CampaignHook |
246
|
|
|
IsPaused bool |
247
|
|
|
Limits CampaignLimits |
248
|
|
|
MessageConfiguration MessageConfiguration |
249
|
|
|
Name string |
250
|
|
|
Schedule Schedule |
251
|
|
|
State CampaignStatus |
252
|
|
|
Tags map[string]string |
253
|
|
|
TemplateConfiguration TemplateConfiguration |
254
|
|
|
TreatmentDescription string |
255
|
|
|
TreatmentName string |
256
|
|
|
Version int64 |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
func newCampaignResponse(o *SDK.CampaignResponse) CampaignResponse { |
260
|
|
|
result := CampaignResponse{} |
261
|
|
|
if o == nil { |
262
|
|
|
return result |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
if o.ApplicationId != nil { |
266
|
|
|
result.ApplicationID = *o.ApplicationId |
267
|
|
|
} |
268
|
|
|
if o.Arn != nil { |
269
|
|
|
result.ARN = *o.Arn |
270
|
|
|
} |
271
|
|
|
if o.CreationDate != nil { |
272
|
|
|
result.CreationDate = *o.CreationDate |
273
|
|
|
} |
274
|
|
|
if o.Id != nil { |
275
|
|
|
result.ID = *o.Id |
276
|
|
|
} |
277
|
|
|
if o.LastModifiedDate != nil { |
278
|
|
|
result.LastModifiedDate = *o.LastModifiedDate |
279
|
|
|
} |
280
|
|
|
if o.SegmentId != nil { |
281
|
|
|
result.SegmentID = *o.SegmentId |
282
|
|
|
} |
283
|
|
|
if o.SegmentVersion != nil { |
284
|
|
|
result.SegmentVersion = *o.SegmentVersion |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
if len(o.AdditionalTreatments) != 0 { |
288
|
|
|
list := make([]TreatmentResource, len(o.AdditionalTreatments)) |
289
|
|
|
for i, v := range o.AdditionalTreatments { |
290
|
|
|
v := v |
291
|
|
|
list[i] = newTreatmentResource(&v) |
292
|
|
|
} |
293
|
|
|
result.AdditionalTreatments = list |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
result.CustomDeliveryConfiguration = newCustomDeliveryConfiguration(o.CustomDeliveryConfiguration) |
297
|
|
|
|
298
|
|
|
if o.DefaultState != nil { |
299
|
|
|
result.DefaultState = CampaignStatus(o.DefaultState.CampaignStatus) |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
if o.Description != nil { |
303
|
|
|
result.Description = *o.Description |
304
|
|
|
} |
305
|
|
|
if o.HoldoutPercent != nil { |
306
|
|
|
result.HoldoutPercent = *o.HoldoutPercent |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
result.Hook = newCampaignHook(o.Hook) |
310
|
|
|
|
311
|
|
|
if o.IsPaused != nil { |
312
|
|
|
result.IsPaused = *o.IsPaused |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
result.Limits = newCampaignLimits(o.Limits) |
316
|
|
|
result.MessageConfiguration = newMessageConfiguration(o.MessageConfiguration) |
317
|
|
|
|
318
|
|
|
if o.Name != nil { |
319
|
|
|
result.Name = *o.Name |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
result.Schedule = newSchedule(o.Schedule) |
323
|
|
|
|
324
|
|
|
if o.State != nil { |
325
|
|
|
result.State = CampaignStatus(o.State.CampaignStatus) |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
result.Tags = o.Tags |
329
|
|
|
result.TemplateConfiguration = newTemplateConfiguration(o.TemplateConfiguration) |
330
|
|
|
|
331
|
|
|
if o.TreatmentDescription != nil { |
332
|
|
|
result.TreatmentDescription = *o.TreatmentDescription |
333
|
|
|
} |
334
|
|
|
if o.TreatmentName != nil { |
335
|
|
|
result.TreatmentName = *o.TreatmentName |
336
|
|
|
} |
337
|
|
|
if o.Version != nil { |
338
|
|
|
result.Version = *o.Version |
339
|
|
|
} |
340
|
|
|
return result |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
type CampaignSMSMessage struct { |
|
|
|
|
344
|
|
|
Body string |
345
|
|
|
MessageType MessageType |
346
|
|
|
SenderID string |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
func newCampaignSMSMessage(o *SDK.CampaignSmsMessage) CampaignSMSMessage { |
350
|
|
|
result := CampaignSMSMessage{} |
351
|
|
|
if o == nil { |
352
|
|
|
return result |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
if o.Body != nil { |
356
|
|
|
result.Body = *o.Body |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
result.MessageType = MessageType(o.MessageType) |
360
|
|
|
|
361
|
|
|
if o.SenderId != nil { |
362
|
|
|
result.SenderID = *o.SenderId |
363
|
|
|
} |
364
|
|
|
return result |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
func (r CampaignSMSMessage) ToSDK() *SDK.CampaignSmsMessage { |
|
|
|
|
368
|
|
|
o := SDK.CampaignSmsMessage{} |
369
|
|
|
|
370
|
|
|
if r.Body != "" { |
371
|
|
|
o.Body = pointers.String(r.Body) |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
o.MessageType = SDK.MessageType(r.MessageType) |
375
|
|
|
|
376
|
|
|
if r.SenderID != "" { |
377
|
|
|
o.SenderId = pointers.String(r.SenderID) |
378
|
|
|
} |
379
|
|
|
return &o |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
type CustomDeliveryConfiguration struct { |
|
|
|
|
383
|
|
|
DeliveryURI string |
384
|
|
|
|
385
|
|
|
// optional |
386
|
|
|
EndpointTypes []EndpointTypesElement |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
func newCustomDeliveryConfiguration(o *SDK.CustomDeliveryConfiguration) CustomDeliveryConfiguration { |
390
|
|
|
result := CustomDeliveryConfiguration{} |
391
|
|
|
if o == nil { |
392
|
|
|
return result |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
if o.DeliveryUri != nil { |
396
|
|
|
result.DeliveryURI = *o.DeliveryUri |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
if len(o.EndpointTypes) != 0 { |
400
|
|
|
list := make([]EndpointTypesElement, len(o.EndpointTypes)) |
401
|
|
|
for i, v := range o.EndpointTypes { |
402
|
|
|
list[i] = EndpointTypesElement(v) |
403
|
|
|
} |
404
|
|
|
result.EndpointTypes = list |
405
|
|
|
} |
406
|
|
|
return result |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
func (r CustomDeliveryConfiguration) ToSDK() *SDK.CustomDeliveryConfiguration { |
|
|
|
|
410
|
|
|
o := SDK.CustomDeliveryConfiguration{} |
411
|
|
|
|
412
|
|
|
if r.DeliveryURI != "" { |
413
|
|
|
o.DeliveryUri = pointers.String(r.DeliveryURI) |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
if len(r.EndpointTypes) != 0 { |
417
|
|
|
list := make([]SDK.EndpointTypesElement, len(r.EndpointTypes)) |
418
|
|
|
for i, v := range r.EndpointTypes { |
419
|
|
|
list[i] = SDK.EndpointTypesElement(v) |
420
|
|
|
} |
421
|
|
|
o.EndpointTypes = list |
422
|
|
|
} |
423
|
|
|
return &o |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
type EventDimensions struct { |
|
|
|
|
427
|
|
|
Attributes map[string]AttributeDimension |
428
|
|
|
EventType SetDimension |
429
|
|
|
Metrics map[string]MetricDimension |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
func newEventDimensions(o *SDK.EventDimensions) EventDimensions { |
433
|
|
|
result := EventDimensions{} |
434
|
|
|
if o == nil { |
435
|
|
|
return result |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
result.Attributes = newAttributeDimensionMap(o.Attributes) |
439
|
|
|
result.EventType = newSetDimension(o.EventType) |
440
|
|
|
result.Metrics = newMetricDimensionMap(o.Metrics) |
441
|
|
|
return result |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
func (r EventDimensions) ToSDK() *SDK.EventDimensions { |
|
|
|
|
445
|
|
|
o := SDK.EventDimensions{} |
446
|
|
|
|
447
|
|
|
o.Attributes = attributeDimensionMapToSDK(r.Attributes) |
448
|
|
|
o.EventType = r.EventType.ToSDK() |
449
|
|
|
o.Metrics = metricDimensionMapToSDK(r.Metrics) |
450
|
|
|
return &o |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
type Message struct { |
|
|
|
|
454
|
|
|
Action Action |
455
|
|
|
Body string |
456
|
|
|
ImageIconURL string |
457
|
|
|
ImageSmallIconURL string |
458
|
|
|
ImageURL string |
459
|
|
|
JSONBody string |
460
|
|
|
MediaURL string |
461
|
|
|
RawContent string |
462
|
|
|
SilentPush bool |
463
|
|
|
TimeToLive int64 |
464
|
|
|
Title string |
465
|
|
|
URL string |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
func newMessage(o *SDK.Message) Message { |
469
|
|
|
result := Message{} |
470
|
|
|
if o == nil { |
471
|
|
|
return result |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
result.Action = Action(o.Action) |
475
|
|
|
|
476
|
|
|
if o.Body != nil { |
477
|
|
|
result.Body = *o.Body |
478
|
|
|
} |
479
|
|
|
if o.ImageIconUrl != nil { |
480
|
|
|
result.ImageIconURL = *o.ImageIconUrl |
481
|
|
|
} |
482
|
|
|
if o.ImageSmallIconUrl != nil { |
483
|
|
|
result.ImageSmallIconURL = *o.ImageSmallIconUrl |
484
|
|
|
} |
485
|
|
|
if o.ImageUrl != nil { |
486
|
|
|
result.ImageURL = *o.ImageUrl |
487
|
|
|
} |
488
|
|
|
if o.JsonBody != nil { |
489
|
|
|
result.JSONBody = *o.JsonBody |
490
|
|
|
} |
491
|
|
|
if o.MediaUrl != nil { |
492
|
|
|
result.MediaURL = *o.MediaUrl |
493
|
|
|
} |
494
|
|
|
if o.RawContent != nil { |
495
|
|
|
result.RawContent = *o.RawContent |
496
|
|
|
} |
497
|
|
|
if o.SilentPush != nil { |
498
|
|
|
result.SilentPush = *o.SilentPush |
499
|
|
|
} |
500
|
|
|
if o.TimeToLive != nil { |
501
|
|
|
result.TimeToLive = *o.TimeToLive |
502
|
|
|
} |
503
|
|
|
if o.Title != nil { |
504
|
|
|
result.Title = *o.Title |
505
|
|
|
} |
506
|
|
|
if o.Url != nil { |
507
|
|
|
result.URL = *o.Url |
508
|
|
|
} |
509
|
|
|
return result |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
func (r Message) ToSDK() *SDK.Message { |
|
|
|
|
513
|
|
|
o := SDK.Message{} |
514
|
|
|
|
515
|
|
|
o.Action = SDK.Action(r.Action) |
516
|
|
|
|
517
|
|
|
if r.Body != "" { |
518
|
|
|
o.Body = pointers.String(r.Body) |
519
|
|
|
} |
520
|
|
|
if r.ImageIconURL != "" { |
521
|
|
|
o.ImageIconUrl = pointers.String(r.ImageIconURL) |
522
|
|
|
} |
523
|
|
|
if r.ImageSmallIconURL != "" { |
524
|
|
|
o.ImageSmallIconUrl = pointers.String(r.ImageSmallIconURL) |
525
|
|
|
} |
526
|
|
|
if r.ImageURL != "" { |
527
|
|
|
o.ImageUrl = pointers.String(r.ImageURL) |
528
|
|
|
} |
529
|
|
|
if r.JSONBody != "" { |
530
|
|
|
o.JsonBody = pointers.String(r.JSONBody) |
531
|
|
|
} |
532
|
|
|
if r.MediaURL != "" { |
533
|
|
|
o.MediaUrl = pointers.String(r.MediaURL) |
534
|
|
|
} |
535
|
|
|
if r.RawContent != "" { |
536
|
|
|
o.RawContent = pointers.String(r.RawContent) |
537
|
|
|
} |
538
|
|
|
if r.SilentPush { |
539
|
|
|
o.SilentPush = pointers.Bool(r.SilentPush) |
540
|
|
|
} |
541
|
|
|
if r.TimeToLive != 0 { |
542
|
|
|
o.TimeToLive = pointers.Long64(r.TimeToLive) |
543
|
|
|
} |
544
|
|
|
if r.Title != "" { |
545
|
|
|
o.Title = pointers.String(r.Title) |
546
|
|
|
} |
547
|
|
|
if r.URL != "" { |
548
|
|
|
o.Url = pointers.String(r.URL) |
549
|
|
|
} |
550
|
|
|
return &o |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
type MessageConfiguration struct { |
|
|
|
|
554
|
|
|
ADMMessage Message |
555
|
|
|
APNsMessage Message |
556
|
|
|
BaiduMessage Message |
557
|
|
|
CustomMessage CampaignCustomMessage |
558
|
|
|
DefaultMessage Message |
559
|
|
|
EmailMessage CampaignEmailMessage |
560
|
|
|
GCMMessage Message |
561
|
|
|
SMSMessage CampaignSMSMessage |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
func newMessageConfiguration(o *SDK.MessageConfiguration) MessageConfiguration { |
565
|
|
|
result := MessageConfiguration{} |
566
|
|
|
if o == nil { |
567
|
|
|
return result |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
result.ADMMessage = newMessage(o.ADMMessage) |
571
|
|
|
result.APNsMessage = newMessage(o.APNSMessage) |
572
|
|
|
result.BaiduMessage = newMessage(o.BaiduMessage) |
573
|
|
|
result.CustomMessage = newCampaignCustomMessage(o.CustomMessage) |
574
|
|
|
result.DefaultMessage = newMessage(o.DefaultMessage) |
575
|
|
|
result.EmailMessage = newCampaignEmailMessage(o.EmailMessage) |
576
|
|
|
result.GCMMessage = newMessage(o.GCMMessage) |
577
|
|
|
result.SMSMessage = newCampaignSMSMessage(o.SMSMessage) |
578
|
|
|
return result |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
func (r MessageConfiguration) ToSDK() *SDK.MessageConfiguration { |
|
|
|
|
582
|
|
|
o := SDK.MessageConfiguration{} |
583
|
|
|
|
584
|
|
|
o.ADMMessage = r.ADMMessage.ToSDK() |
585
|
|
|
o.APNSMessage = r.APNsMessage.ToSDK() |
586
|
|
|
o.BaiduMessage = r.BaiduMessage.ToSDK() |
587
|
|
|
o.CustomMessage = r.CustomMessage.ToSDK() |
588
|
|
|
o.DefaultMessage = r.DefaultMessage.ToSDK() |
589
|
|
|
o.EmailMessage = r.EmailMessage.ToSDK() |
590
|
|
|
o.GCMMessage = r.GCMMessage.ToSDK() |
591
|
|
|
o.SMSMessage = r.SMSMessage.ToSDK() |
592
|
|
|
return &o |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
type MetricDimension struct { |
|
|
|
|
596
|
|
|
ComparisonOperator string |
597
|
|
|
Value float64 |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
func newMetricDimensionMap(in map[string]SDK.MetricDimension) map[string]MetricDimension { |
601
|
|
|
result := make(map[string]MetricDimension, len(in)) |
602
|
|
|
for key, val := range in { |
603
|
|
|
val := val |
604
|
|
|
result[key] = newMetricDimension(&val) |
605
|
|
|
} |
606
|
|
|
return result |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
func newMetricDimension(o *SDK.MetricDimension) MetricDimension { |
610
|
|
|
result := MetricDimension{} |
611
|
|
|
|
612
|
|
|
if o.ComparisonOperator != nil { |
613
|
|
|
result.ComparisonOperator = *o.ComparisonOperator |
614
|
|
|
} |
615
|
|
|
if o.Value != nil { |
616
|
|
|
result.Value = *o.Value |
617
|
|
|
} |
618
|
|
|
return result |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
func metricDimensionMapToSDK(in map[string]MetricDimension) map[string]SDK.MetricDimension { |
622
|
|
|
result := make(map[string]SDK.MetricDimension, len(in)) |
623
|
|
|
for key, val := range in { |
624
|
|
|
result[key] = val.ToSDK() |
625
|
|
|
} |
626
|
|
|
return result |
627
|
|
|
} |
628
|
|
|
func (r MetricDimension) ToSDK() SDK.MetricDimension { |
|
|
|
|
629
|
|
|
o := SDK.MetricDimension{} |
630
|
|
|
|
631
|
|
|
if r.ComparisonOperator != "" { |
632
|
|
|
o.ComparisonOperator = pointers.String(r.ComparisonOperator) |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
o.Value = pointers.Float64(r.Value) |
636
|
|
|
return o |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
type QuietTime struct { |
|
|
|
|
640
|
|
|
End string |
641
|
|
|
Start string |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
func newQuietTime(o *SDK.QuietTime) QuietTime { |
645
|
|
|
result := QuietTime{} |
646
|
|
|
if o == nil { |
647
|
|
|
return result |
648
|
|
|
} |
649
|
|
|
|
650
|
|
|
if o.End != nil { |
651
|
|
|
result.End = *o.End |
652
|
|
|
} |
653
|
|
|
if o.Start != nil { |
654
|
|
|
result.Start = *o.Start |
655
|
|
|
} |
656
|
|
|
return result |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
func (r QuietTime) ToSDK() *SDK.QuietTime { |
|
|
|
|
660
|
|
|
o := SDK.QuietTime{} |
661
|
|
|
|
662
|
|
|
if r.End != "" { |
663
|
|
|
o.End = pointers.String(r.End) |
664
|
|
|
} |
665
|
|
|
if r.Start != "" { |
666
|
|
|
o.Start = pointers.String(r.Start) |
667
|
|
|
} |
668
|
|
|
return &o |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
type Schedule struct { |
|
|
|
|
672
|
|
|
StartTime string |
673
|
|
|
|
674
|
|
|
// optional |
675
|
|
|
EndTime string |
676
|
|
|
EventFilter CampaignEventFilter |
677
|
|
|
Frequency Frequency |
678
|
|
|
IsLocalTime bool |
679
|
|
|
QuietTime QuietTime |
680
|
|
|
Timezone string |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
func newSchedule(o *SDK.Schedule) Schedule { |
684
|
|
|
result := Schedule{} |
685
|
|
|
if o == nil { |
686
|
|
|
return result |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
if o.StartTime != nil { |
690
|
|
|
result.StartTime = *o.StartTime |
691
|
|
|
} |
692
|
|
|
|
693
|
|
|
result.EventFilter = newCampaignEventFilter(o.EventFilter) |
694
|
|
|
result.Frequency = Frequency(o.Frequency) |
695
|
|
|
|
696
|
|
|
if o.IsLocalTime != nil { |
697
|
|
|
result.IsLocalTime = *o.IsLocalTime |
698
|
|
|
} |
699
|
|
|
|
700
|
|
|
result.QuietTime = newQuietTime(o.QuietTime) |
701
|
|
|
|
702
|
|
|
if o.Timezone != nil { |
703
|
|
|
result.Timezone = *o.Timezone |
704
|
|
|
} |
705
|
|
|
return result |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
func (r Schedule) ToSDK() *SDK.Schedule { |
|
|
|
|
709
|
|
|
o := SDK.Schedule{} |
710
|
|
|
|
711
|
|
|
if r.StartTime != "" { |
712
|
|
|
o.StartTime = pointers.String(r.StartTime) |
713
|
|
|
} |
714
|
|
|
if r.EndTime != "" { |
715
|
|
|
o.EndTime = pointers.String(r.EndTime) |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
o.EventFilter = r.EventFilter.ToSDK() |
719
|
|
|
o.Frequency = SDK.Frequency(r.Frequency) |
720
|
|
|
|
721
|
|
|
if r.IsLocalTime { |
722
|
|
|
o.IsLocalTime = pointers.Bool(r.IsLocalTime) |
723
|
|
|
} |
724
|
|
|
|
725
|
|
|
o.QuietTime = r.QuietTime.ToSDK() |
726
|
|
|
|
727
|
|
|
if r.Timezone != "" { |
728
|
|
|
o.Timezone = pointers.String(r.Timezone) |
729
|
|
|
} |
730
|
|
|
return &o |
731
|
|
|
} |
732
|
|
|
|
733
|
|
|
type SetDimension struct { |
|
|
|
|
734
|
|
|
Values []string |
735
|
|
|
|
736
|
|
|
// optional |
737
|
|
|
DimensionType DimensionType |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
func newSetDimension(o *SDK.SetDimension) SetDimension { |
741
|
|
|
result := SetDimension{} |
742
|
|
|
if o == nil { |
743
|
|
|
return result |
744
|
|
|
} |
745
|
|
|
|
746
|
|
|
result.Values = o.Values |
747
|
|
|
result.DimensionType = DimensionType(o.DimensionType) |
748
|
|
|
return result |
749
|
|
|
} |
750
|
|
|
|
751
|
|
|
func (r SetDimension) ToSDK() *SDK.SetDimension { |
|
|
|
|
752
|
|
|
o := SDK.SetDimension{} |
753
|
|
|
|
754
|
|
|
o.Values = r.Values |
755
|
|
|
o.DimensionType = SDK.DimensionType(r.DimensionType) |
756
|
|
|
return &o |
757
|
|
|
} |
758
|
|
|
|
759
|
|
|
type Template struct { |
|
|
|
|
760
|
|
|
Name string |
761
|
|
|
Version string |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
func newTemplate(o *SDK.Template) Template { |
765
|
|
|
result := Template{} |
766
|
|
|
if o == nil { |
767
|
|
|
return result |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
if o.Name != nil { |
771
|
|
|
result.Name = *o.Name |
772
|
|
|
} |
773
|
|
|
if o.Version != nil { |
774
|
|
|
result.Version = *o.Version |
775
|
|
|
} |
776
|
|
|
return result |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
func (r Template) ToSDK() *SDK.Template { |
|
|
|
|
780
|
|
|
o := SDK.Template{} |
781
|
|
|
|
782
|
|
|
if r.Name != "" { |
783
|
|
|
o.Name = pointers.String(r.Name) |
784
|
|
|
} |
785
|
|
|
if r.Version != "" { |
786
|
|
|
o.Version = pointers.String(r.Version) |
787
|
|
|
} |
788
|
|
|
return &o |
789
|
|
|
} |
790
|
|
|
|
791
|
|
|
type TemplateConfiguration struct { |
|
|
|
|
792
|
|
|
EmailTemplate Template |
793
|
|
|
PushTemplate Template |
794
|
|
|
SMSTemplate Template |
795
|
|
|
VoiceTemplate Template |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
func newTemplateConfiguration(o *SDK.TemplateConfiguration) TemplateConfiguration { |
799
|
|
|
result := TemplateConfiguration{} |
800
|
|
|
if o == nil { |
801
|
|
|
return result |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
result.EmailTemplate = newTemplate(o.EmailTemplate) |
805
|
|
|
result.PushTemplate = newTemplate(o.PushTemplate) |
806
|
|
|
result.SMSTemplate = newTemplate(o.SMSTemplate) |
807
|
|
|
result.VoiceTemplate = newTemplate(o.VoiceTemplate) |
808
|
|
|
return result |
809
|
|
|
} |
810
|
|
|
|
811
|
|
|
func (r TemplateConfiguration) ToSDK() *SDK.TemplateConfiguration { |
|
|
|
|
812
|
|
|
o := SDK.TemplateConfiguration{} |
813
|
|
|
|
814
|
|
|
o.EmailTemplate = r.EmailTemplate.ToSDK() |
815
|
|
|
o.PushTemplate = r.PushTemplate.ToSDK() |
816
|
|
|
o.SMSTemplate = r.SMSTemplate.ToSDK() |
817
|
|
|
o.VoiceTemplate = r.VoiceTemplate.ToSDK() |
818
|
|
|
return &o |
819
|
|
|
} |
820
|
|
|
|
821
|
|
|
type TreatmentResource struct { |
|
|
|
|
822
|
|
|
ID string |
823
|
|
|
SizePercent int64 |
824
|
|
|
|
825
|
|
|
// optional |
826
|
|
|
CustomDeliveryConfiguration CustomDeliveryConfiguration |
827
|
|
|
MessageConfiguration MessageConfiguration |
828
|
|
|
Schedule Schedule |
829
|
|
|
State CampaignStatus |
830
|
|
|
TemplateConfiguration TemplateConfiguration |
831
|
|
|
TreatmentDescription string |
832
|
|
|
TreatmentName string |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
func newTreatmentResource(o *SDK.TreatmentResource) TreatmentResource { |
836
|
|
|
result := TreatmentResource{} |
837
|
|
|
if o == nil { |
838
|
|
|
return result |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
if o.Id != nil { |
842
|
|
|
result.ID = *o.Id |
843
|
|
|
} |
844
|
|
|
if o.SizePercent != nil { |
845
|
|
|
result.SizePercent = *o.SizePercent |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
result.CustomDeliveryConfiguration = newCustomDeliveryConfiguration(o.CustomDeliveryConfiguration) |
849
|
|
|
result.MessageConfiguration = newMessageConfiguration(o.MessageConfiguration) |
850
|
|
|
result.Schedule = newSchedule(o.Schedule) |
851
|
|
|
if o.State != nil { |
852
|
|
|
result.State = CampaignStatus(o.State.CampaignStatus) |
853
|
|
|
} |
854
|
|
|
result.TemplateConfiguration = newTemplateConfiguration(o.TemplateConfiguration) |
855
|
|
|
|
856
|
|
|
if o.TreatmentDescription != nil { |
857
|
|
|
result.TreatmentDescription = *o.TreatmentDescription |
858
|
|
|
} |
859
|
|
|
if o.TreatmentName != nil { |
860
|
|
|
result.TreatmentName = *o.TreatmentName |
861
|
|
|
} |
862
|
|
|
return result |
863
|
|
|
} |
864
|
|
|
|
865
|
|
|
type WriteCampaignRequest struct { |
|
|
|
|
866
|
|
|
AdditionalTreatments []WriteTreatmentResource |
867
|
|
|
CustomDeliveryConfiguration CustomDeliveryConfiguration |
868
|
|
|
Description string |
869
|
|
|
HoldoutPercent int64 |
870
|
|
|
Hook CampaignHook |
871
|
|
|
IsPaused bool |
872
|
|
|
Limits CampaignLimits |
873
|
|
|
MessageConfiguration MessageConfiguration |
874
|
|
|
Name string |
875
|
|
|
Schedule Schedule |
876
|
|
|
SegmentID string |
877
|
|
|
SegmentVersion int64 |
878
|
|
|
Tags map[string]string |
879
|
|
|
TemplateConfiguration TemplateConfiguration |
880
|
|
|
TreatmentDescription string |
881
|
|
|
TreatmentName string |
882
|
|
|
} |
883
|
|
|
|
884
|
|
|
func (r WriteCampaignRequest) ToSDK() *SDK.WriteCampaignRequest { |
|
|
|
|
885
|
|
|
o := SDK.WriteCampaignRequest{} |
886
|
|
|
|
887
|
|
|
if len(r.AdditionalTreatments) != 0 { |
888
|
|
|
list := make([]SDK.WriteTreatmentResource, len(r.AdditionalTreatments)) |
889
|
|
|
for i, v := range r.AdditionalTreatments { |
890
|
|
|
list[i] = v.ToSDK() |
891
|
|
|
} |
892
|
|
|
o.AdditionalTreatments = list |
893
|
|
|
} |
894
|
|
|
o.CustomDeliveryConfiguration = r.CustomDeliveryConfiguration.ToSDK() |
895
|
|
|
|
896
|
|
|
if r.Description != "" { |
897
|
|
|
o.Description = pointers.String(r.Description) |
898
|
|
|
} |
899
|
|
|
if r.HoldoutPercent != 0 { |
900
|
|
|
o.HoldoutPercent = pointers.Long64(r.HoldoutPercent) |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
o.Hook = r.Hook.ToSDK() |
904
|
|
|
|
905
|
|
|
if r.IsPaused { |
906
|
|
|
o.IsPaused = pointers.Bool(r.IsPaused) |
907
|
|
|
} |
908
|
|
|
if r.Name != "" { |
909
|
|
|
o.Name = pointers.String(r.Name) |
910
|
|
|
} |
911
|
|
|
|
912
|
|
|
if r.SegmentID != "" { |
913
|
|
|
o.SegmentId = pointers.String(r.SegmentID) |
914
|
|
|
} |
915
|
|
|
if r.SegmentVersion != 0 { |
916
|
|
|
o.SegmentVersion = pointers.Long64(r.SegmentVersion) |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
o.Tags = r.Tags |
920
|
|
|
|
921
|
|
|
if r.TreatmentDescription != "" { |
922
|
|
|
o.TreatmentDescription = pointers.String(r.TreatmentDescription) |
923
|
|
|
} |
924
|
|
|
if r.TreatmentName != "" { |
925
|
|
|
o.TreatmentName = pointers.String(r.TreatmentName) |
926
|
|
|
} |
927
|
|
|
return &o |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
type WriteTreatmentResource struct { |
|
|
|
|
931
|
|
|
SizePercent int64 |
932
|
|
|
|
933
|
|
|
// optional |
934
|
|
|
CustomDeliveryConfiguration CustomDeliveryConfiguration |
935
|
|
|
MessageConfiguration MessageConfiguration |
936
|
|
|
Schedule Schedule |
937
|
|
|
TemplateConfiguration TemplateConfiguration |
938
|
|
|
TreatmentDescription string |
939
|
|
|
TreatmentName string |
940
|
|
|
} |
941
|
|
|
|
942
|
|
|
func (r WriteTreatmentResource) ToSDK() SDK.WriteTreatmentResource { |
|
|
|
|
943
|
|
|
o := SDK.WriteTreatmentResource{} |
944
|
|
|
|
945
|
|
|
if r.SizePercent != 0 { |
946
|
|
|
o.SizePercent = pointers.Long64(r.SizePercent) |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
o.CustomDeliveryConfiguration = r.CustomDeliveryConfiguration.ToSDK() |
950
|
|
|
o.MessageConfiguration = r.MessageConfiguration.ToSDK() |
951
|
|
|
o.Schedule = r.Schedule.ToSDK() |
952
|
|
|
o.TemplateConfiguration = r.TemplateConfiguration.ToSDK() |
953
|
|
|
|
954
|
|
|
if r.TreatmentDescription != "" { |
955
|
|
|
o.TreatmentDescription = pointers.String(r.TreatmentDescription) |
956
|
|
|
} |
957
|
|
|
if r.TreatmentName != "" { |
958
|
|
|
o.TreatmentName = pointers.String(r.TreatmentName) |
959
|
|
|
} |
960
|
|
|
return o |
961
|
|
|
} |
962
|
|
|
|