-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsend.go
More file actions
707 lines (631 loc) · 24.3 KB
/
send.go
File metadata and controls
707 lines (631 loc) · 24.3 KB
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package courier
import (
"context"
"net/http"
"slices"
"github.com/trycourier/courier-go/v4/internal/apijson"
"github.com/trycourier/courier-go/v4/internal/requestconfig"
"github.com/trycourier/courier-go/v4/option"
"github.com/trycourier/courier-go/v4/packages/param"
"github.com/trycourier/courier-go/v4/packages/respjson"
"github.com/trycourier/courier-go/v4/shared"
)
// SendService contains methods and other services that help with interacting with
// the Courier API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewSendService] method instead.
type SendService struct {
Options []option.RequestOption
}
// NewSendService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewSendService(opts ...option.RequestOption) (r SendService) {
r = SendService{}
r.Options = opts
return
}
// Send a message to one or more recipients.
func (r *SendService) Message(ctx context.Context, body SendMessageParams, opts ...option.RequestOption) (res *SendMessageResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "send"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
type SendMessageResponse struct {
// A successful call to `POST /send` returns a `202` status code along with a
// `requestId` in the response body. For single-recipient requests, the `requestId`
// is the derived message_id. For multiple recipients, Courier assigns a unique
// message_id to each derived message.
RequestID string `json:"requestId" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
RequestID respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r SendMessageResponse) RawJSON() string { return r.JSON.raw }
func (r *SendMessageResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type SendMessageParams struct {
// The message property has the following primary top-level properties. They define
// the destination and content of the message.
Message SendMessageParamsMessage `json:"message,omitzero" api:"required"`
paramObj
}
func (r SendMessageParams) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The message property has the following primary top-level properties. They define
// the destination and content of the message.
type SendMessageParamsMessage struct {
BrandID param.Opt[string] `json:"brand_id,omitzero"`
Template param.Opt[string] `json:"template,omitzero"`
Data map[string]any `json:"data,omitzero"`
Delay SendMessageParamsMessageDelay `json:"delay,omitzero"`
Expiry SendMessageParamsMessageExpiry `json:"expiry,omitzero"`
Metadata SendMessageParamsMessageMetadata `json:"metadata,omitzero"`
Preferences SendMessageParamsMessagePreferences `json:"preferences,omitzero"`
// Customize which channels/providers Courier may deliver the message through.
Routing SendMessageParamsMessageRouting `json:"routing,omitzero"`
Timeout SendMessageParamsMessageTimeout `json:"timeout,omitzero"`
// The recipient or a list of recipients of the message
To SendMessageParamsMessageToUnion `json:"to,omitzero"`
// Define run-time configuration for channels. Valid ChannelId's: email, sms, push,
// inbox, direct_message, banner, webhook.
Channels shared.MessageChannelsParam `json:"channels,omitzero"`
// Describes content that will work for email, inbox, push, chat, or any channel
// id.
Content SendMessageParamsMessageContentUnion `json:"content,omitzero"`
Context shared.MessageContextParam `json:"context,omitzero"`
Providers shared.MessageProvidersParam `json:"providers,omitzero"`
paramObj
}
func (r SendMessageParamsMessage) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessage
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessage) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type SendMessageParamsMessageContentUnion struct {
OfElementalContentSugar *shared.ElementalContentSugarParam `json:",omitzero,inline"`
OfElementalContent *shared.ElementalContentParam `json:",omitzero,inline"`
paramUnion
}
func (u SendMessageParamsMessageContentUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfElementalContentSugar, u.OfElementalContent)
}
func (u *SendMessageParamsMessageContentUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *SendMessageParamsMessageContentUnion) asAny() any {
if !param.IsOmitted(u.OfElementalContentSugar) {
return u.OfElementalContentSugar
} else if !param.IsOmitted(u.OfElementalContent) {
return u.OfElementalContent
}
return nil
}
type SendMessageParamsMessageDelay struct {
// The duration of the delay in milliseconds.
Duration param.Opt[int64] `json:"duration,omitzero"`
// IANA timezone identifier (e.g., "America/Los_Angeles", "UTC"). Used when
// resolving opening hours expressions. Takes precedence over user profile timezone
// settings.
Timezone param.Opt[string] `json:"timezone,omitzero"`
// ISO 8601 timestamp or opening_hours-like format.
Until param.Opt[string] `json:"until,omitzero"`
paramObj
}
func (r SendMessageParamsMessageDelay) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessageDelay
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessageDelay) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The property ExpiresIn is required.
type SendMessageParamsMessageExpiry struct {
// Duration in ms or ISO8601 duration (e.g. P1DT4H).
ExpiresIn SendMessageParamsMessageExpiryExpiresInUnion `json:"expires_in,omitzero" api:"required"`
// Epoch or ISO8601 timestamp with timezone.
ExpiresAt param.Opt[string] `json:"expires_at,omitzero"`
paramObj
}
func (r SendMessageParamsMessageExpiry) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessageExpiry
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessageExpiry) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type SendMessageParamsMessageExpiryExpiresInUnion struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfInt param.Opt[int64] `json:",omitzero,inline"`
paramUnion
}
func (u SendMessageParamsMessageExpiryExpiresInUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfString, u.OfInt)
}
func (u *SendMessageParamsMessageExpiryExpiresInUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *SendMessageParamsMessageExpiryExpiresInUnion) asAny() any {
if !param.IsOmitted(u.OfString) {
return &u.OfString.Value
} else if !param.IsOmitted(u.OfInt) {
return &u.OfInt.Value
}
return nil
}
type SendMessageParamsMessageMetadata struct {
Event param.Opt[string] `json:"event,omitzero"`
TraceID param.Opt[string] `json:"trace_id,omitzero"`
Tags []string `json:"tags,omitzero"`
Utm shared.UtmParam `json:"utm,omitzero"`
paramObj
}
func (r SendMessageParamsMessageMetadata) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessageMetadata
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessageMetadata) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// The property SubscriptionTopicID is required.
type SendMessageParamsMessagePreferences struct {
// The subscription topic to apply to the message.
SubscriptionTopicID string `json:"subscription_topic_id" api:"required"`
paramObj
}
func (r SendMessageParamsMessagePreferences) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessagePreferences
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessagePreferences) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Customize which channels/providers Courier may deliver the message through.
//
// The properties Channels, Method are required.
type SendMessageParamsMessageRouting struct {
// A list of channels or providers (or nested routing rules).
Channels []shared.MessageRoutingChannelUnionParam `json:"channels,omitzero" api:"required"`
// Any of "all", "single".
Method string `json:"method,omitzero" api:"required"`
paramObj
}
func (r SendMessageParamsMessageRouting) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessageRouting
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessageRouting) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
apijson.RegisterFieldValidator[SendMessageParamsMessageRouting](
"method", "all", "single",
)
}
type SendMessageParamsMessageTimeout struct {
Escalation param.Opt[int64] `json:"escalation,omitzero"`
Message param.Opt[int64] `json:"message,omitzero"`
Channel map[string]int64 `json:"channel,omitzero"`
// Any of "no-escalation", "delivered", "viewed", "engaged".
Criteria string `json:"criteria,omitzero"`
Provider map[string]int64 `json:"provider,omitzero"`
paramObj
}
func (r SendMessageParamsMessageTimeout) MarshalJSON() (data []byte, err error) {
type shadow SendMessageParamsMessageTimeout
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *SendMessageParamsMessageTimeout) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
apijson.RegisterFieldValidator[SendMessageParamsMessageTimeout](
"criteria", "no-escalation", "delivered", "viewed", "engaged",
)
}
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type SendMessageParamsMessageToUnion struct {
OfUserRecipient *shared.UserRecipientParam `json:",omitzero,inline"`
OfAudienceRecipient *shared.AudienceRecipientParam `json:",omitzero,inline"`
OfListRecipient *shared.ListRecipientParam `json:",omitzero,inline"`
OfListPatternRecipient *shared.ListPatternRecipientParam `json:",omitzero,inline"`
OfSlackRecipient *shared.SlackRecipientParam `json:",omitzero,inline"`
OfMsTeamsRecipient *shared.MsTeamsRecipientParam `json:",omitzero,inline"`
OfPagerDutyRecipient *shared.PagerdutyRecipientParam `json:",omitzero,inline"`
OfWebhookRecipient *shared.WebhookRecipientParam `json:",omitzero,inline"`
OfSendMessagesMessageToArray []SendMessageParamsMessageToArrayItemUnion `json:",omitzero,inline"`
paramUnion
}
func (u SendMessageParamsMessageToUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfUserRecipient,
u.OfAudienceRecipient,
u.OfListRecipient,
u.OfListPatternRecipient,
u.OfSlackRecipient,
u.OfMsTeamsRecipient,
u.OfPagerDutyRecipient,
u.OfWebhookRecipient,
u.OfSendMessagesMessageToArray)
}
func (u *SendMessageParamsMessageToUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *SendMessageParamsMessageToUnion) asAny() any {
if !param.IsOmitted(u.OfUserRecipient) {
return u.OfUserRecipient
} else if !param.IsOmitted(u.OfAudienceRecipient) {
return u.OfAudienceRecipient
} else if !param.IsOmitted(u.OfListRecipient) {
return u.OfListRecipient
} else if !param.IsOmitted(u.OfListPatternRecipient) {
return u.OfListPatternRecipient
} else if !param.IsOmitted(u.OfSlackRecipient) {
return u.OfSlackRecipient
} else if !param.IsOmitted(u.OfMsTeamsRecipient) {
return u.OfMsTeamsRecipient
} else if !param.IsOmitted(u.OfPagerDutyRecipient) {
return u.OfPagerDutyRecipient
} else if !param.IsOmitted(u.OfWebhookRecipient) {
return u.OfWebhookRecipient
} else if !param.IsOmitted(u.OfSendMessagesMessageToArray) {
return &u.OfSendMessagesMessageToArray
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetAccountID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.AccountID.Valid() {
return &vt.AccountID.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetContext() *shared.MessageContextParam {
if vt := u.OfUserRecipient; vt != nil {
return &vt.Context
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetEmail() *string {
if vt := u.OfUserRecipient; vt != nil && vt.Email.Valid() {
return &vt.Email.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetLocale() *string {
if vt := u.OfUserRecipient; vt != nil && vt.Locale.Valid() {
return &vt.Locale.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetPhoneNumber() *string {
if vt := u.OfUserRecipient; vt != nil && vt.PhoneNumber.Valid() {
return &vt.PhoneNumber.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetPreferences() *shared.UserRecipientPreferencesParam {
if vt := u.OfUserRecipient; vt != nil {
return &vt.Preferences
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetTenantID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.TenantID.Valid() {
return &vt.TenantID.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetUserID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.UserID.Valid() {
return &vt.UserID.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetAudienceID() *string {
if vt := u.OfAudienceRecipient; vt != nil {
return &vt.AudienceID
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetListPattern() *string {
if vt := u.OfListPatternRecipient; vt != nil && vt.ListPattern.Valid() {
return &vt.ListPattern.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetSlack() *shared.SlackUnionParam {
if vt := u.OfSlackRecipient; vt != nil {
return &vt.Slack
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetMsTeams() *shared.MsTeamsUnionParam {
if vt := u.OfMsTeamsRecipient; vt != nil {
return &vt.MsTeams
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetPagerduty() *shared.PagerdutyParam {
if vt := u.OfPagerDutyRecipient; vt != nil {
return &vt.Pagerduty
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetWebhook() *shared.WebhookProfileParam {
if vt := u.OfWebhookRecipient; vt != nil {
return &vt.Webhook
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToUnion) GetListID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.ListID.Valid() {
return &vt.ListID.Value
} else if vt := u.OfListRecipient; vt != nil && vt.ListID.Valid() {
return &vt.ListID.Value
}
return nil
}
// Returns a pointer to the underlying variant's Data property, if present.
func (u SendMessageParamsMessageToUnion) GetData() map[string]any {
if vt := u.OfUserRecipient; vt != nil {
return vt.Data
} else if vt := u.OfAudienceRecipient; vt != nil {
return vt.Data
} else if vt := u.OfListRecipient; vt != nil {
return vt.Data
} else if vt := u.OfListPatternRecipient; vt != nil {
return vt.Data
}
return nil
}
// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u SendMessageParamsMessageToUnion) GetFilters() (res sendMessageParamsMessageToUnionFilters) {
if vt := u.OfAudienceRecipient; vt != nil {
res.any = &vt.Filters
} else if vt := u.OfListRecipient; vt != nil {
res.any = &vt.Filters
}
return
}
// Can have the runtime types [_[]shared.AudienceFilterParam],
// [_[]shared.ListFilterParam]
type sendMessageParamsMessageToUnionFilters struct{ any }
// Use the following switch statement to get the type of the union:
//
// switch u.AsAny().(type) {
// case *[]shared.AudienceFilterParam:
// case *[]shared.ListFilterParam:
// default:
// fmt.Errorf("not present")
// }
func (u sendMessageParamsMessageToUnionFilters) AsAny() any { return u.any }
// Only one field can be non-zero.
//
// Use [param.IsOmitted] to confirm if a field is set.
type SendMessageParamsMessageToArrayItemUnion struct {
OfUserRecipient *shared.UserRecipientParam `json:",omitzero,inline"`
OfAudienceRecipient *shared.AudienceRecipientParam `json:",omitzero,inline"`
OfListRecipient *shared.ListRecipientParam `json:",omitzero,inline"`
OfListPatternRecipient *shared.ListPatternRecipientParam `json:",omitzero,inline"`
OfSlackRecipient *shared.SlackRecipientParam `json:",omitzero,inline"`
OfMsTeamsRecipient *shared.MsTeamsRecipientParam `json:",omitzero,inline"`
OfPagerDutyRecipient *shared.PagerdutyRecipientParam `json:",omitzero,inline"`
OfWebhookRecipient *shared.WebhookRecipientParam `json:",omitzero,inline"`
paramUnion
}
func (u SendMessageParamsMessageToArrayItemUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfUserRecipient,
u.OfAudienceRecipient,
u.OfListRecipient,
u.OfListPatternRecipient,
u.OfSlackRecipient,
u.OfMsTeamsRecipient,
u.OfPagerDutyRecipient,
u.OfWebhookRecipient)
}
func (u *SendMessageParamsMessageToArrayItemUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
func (u *SendMessageParamsMessageToArrayItemUnion) asAny() any {
if !param.IsOmitted(u.OfUserRecipient) {
return u.OfUserRecipient
} else if !param.IsOmitted(u.OfAudienceRecipient) {
return u.OfAudienceRecipient
} else if !param.IsOmitted(u.OfListRecipient) {
return u.OfListRecipient
} else if !param.IsOmitted(u.OfListPatternRecipient) {
return u.OfListPatternRecipient
} else if !param.IsOmitted(u.OfSlackRecipient) {
return u.OfSlackRecipient
} else if !param.IsOmitted(u.OfMsTeamsRecipient) {
return u.OfMsTeamsRecipient
} else if !param.IsOmitted(u.OfPagerDutyRecipient) {
return u.OfPagerDutyRecipient
} else if !param.IsOmitted(u.OfWebhookRecipient) {
return u.OfWebhookRecipient
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetAccountID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.AccountID.Valid() {
return &vt.AccountID.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetContext() *shared.MessageContextParam {
if vt := u.OfUserRecipient; vt != nil {
return &vt.Context
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetEmail() *string {
if vt := u.OfUserRecipient; vt != nil && vt.Email.Valid() {
return &vt.Email.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetLocale() *string {
if vt := u.OfUserRecipient; vt != nil && vt.Locale.Valid() {
return &vt.Locale.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetPhoneNumber() *string {
if vt := u.OfUserRecipient; vt != nil && vt.PhoneNumber.Valid() {
return &vt.PhoneNumber.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetPreferences() *shared.UserRecipientPreferencesParam {
if vt := u.OfUserRecipient; vt != nil {
return &vt.Preferences
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetTenantID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.TenantID.Valid() {
return &vt.TenantID.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetUserID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.UserID.Valid() {
return &vt.UserID.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetAudienceID() *string {
if vt := u.OfAudienceRecipient; vt != nil {
return &vt.AudienceID
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetListPattern() *string {
if vt := u.OfListPatternRecipient; vt != nil && vt.ListPattern.Valid() {
return &vt.ListPattern.Value
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetSlack() *shared.SlackUnionParam {
if vt := u.OfSlackRecipient; vt != nil {
return &vt.Slack
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetMsTeams() *shared.MsTeamsUnionParam {
if vt := u.OfMsTeamsRecipient; vt != nil {
return &vt.MsTeams
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetPagerduty() *shared.PagerdutyParam {
if vt := u.OfPagerDutyRecipient; vt != nil {
return &vt.Pagerduty
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetWebhook() *shared.WebhookProfileParam {
if vt := u.OfWebhookRecipient; vt != nil {
return &vt.Webhook
}
return nil
}
// Returns a pointer to the underlying variant's property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetListID() *string {
if vt := u.OfUserRecipient; vt != nil && vt.ListID.Valid() {
return &vt.ListID.Value
} else if vt := u.OfListRecipient; vt != nil && vt.ListID.Valid() {
return &vt.ListID.Value
}
return nil
}
// Returns a pointer to the underlying variant's Data property, if present.
func (u SendMessageParamsMessageToArrayItemUnion) GetData() map[string]any {
if vt := u.OfUserRecipient; vt != nil {
return vt.Data
} else if vt := u.OfAudienceRecipient; vt != nil {
return vt.Data
} else if vt := u.OfListRecipient; vt != nil {
return vt.Data
} else if vt := u.OfListPatternRecipient; vt != nil {
return vt.Data
}
return nil
}
// Returns a subunion which exports methods to access subproperties
//
// Or use AsAny() to get the underlying value
func (u SendMessageParamsMessageToArrayItemUnion) GetFilters() (res sendMessageParamsMessageToArrayItemUnionFilters) {
if vt := u.OfAudienceRecipient; vt != nil {
res.any = &vt.Filters
} else if vt := u.OfListRecipient; vt != nil {
res.any = &vt.Filters
}
return
}
// Can have the runtime types [_[]shared.AudienceFilterParam],
// [_[]shared.ListFilterParam]
type sendMessageParamsMessageToArrayItemUnionFilters struct{ any }
// Use the following switch statement to get the type of the union:
//
// switch u.AsAny().(type) {
// case *[]shared.AudienceFilterParam:
// case *[]shared.ListFilterParam:
// default:
// fmt.Errorf("not present")
// }
func (u sendMessageParamsMessageToArrayItemUnionFilters) AsAny() any { return u.any }