Passed
Pull Request — master (#29)
by eval
02:10
created

pinpoint.Message.ToSDK   D

Complexity

Conditions 12

Size

Total Lines 39
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 12
eloc 26
nop 0
dl 0
loc 39
rs 4.8
c 0
b 0
f 0

How to fix   Complexity   

Complexity

Complex classes like pinpoint.Message.ToSDK often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

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