-
Notifications
You must be signed in to change notification settings - Fork 14
/
types.go
8018 lines (7094 loc) · 223 KB
/
types.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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
core "github.com/trycourier/courier-go/v3/core"
)
type SendMessageRequest struct {
// Defines the message to be delivered
Message *Message `json:"message,omitempty" url:"message,omitempty"`
}
type SendMessageResponse struct {
// A successful call to `POST /send` returns a `202` status code along with a `requestId` in the response body.
//
// For send requests that have a single recipient, the `requestId` is assigned to the derived message as its message_id. Therefore the `requestId` can be supplied to the Message's API for single recipient messages.
//
// For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier assigns a unique id to each derived message as its `message_id`. Therefore the `requestId` cannot be supplied to the Message's API for single-recipient messages.
RequestId string `json:"requestId" url:"requestId"`
_rawJSON json.RawMessage
}
func (s *SendMessageResponse) UnmarshalJSON(data []byte) error {
type unmarshaler SendMessageResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SendMessageResponse(value)
s._rawJSON = json.RawMessage(data)
return nil
}
func (s *SendMessageResponse) String() string {
if len(s._rawJSON) > 0 {
if value, err := core.StringifyJSON(s._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
type AudienceMember struct {
AddedAt string `json:"added_at" url:"added_at"`
AudienceId string `json:"audience_id" url:"audience_id"`
AudienceVersion int `json:"audience_version" url:"audience_version"`
MemberId string `json:"member_id" url:"member_id"`
Reason string `json:"reason" url:"reason"`
_rawJSON json.RawMessage
}
func (a *AudienceMember) UnmarshalJSON(data []byte) error {
type unmarshaler AudienceMember
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AudienceMember(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AudienceMember) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AudienceMemberGetResponse struct {
AudienceMember *AudienceMember `json:"audienceMember,omitempty" url:"audienceMember,omitempty"`
_rawJSON json.RawMessage
}
func (a *AudienceMemberGetResponse) UnmarshalJSON(data []byte) error {
type unmarshaler AudienceMemberGetResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AudienceMemberGetResponse(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AudienceMemberGetResponse) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type BaseFilterConfig struct {
// The operator to use for filtering
Operator *Operator `json:"operator,omitempty" url:"operator,omitempty"`
_rawJSON json.RawMessage
}
func (b *BaseFilterConfig) UnmarshalJSON(data []byte) error {
type unmarshaler BaseFilterConfig
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*b = BaseFilterConfig(value)
b._rawJSON = json.RawMessage(data)
return nil
}
func (b *BaseFilterConfig) String() string {
if len(b._rawJSON) > 0 {
if value, err := core.StringifyJSON(b._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(b); err == nil {
return value
}
return fmt.Sprintf("%#v", b)
}
type ComparisonOperator string
const (
ComparisonOperatorEndsWith ComparisonOperator = "ENDS_WITH"
ComparisonOperatorEq ComparisonOperator = "EQ"
ComparisonOperatorExists ComparisonOperator = "EXISTS"
ComparisonOperatorGt ComparisonOperator = "GT"
ComparisonOperatorGte ComparisonOperator = "GTE"
ComparisonOperatorIncludes ComparisonOperator = "INCLUDES"
ComparisonOperatorIsAfter ComparisonOperator = "IS_AFTER"
ComparisonOperatorIsBefore ComparisonOperator = "IS_BEFORE"
ComparisonOperatorLt ComparisonOperator = "LT"
ComparisonOperatorLte ComparisonOperator = "LTE"
ComparisonOperatorNeq ComparisonOperator = "NEQ"
ComparisonOperatorOmit ComparisonOperator = "OMIT"
ComparisonOperatorStartsWith ComparisonOperator = "STARTS_WITH"
)
func NewComparisonOperatorFromString(s string) (ComparisonOperator, error) {
switch s {
case "ENDS_WITH":
return ComparisonOperatorEndsWith, nil
case "EQ":
return ComparisonOperatorEq, nil
case "EXISTS":
return ComparisonOperatorExists, nil
case "GT":
return ComparisonOperatorGt, nil
case "GTE":
return ComparisonOperatorGte, nil
case "INCLUDES":
return ComparisonOperatorIncludes, nil
case "IS_AFTER":
return ComparisonOperatorIsAfter, nil
case "IS_BEFORE":
return ComparisonOperatorIsBefore, nil
case "LT":
return ComparisonOperatorLt, nil
case "LTE":
return ComparisonOperatorLte, nil
case "NEQ":
return ComparisonOperatorNeq, nil
case "OMIT":
return ComparisonOperatorOmit, nil
case "STARTS_WITH":
return ComparisonOperatorStartsWith, nil
}
var t ComparisonOperator
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (c ComparisonOperator) Ptr() *ComparisonOperator {
return &c
}
type FilterConfig struct {
SingleFilterConfig *SingleFilterConfig
NestedFilterConfig *NestedFilterConfig
}
func (f *FilterConfig) UnmarshalJSON(data []byte) error {
valueSingleFilterConfig := new(SingleFilterConfig)
if err := json.Unmarshal(data, &valueSingleFilterConfig); err == nil {
f.SingleFilterConfig = valueSingleFilterConfig
return nil
}
valueNestedFilterConfig := new(NestedFilterConfig)
if err := json.Unmarshal(data, &valueNestedFilterConfig); err == nil {
f.NestedFilterConfig = valueNestedFilterConfig
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, f)
}
func (f FilterConfig) MarshalJSON() ([]byte, error) {
if f.SingleFilterConfig != nil {
return json.Marshal(f.SingleFilterConfig)
}
if f.NestedFilterConfig != nil {
return json.Marshal(f.NestedFilterConfig)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", f)
}
type FilterConfigVisitor interface {
VisitSingleFilterConfig(*SingleFilterConfig) error
VisitNestedFilterConfig(*NestedFilterConfig) error
}
func (f *FilterConfig) Accept(visitor FilterConfigVisitor) error {
if f.SingleFilterConfig != nil {
return visitor.VisitSingleFilterConfig(f.SingleFilterConfig)
}
if f.NestedFilterConfig != nil {
return visitor.VisitNestedFilterConfig(f.NestedFilterConfig)
}
return fmt.Errorf("type %T does not include a non-empty union type", f)
}
type LogicalOperator string
const (
LogicalOperatorAnd LogicalOperator = "AND"
LogicalOperatorOr LogicalOperator = "OR"
)
func NewLogicalOperatorFromString(s string) (LogicalOperator, error) {
switch s {
case "AND":
return LogicalOperatorAnd, nil
case "OR":
return LogicalOperatorOr, nil
}
var t LogicalOperator
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (l LogicalOperator) Ptr() *LogicalOperator {
return &l
}
// The operator to use for filtering
type NestedFilterConfig struct {
// The operator to use for filtering
Operator *Operator `json:"operator,omitempty" url:"operator,omitempty"`
Rules []*FilterConfig `json:"rules,omitempty" url:"rules,omitempty"`
_rawJSON json.RawMessage
}
func (n *NestedFilterConfig) UnmarshalJSON(data []byte) error {
type unmarshaler NestedFilterConfig
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*n = NestedFilterConfig(value)
n._rawJSON = json.RawMessage(data)
return nil
}
func (n *NestedFilterConfig) String() string {
if len(n._rawJSON) > 0 {
if value, err := core.StringifyJSON(n._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(n); err == nil {
return value
}
return fmt.Sprintf("%#v", n)
}
type Operator struct {
ComparisonOperator ComparisonOperator
LogicalOperator LogicalOperator
}
func (o *Operator) UnmarshalJSON(data []byte) error {
var valueComparisonOperator ComparisonOperator
if err := json.Unmarshal(data, &valueComparisonOperator); err == nil {
o.ComparisonOperator = valueComparisonOperator
return nil
}
var valueLogicalOperator LogicalOperator
if err := json.Unmarshal(data, &valueLogicalOperator); err == nil {
o.LogicalOperator = valueLogicalOperator
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, o)
}
func (o Operator) MarshalJSON() ([]byte, error) {
if o.ComparisonOperator != "" {
return json.Marshal(o.ComparisonOperator)
}
if o.LogicalOperator != "" {
return json.Marshal(o.LogicalOperator)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", o)
}
type OperatorVisitor interface {
VisitComparisonOperator(ComparisonOperator) error
VisitLogicalOperator(LogicalOperator) error
}
func (o *Operator) Accept(visitor OperatorVisitor) error {
if o.ComparisonOperator != "" {
return visitor.VisitComparisonOperator(o.ComparisonOperator)
}
if o.LogicalOperator != "" {
return visitor.VisitLogicalOperator(o.LogicalOperator)
}
return fmt.Errorf("type %T does not include a non-empty union type", o)
}
// A single filter to use for filtering
type SingleFilterConfig struct {
// The operator to use for filtering
Operator *Operator `json:"operator,omitempty" url:"operator,omitempty"`
// The value to use for filtering
Value string `json:"value" url:"value"`
// The attribe name from profile whose value will be operated against the filter value
Path string `json:"path" url:"path"`
_rawJSON json.RawMessage
}
func (s *SingleFilterConfig) UnmarshalJSON(data []byte) error {
type unmarshaler SingleFilterConfig
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*s = SingleFilterConfig(value)
s._rawJSON = json.RawMessage(data)
return nil
}
func (s *SingleFilterConfig) String() string {
if len(s._rawJSON) > 0 {
if value, err := core.StringifyJSON(s._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(s); err == nil {
return value
}
return fmt.Sprintf("%#v", s)
}
type Actor struct {
Id *string `json:"id,omitempty" url:"id,omitempty"`
Email *string `json:"email,omitempty" url:"email,omitempty"`
_rawJSON json.RawMessage
}
func (a *Actor) UnmarshalJSON(data []byte) error {
type unmarshaler Actor
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = Actor(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *Actor) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type GetAuditEventParams struct {
AuditEventId string `json:"auditEventId" url:"auditEventId"`
_rawJSON json.RawMessage
}
func (g *GetAuditEventParams) UnmarshalJSON(data []byte) error {
type unmarshaler GetAuditEventParams
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*g = GetAuditEventParams(value)
g._rawJSON = json.RawMessage(data)
return nil
}
func (g *GetAuditEventParams) String() string {
if len(g._rawJSON) > 0 {
if value, err := core.StringifyJSON(g._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(g); err == nil {
return value
}
return fmt.Sprintf("%#v", g)
}
type ListAuditEventsParams struct {
Cursor *string `json:"cursor,omitempty" url:"cursor,omitempty"`
_rawJSON json.RawMessage
}
func (l *ListAuditEventsParams) UnmarshalJSON(data []byte) error {
type unmarshaler ListAuditEventsParams
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = ListAuditEventsParams(value)
l._rawJSON = json.RawMessage(data)
return nil
}
func (l *ListAuditEventsParams) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
type Target struct {
Id *string `json:"id,omitempty" url:"id,omitempty"`
Email *string `json:"email,omitempty" url:"email,omitempty"`
_rawJSON json.RawMessage
}
func (t *Target) UnmarshalJSON(data []byte) error {
type unmarshaler Target
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*t = Target(value)
t._rawJSON = json.RawMessage(data)
return nil
}
func (t *Target) String() string {
if len(t._rawJSON) > 0 {
if value, err := core.StringifyJSON(t._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(t); err == nil {
return value
}
return fmt.Sprintf("%#v", t)
}
type AccessorType struct {
Ref string `json:"$ref" url:"$ref"`
_rawJSON json.RawMessage
}
func (a *AccessorType) UnmarshalJSON(data []byte) error {
type unmarshaler AccessorType
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AccessorType(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AccessorType) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type Automation struct {
CancelationToken *string `json:"cancelation_token,omitempty" url:"cancelation_token,omitempty"`
Steps []*AutomationStepOption `json:"steps,omitempty" url:"steps,omitempty"`
_rawJSON json.RawMessage
}
func (a *Automation) UnmarshalJSON(data []byte) error {
type unmarshaler Automation
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = Automation(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *Automation) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationAddToBatchMaxItemsType struct {
String string
Integer int
}
func (a *AutomationAddToBatchMaxItemsType) UnmarshalJSON(data []byte) error {
var valueString string
if err := json.Unmarshal(data, &valueString); err == nil {
a.String = valueString
return nil
}
var valueInteger int
if err := json.Unmarshal(data, &valueInteger); err == nil {
a.Integer = valueInteger
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, a)
}
func (a AutomationAddToBatchMaxItemsType) MarshalJSON() ([]byte, error) {
if a.String != "" {
return json.Marshal(a.String)
}
if a.Integer != 0 {
return json.Marshal(a.Integer)
}
return nil, fmt.Errorf("type %T does not include a non-empty union type", a)
}
type AutomationAddToBatchMaxItemsTypeVisitor interface {
VisitString(string) error
VisitInteger(int) error
}
func (a *AutomationAddToBatchMaxItemsType) Accept(visitor AutomationAddToBatchMaxItemsTypeVisitor) error {
if a.String != "" {
return visitor.VisitString(a.String)
}
if a.Integer != 0 {
return visitor.VisitInteger(a.Integer)
}
return fmt.Errorf("type %T does not include a non-empty union type", a)
}
// Defines what items should be retained and passed along to the next steps when the batch is released
type AutomationAddToBatchRetain struct {
// Keep N number of notifications based on the type. First/Last N based on notification received.
// highest/lowest based on a scoring key providing in the data accessed by sort_key
Type AutomationAddToBatchRetainType `json:"type,omitempty" url:"type,omitempty"`
// The number of records to keep in batch. Default is 10 and only configurable by requesting from support.
// When configurable minimum is 2 and maximum is 100.
Count int `json:"count" url:"count"`
// Defines the data value data[sort_key] that is used to sort the stored items. Required when type is set to highest or lowest.
SortKey *string `json:"sort_key,omitempty" url:"sort_key,omitempty"`
_rawJSON json.RawMessage
}
func (a *AutomationAddToBatchRetain) UnmarshalJSON(data []byte) error {
type unmarshaler AutomationAddToBatchRetain
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AutomationAddToBatchRetain(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationAddToBatchRetain) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationAddToBatchRetainType string
const (
AutomationAddToBatchRetainTypeFirst AutomationAddToBatchRetainType = "first"
AutomationAddToBatchRetainTypeLast AutomationAddToBatchRetainType = "last"
AutomationAddToBatchRetainTypeHighest AutomationAddToBatchRetainType = "highest"
AutomationAddToBatchRetainTypeLowest AutomationAddToBatchRetainType = "lowest"
)
func NewAutomationAddToBatchRetainTypeFromString(s string) (AutomationAddToBatchRetainType, error) {
switch s {
case "first":
return AutomationAddToBatchRetainTypeFirst, nil
case "last":
return AutomationAddToBatchRetainTypeLast, nil
case "highest":
return AutomationAddToBatchRetainTypeHighest, nil
case "lowest":
return AutomationAddToBatchRetainTypeLowest, nil
}
var t AutomationAddToBatchRetainType
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (a AutomationAddToBatchRetainType) Ptr() *AutomationAddToBatchRetainType {
return &a
}
type AutomationAddToBatchScope string
const (
AutomationAddToBatchScopeUser AutomationAddToBatchScope = "user"
AutomationAddToBatchScopeGlobal AutomationAddToBatchScope = "global"
AutomationAddToBatchScopeDynamic AutomationAddToBatchScope = "dynamic"
)
func NewAutomationAddToBatchScopeFromString(s string) (AutomationAddToBatchScope, error) {
switch s {
case "user":
return AutomationAddToBatchScopeUser, nil
case "global":
return AutomationAddToBatchScopeGlobal, nil
case "dynamic":
return AutomationAddToBatchScopeDynamic, nil
}
var t AutomationAddToBatchScope
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (a AutomationAddToBatchScope) Ptr() *AutomationAddToBatchScope {
return &a
}
type AutomationAddToBatchStep struct {
If *string `json:"if,omitempty" url:"if,omitempty"`
Ref *string `json:"ref,omitempty" url:"ref,omitempty"`
// Defines the period of inactivity before the batch is released. Specified as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations)
WaitPeriod string `json:"wait_period" url:"wait_period"`
// Defines the maximum wait time before the batch should be released. Must be less than wait period. Maximum of 60 days. Specified as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations)
MaxWaitPeriod string `json:"max_wait_period" url:"max_wait_period"`
// If specified, the batch will release as soon as this number is reached
MaxItems *AutomationAddToBatchMaxItemsType `json:"max_items,omitempty" url:"max_items,omitempty"`
Retain *AutomationAddToBatchRetain `json:"retain,omitempty" url:"retain,omitempty"`
// Determine the scope of the batching. If user, chosen in this order: recipient, profile.user_id, data.user_id, data.userId.
// If dynamic, then specify where the batch_key or a reference to the batch_key
Scope *AutomationAddToBatchScope `json:"scope,omitempty" url:"scope,omitempty"`
// If using scope=dynamic, provide the key or a reference (e.g., refs.data.batch_key)
BatchKey *string `json:"batch_key,omitempty" url:"batch_key,omitempty"`
BatchId *string `json:"batch_id,omitempty" url:"batch_id,omitempty"`
// Defines the field of the data object the batch is set to when complete. Defaults to `batch`
CategoryKey *string `json:"category_key,omitempty" url:"category_key,omitempty"`
action string
_rawJSON json.RawMessage
}
func (a *AutomationAddToBatchStep) Action() string {
return a.action
}
func (a *AutomationAddToBatchStep) UnmarshalJSON(data []byte) error {
type embed AutomationAddToBatchStep
var unmarshaler = struct {
embed
}{
embed: embed(*a),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*a = AutomationAddToBatchStep(unmarshaler.embed)
a.action = "add-to-batch"
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationAddToBatchStep) MarshalJSON() ([]byte, error) {
type embed AutomationAddToBatchStep
var marshaler = struct {
embed
Action string `json:"action"`
}{
embed: embed(*a),
Action: "add-to-batch",
}
return json.Marshal(marshaler)
}
func (a *AutomationAddToBatchStep) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationAddToDigestStep struct {
If *string `json:"if,omitempty" url:"if,omitempty"`
Ref *string `json:"ref,omitempty" url:"ref,omitempty"`
// The subscription topic that has digests enabled
SubscriptionTopicId string `json:"subscription_topic_id" url:"subscription_topic_id"`
action string
_rawJSON json.RawMessage
}
func (a *AutomationAddToDigestStep) Action() string {
return a.action
}
func (a *AutomationAddToDigestStep) UnmarshalJSON(data []byte) error {
type embed AutomationAddToDigestStep
var unmarshaler = struct {
embed
}{
embed: embed(*a),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*a = AutomationAddToDigestStep(unmarshaler.embed)
a.action = "add-to-digest"
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationAddToDigestStep) MarshalJSON() ([]byte, error) {
type embed AutomationAddToDigestStep
var marshaler = struct {
embed
Action string `json:"action"`
}{
embed: embed(*a),
Action: "add-to-digest",
}
return json.Marshal(marshaler)
}
func (a *AutomationAddToDigestStep) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationCancelStep struct {
If *string `json:"if,omitempty" url:"if,omitempty"`
Ref *string `json:"ref,omitempty" url:"ref,omitempty"`
CancelationToken *string `json:"cancelation_token,omitempty" url:"cancelation_token,omitempty"`
action string
_rawJSON json.RawMessage
}
func (a *AutomationCancelStep) Action() string {
return a.action
}
func (a *AutomationCancelStep) UnmarshalJSON(data []byte) error {
type embed AutomationCancelStep
var unmarshaler = struct {
embed
}{
embed: embed(*a),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*a = AutomationCancelStep(unmarshaler.embed)
a.action = "cancel"
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationCancelStep) MarshalJSON() ([]byte, error) {
type embed AutomationCancelStep
var marshaler = struct {
embed
Action string `json:"action"`
}{
embed: embed(*a),
Action: "cancel",
}
return json.Marshal(marshaler)
}
func (a *AutomationCancelStep) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationDelayStep struct {
If *string `json:"if,omitempty" url:"if,omitempty"`
Ref *string `json:"ref,omitempty" url:"ref,omitempty"`
// The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string for how long to delay for
Duration *string `json:"duration,omitempty" url:"duration,omitempty"`
// The ISO 8601 timestamp for when the delay should end
Until *string `json:"until,omitempty" url:"until,omitempty"`
action string
_rawJSON json.RawMessage
}
func (a *AutomationDelayStep) Action() string {
return a.action
}
func (a *AutomationDelayStep) UnmarshalJSON(data []byte) error {
type embed AutomationDelayStep
var unmarshaler = struct {
embed
}{
embed: embed(*a),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*a = AutomationDelayStep(unmarshaler.embed)
a.action = "delay"
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationDelayStep) MarshalJSON() ([]byte, error) {
type embed AutomationDelayStep
var marshaler = struct {
embed
Action string `json:"action"`
}{
embed: embed(*a),
Action: "delay",
}
return json.Marshal(marshaler)
}
func (a *AutomationDelayStep) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationFetchDataStep struct {
If *string `json:"if,omitempty" url:"if,omitempty"`
Ref *string `json:"ref,omitempty" url:"ref,omitempty"`
Webhook *AutomationFetchDataWebhook `json:"webhook,omitempty" url:"webhook,omitempty"`
MergeStrategy MergeAlgorithm `json:"merge_strategy,omitempty" url:"merge_strategy,omitempty"`
IdempotencyExpiry *string `json:"idempotency_expiry,omitempty" url:"idempotency_expiry,omitempty"`
IdempotencyKey *string `json:"idempotency_key,omitempty" url:"idempotency_key,omitempty"`
action string
_rawJSON json.RawMessage
}
func (a *AutomationFetchDataStep) Action() string {
return a.action
}
func (a *AutomationFetchDataStep) UnmarshalJSON(data []byte) error {
type embed AutomationFetchDataStep
var unmarshaler = struct {
embed
}{
embed: embed(*a),
}
if err := json.Unmarshal(data, &unmarshaler); err != nil {
return err
}
*a = AutomationFetchDataStep(unmarshaler.embed)
a.action = "fetch-data"
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationFetchDataStep) MarshalJSON() ([]byte, error) {
type embed AutomationFetchDataStep
var marshaler = struct {
embed
Action string `json:"action"`
}{
embed: embed(*a),
Action: "fetch-data",
}
return json.Marshal(marshaler)
}
func (a *AutomationFetchDataStep) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}
return fmt.Sprintf("%#v", a)
}
type AutomationFetchDataWebhook struct {
Body map[string]interface{} `json:"body,omitempty" url:"body,omitempty"`
Headers map[string]interface{} `json:"headers,omitempty" url:"headers,omitempty"`
Params map[string]interface{} `json:"params,omitempty" url:"params,omitempty"`
Method AutomationFetchDataWebhookMethod `json:"method,omitempty" url:"method,omitempty"`
Url string `json:"url" url:"url"`
_rawJSON json.RawMessage
}
func (a *AutomationFetchDataWebhook) UnmarshalJSON(data []byte) error {
type unmarshaler AutomationFetchDataWebhook
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AutomationFetchDataWebhook(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AutomationFetchDataWebhook) String() string {
if len(a._rawJSON) > 0 {
if value, err := core.StringifyJSON(a._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(a); err == nil {
return value
}