-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathaudiences.go
197 lines (171 loc) · 5.27 KB
/
audiences.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
// 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 AudiencesListParams struct {
// A unique identifier that allows for fetching the next set of audiences
Cursor *string `json:"-" url:"cursor,omitempty"`
}
type AudienceMembersListParams struct {
// A unique identifier that allows for fetching the next set of members
Cursor *string `json:"-" url:"cursor,omitempty"`
}
type Audience struct {
// A unique identifier representing the audience_id
Id string `json:"id" url:"id"`
// The name of the audience
Name string `json:"name" url:"name"`
// A description of the audience
Description string `json:"description" url:"description"`
Filter *Filter `json:"filter,omitempty" url:"filter,omitempty"`
CreatedAt string `json:"created_at" url:"created_at"`
UpdatedAt string `json:"updated_at" url:"updated_at"`
_rawJSON json.RawMessage
}
func (a *Audience) UnmarshalJSON(data []byte) error {
type unmarshaler Audience
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = Audience(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *Audience) 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 AudienceListResponse struct {
Items []*Audience `json:"items,omitempty" url:"items,omitempty"`
Paging *Paging `json:"paging,omitempty" url:"paging,omitempty"`
_rawJSON json.RawMessage
}
func (a *AudienceListResponse) UnmarshalJSON(data []byte) error {
type unmarshaler AudienceListResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AudienceListResponse(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AudienceListResponse) 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 AudienceMemberListResponse struct {
Items []*AudienceMember `json:"items,omitempty" url:"items,omitempty"`
Paging *Paging `json:"paging,omitempty" url:"paging,omitempty"`
_rawJSON json.RawMessage
}
func (a *AudienceMemberListResponse) UnmarshalJSON(data []byte) error {
type unmarshaler AudienceMemberListResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AudienceMemberListResponse(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AudienceMemberListResponse) 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 AudienceUpdateResponse struct {
Audience *Audience `json:"audience,omitempty" url:"audience,omitempty"`
_rawJSON json.RawMessage
}
func (a *AudienceUpdateResponse) UnmarshalJSON(data []byte) error {
type unmarshaler AudienceUpdateResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*a = AudienceUpdateResponse(value)
a._rawJSON = json.RawMessage(data)
return nil
}
func (a *AudienceUpdateResponse) 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 Filter struct {
SingleFilterConfig *SingleFilterConfig
NestedFilterConfig *NestedFilterConfig
}
func (f *Filter) 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 Filter) 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 FilterVisitor interface {
VisitSingleFilterConfig(*SingleFilterConfig) error
VisitNestedFilterConfig(*NestedFilterConfig) error
}
func (f *Filter) Accept(visitor FilterVisitor) 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 AudienceUpdateParams struct {
// The name of the audience
Name *string `json:"name,omitempty" url:"name,omitempty"`
// A description of the audience
Description *string `json:"description,omitempty" url:"description,omitempty"`
Filter *Filter `json:"filter,omitempty" url:"filter,omitempty"`
}