|
1
|
|
|
package pinpoint |
|
2
|
|
|
|
|
3
|
|
|
import ( |
|
4
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/pinpoint" |
|
5
|
|
|
|
|
6
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
|
7
|
|
|
) |
|
8
|
|
|
|
|
9
|
|
|
type EndpointRequest struct { |
|
|
|
|
|
|
10
|
|
|
Address string // Email | Push Token | Tel No. |
|
11
|
|
|
Attributes map[string][]string |
|
12
|
|
|
ChannelType ChannelType |
|
13
|
|
|
Demographic EndpointDemographic |
|
14
|
|
|
EffectiveDate string |
|
15
|
|
|
EndpointStatus string |
|
16
|
|
|
Location EndpointLocation |
|
17
|
|
|
Metrics map[string]float64 |
|
18
|
|
|
OptOut string |
|
19
|
|
|
RequestID string |
|
20
|
|
|
User EndpointUser |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
func (r EndpointRequest) ToSDK() *SDK.EndpointRequest { |
|
|
|
|
|
|
24
|
|
|
o := SDK.EndpointRequest{} |
|
25
|
|
|
|
|
26
|
|
|
if r.Address != "" { |
|
27
|
|
|
o.Address = pointers.String(r.Address) |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
o.Attributes = r.Attributes |
|
31
|
|
|
o.ChannelType = SDK.ChannelType(r.ChannelType) |
|
32
|
|
|
o.Demographic = r.Demographic.ToSDK() |
|
33
|
|
|
|
|
34
|
|
|
if r.EffectiveDate != "" { |
|
35
|
|
|
o.EffectiveDate = pointers.String(r.EffectiveDate) |
|
36
|
|
|
} |
|
37
|
|
|
if r.EndpointStatus != "" { |
|
38
|
|
|
o.EndpointStatus = pointers.String(r.EndpointStatus) |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
o.Location = r.Location.ToSDK() |
|
42
|
|
|
o.Metrics = r.Metrics |
|
43
|
|
|
|
|
44
|
|
|
if r.OptOut != "" { |
|
45
|
|
|
o.OptOut = pointers.String(r.OptOut) |
|
46
|
|
|
} |
|
47
|
|
|
if r.RequestID != "" { |
|
48
|
|
|
o.RequestId = pointers.String(r.RequestID) |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
o.User = r.User.ToSDK() |
|
52
|
|
|
return &o |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
type EndpointBatchRequest struct { |
|
|
|
|
|
|
56
|
|
|
Item []EndpointBatchItem // max: 100 |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
func (r EndpointBatchRequest) ToSDK() *SDK.EndpointBatchRequest { |
|
|
|
|
|
|
60
|
|
|
o := SDK.EndpointBatchRequest{} |
|
61
|
|
|
|
|
62
|
|
|
if len(r.Item) != 0 { |
|
63
|
|
|
list := make([]SDK.EndpointBatchItem, len(r.Item)) |
|
64
|
|
|
for i, v := range r.Item { |
|
65
|
|
|
list[i] = v.ToSDK() |
|
66
|
|
|
} |
|
67
|
|
|
o.Item = list |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return &o |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
type EndpointBatchItem struct { |
|
|
|
|
|
|
74
|
|
|
Address string // Email | Push Token | Tel No. |
|
75
|
|
|
Attributes map[string][]string |
|
76
|
|
|
ChannelType ChannelType |
|
77
|
|
|
Demographic EndpointDemographic |
|
78
|
|
|
EffectiveDate string |
|
79
|
|
|
EndpointStatus string |
|
80
|
|
|
ID string |
|
81
|
|
|
Location EndpointLocation |
|
82
|
|
|
Metrics map[string]float64 |
|
83
|
|
|
OptOut string |
|
84
|
|
|
RequestID string |
|
85
|
|
|
User EndpointUser |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
func (r EndpointBatchItem) ToSDK() SDK.EndpointBatchItem { |
|
|
|
|
|
|
89
|
|
|
o := SDK.EndpointBatchItem{} |
|
90
|
|
|
|
|
91
|
|
|
if r.Address != "" { |
|
92
|
|
|
o.Address = pointers.String(r.Address) |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
o.Attributes = r.Attributes |
|
96
|
|
|
o.ChannelType = SDK.ChannelType(r.ChannelType) |
|
97
|
|
|
o.Demographic = r.Demographic.ToSDK() |
|
98
|
|
|
|
|
99
|
|
|
if r.EffectiveDate != "" { |
|
100
|
|
|
o.EffectiveDate = pointers.String(r.EffectiveDate) |
|
101
|
|
|
} |
|
102
|
|
|
if r.EndpointStatus != "" { |
|
103
|
|
|
o.EndpointStatus = pointers.String(r.EndpointStatus) |
|
104
|
|
|
} |
|
105
|
|
|
if r.ID != "" { |
|
106
|
|
|
o.Id = pointers.String(r.ID) |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
o.Location = r.Location.ToSDK() |
|
110
|
|
|
o.Metrics = r.Metrics |
|
111
|
|
|
|
|
112
|
|
|
if r.OptOut != "" { |
|
113
|
|
|
o.OptOut = pointers.String(r.OptOut) |
|
114
|
|
|
} |
|
115
|
|
|
if r.RequestID != "" { |
|
116
|
|
|
o.RequestId = pointers.String(r.RequestID) |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
o.User = r.User.ToSDK() |
|
120
|
|
|
return o |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
type EndpointsResponse struct { |
|
|
|
|
|
|
124
|
|
|
Item []EndpointResponse |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
func newEndpointsResponse(o *SDK.EndpointsResponse) EndpointsResponse { |
|
128
|
|
|
result := EndpointsResponse{} |
|
129
|
|
|
if o == nil { |
|
130
|
|
|
return result |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
if len(o.Item) != 0 { |
|
134
|
|
|
list := make([]EndpointResponse, len(o.Item)) |
|
135
|
|
|
for i, v := range o.Item { |
|
136
|
|
|
v := v |
|
137
|
|
|
list[i] = newEndpointResponse(&v) |
|
138
|
|
|
} |
|
139
|
|
|
result.Item = list |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
return result |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
type EndpointResponse struct { |
|
|
|
|
|
|
146
|
|
|
Address string // Email | Push Token | Tel No. |
|
147
|
|
|
ApplicationID string |
|
148
|
|
|
Attributes map[string][]string |
|
149
|
|
|
ChannelType ChannelType |
|
150
|
|
|
CohortID string |
|
151
|
|
|
CreationDate string |
|
152
|
|
|
Demographic EndpointDemographic |
|
153
|
|
|
EffectiveDate string |
|
154
|
|
|
EndpointStatus string |
|
155
|
|
|
ID string |
|
156
|
|
|
Location EndpointLocation |
|
157
|
|
|
Metrics map[string]float64 |
|
158
|
|
|
OptOut string |
|
159
|
|
|
RequestID string |
|
160
|
|
|
User EndpointUser |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
func newEndpointResponse(o *SDK.EndpointResponse) EndpointResponse { |
|
164
|
|
|
result := EndpointResponse{} |
|
165
|
|
|
if o == nil { |
|
166
|
|
|
return result |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
if o.Address != nil { |
|
170
|
|
|
result.Address = *o.Address |
|
171
|
|
|
} |
|
172
|
|
|
if o.ApplicationId != nil { |
|
173
|
|
|
result.ApplicationID = *o.ApplicationId |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
result.Attributes = o.Attributes |
|
177
|
|
|
result.ChannelType = ChannelType(o.ChannelType) |
|
178
|
|
|
|
|
179
|
|
|
if o.CohortId != nil { |
|
180
|
|
|
result.CohortID = *o.CohortId |
|
181
|
|
|
} |
|
182
|
|
|
if o.CreationDate != nil { |
|
183
|
|
|
result.CreationDate = *o.CreationDate |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
result.Demographic = newEndpointDemographic(o.Demographic) |
|
187
|
|
|
|
|
188
|
|
|
if o.EffectiveDate != nil { |
|
189
|
|
|
result.EffectiveDate = *o.EffectiveDate |
|
190
|
|
|
} |
|
191
|
|
|
if o.EndpointStatus != nil { |
|
192
|
|
|
result.EndpointStatus = *o.EndpointStatus |
|
193
|
|
|
} |
|
194
|
|
|
if o.Id != nil { |
|
195
|
|
|
result.ID = *o.Id |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
result.Location = newEndpointLocation(o.Location) |
|
199
|
|
|
result.Metrics = o.Metrics |
|
200
|
|
|
|
|
201
|
|
|
if o.OptOut != nil { |
|
202
|
|
|
result.OptOut = *o.OptOut |
|
203
|
|
|
} |
|
204
|
|
|
if o.RequestId != nil { |
|
205
|
|
|
result.RequestID = *o.RequestId |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
result.User = newEndpointUser(o.User) |
|
209
|
|
|
|
|
210
|
|
|
return result |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
type EndpointDemographic struct { |
|
|
|
|
|
|
214
|
|
|
AppVersion string |
|
215
|
|
|
Locale string |
|
216
|
|
|
Make string |
|
217
|
|
|
Model string |
|
218
|
|
|
ModelVersion string |
|
219
|
|
|
Platform string |
|
220
|
|
|
PlatformVersion string |
|
221
|
|
|
Timezone string |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
func newEndpointDemographic(o *SDK.EndpointDemographic) EndpointDemographic { |
|
225
|
|
|
result := EndpointDemographic{} |
|
226
|
|
|
if o.AppVersion != nil { |
|
227
|
|
|
result.AppVersion = *o.AppVersion |
|
228
|
|
|
} |
|
229
|
|
|
if o.Locale != nil { |
|
230
|
|
|
result.Locale = *o.Locale |
|
231
|
|
|
} |
|
232
|
|
|
if o.Make != nil { |
|
233
|
|
|
result.Make = *o.Make |
|
234
|
|
|
} |
|
235
|
|
|
if o.Model != nil { |
|
236
|
|
|
result.Model = *o.Model |
|
237
|
|
|
} |
|
238
|
|
|
if o.ModelVersion != nil { |
|
239
|
|
|
result.ModelVersion = *o.ModelVersion |
|
240
|
|
|
} |
|
241
|
|
|
if o.Platform != nil { |
|
242
|
|
|
result.Platform = *o.Platform |
|
243
|
|
|
} |
|
244
|
|
|
if o.PlatformVersion != nil { |
|
245
|
|
|
result.PlatformVersion = *o.PlatformVersion |
|
246
|
|
|
} |
|
247
|
|
|
if o.Timezone != nil { |
|
248
|
|
|
result.Timezone = *o.Timezone |
|
249
|
|
|
} |
|
250
|
|
|
return result |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
func (r EndpointDemographic) ToSDK() *SDK.EndpointDemographic { |
|
|
|
|
|
|
254
|
|
|
o := SDK.EndpointDemographic{} |
|
255
|
|
|
|
|
256
|
|
|
if r.AppVersion != "" { |
|
257
|
|
|
o.AppVersion = pointers.String(r.AppVersion) |
|
258
|
|
|
} |
|
259
|
|
|
if r.Locale != "" { |
|
260
|
|
|
o.Locale = pointers.String(r.Locale) |
|
261
|
|
|
} |
|
262
|
|
|
if r.Make != "" { |
|
263
|
|
|
o.Make = pointers.String(r.Make) |
|
264
|
|
|
} |
|
265
|
|
|
if r.Model != "" { |
|
266
|
|
|
o.Model = pointers.String(r.Model) |
|
267
|
|
|
} |
|
268
|
|
|
if r.ModelVersion != "" { |
|
269
|
|
|
o.ModelVersion = pointers.String(r.ModelVersion) |
|
270
|
|
|
} |
|
271
|
|
|
if r.Platform != "" { |
|
272
|
|
|
o.Platform = pointers.String(r.Platform) |
|
273
|
|
|
} |
|
274
|
|
|
if r.PlatformVersion != "" { |
|
275
|
|
|
o.PlatformVersion = pointers.String(r.PlatformVersion) |
|
276
|
|
|
} |
|
277
|
|
|
if r.Timezone != "" { |
|
278
|
|
|
o.Timezone = pointers.String(r.Timezone) |
|
279
|
|
|
} |
|
280
|
|
|
return &o |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
type EndpointLocation struct { |
|
|
|
|
|
|
284
|
|
|
City string |
|
285
|
|
|
Country string |
|
286
|
|
|
Latitude float64 |
|
287
|
|
|
Longitude float64 |
|
288
|
|
|
PostalCode string |
|
289
|
|
|
Region string |
|
290
|
|
|
|
|
291
|
|
|
HasLatitude bool |
|
292
|
|
|
HasLongitude bool |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
func newEndpointLocation(o *SDK.EndpointLocation) EndpointLocation { |
|
296
|
|
|
result := EndpointLocation{} |
|
297
|
|
|
if o.City != nil { |
|
298
|
|
|
result.City = *o.City |
|
299
|
|
|
} |
|
300
|
|
|
if o.Country != nil { |
|
301
|
|
|
result.Country = *o.Country |
|
302
|
|
|
} |
|
303
|
|
|
if o.Latitude != nil { |
|
304
|
|
|
result.Latitude = *o.Latitude |
|
305
|
|
|
} |
|
306
|
|
|
if o.Longitude != nil { |
|
307
|
|
|
result.Longitude = *o.Longitude |
|
308
|
|
|
} |
|
309
|
|
|
if o.PostalCode != nil { |
|
310
|
|
|
result.PostalCode = *o.PostalCode |
|
311
|
|
|
} |
|
312
|
|
|
if o.Region != nil { |
|
313
|
|
|
result.Region = *o.Region |
|
314
|
|
|
} |
|
315
|
|
|
return result |
|
316
|
|
|
} |
|
317
|
|
|
|
|
318
|
|
|
func (r EndpointLocation) ToSDK() *SDK.EndpointLocation { |
|
|
|
|
|
|
319
|
|
|
o := SDK.EndpointLocation{} |
|
320
|
|
|
|
|
321
|
|
|
if r.City != "" { |
|
322
|
|
|
o.City = pointers.String(r.City) |
|
323
|
|
|
} |
|
324
|
|
|
if r.Country != "" { |
|
325
|
|
|
o.Country = pointers.String(r.Country) |
|
326
|
|
|
} |
|
327
|
|
|
if r.PostalCode != "" { |
|
328
|
|
|
o.PostalCode = pointers.String(r.PostalCode) |
|
329
|
|
|
} |
|
330
|
|
|
if r.Region != "" { |
|
331
|
|
|
o.Region = pointers.String(r.Region) |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
if r.Latitude != 0 || r.HasLatitude { |
|
335
|
|
|
o.Latitude = pointers.Float64(r.Latitude) |
|
336
|
|
|
} |
|
337
|
|
|
if r.Longitude != 0 || r.HasLongitude { |
|
338
|
|
|
o.Longitude = pointers.Float64(r.Longitude) |
|
339
|
|
|
} |
|
340
|
|
|
return &o |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
type EndpointUser struct { |
|
|
|
|
|
|
344
|
|
|
UserAttributes map[string][]string |
|
345
|
|
|
UserID string |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
func newEndpointUser(o *SDK.EndpointUser) EndpointUser { |
|
349
|
|
|
result := EndpointUser{} |
|
350
|
|
|
|
|
351
|
|
|
result.UserAttributes = o.UserAttributes |
|
352
|
|
|
|
|
353
|
|
|
if o.UserId != nil { |
|
354
|
|
|
result.UserID = *o.UserId |
|
355
|
|
|
} |
|
356
|
|
|
return result |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
func (r EndpointUser) ToSDK() *SDK.EndpointUser { |
|
|
|
|
|
|
360
|
|
|
o := SDK.EndpointUser{} |
|
361
|
|
|
|
|
362
|
|
|
o.UserAttributes = r.UserAttributes |
|
363
|
|
|
|
|
364
|
|
|
if r.UserID != "" { |
|
365
|
|
|
o.UserId = pointers.String(r.UserID) |
|
366
|
|
|
} |
|
367
|
|
|
return &o |
|
368
|
|
|
} |
|
369
|
|
|
|