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
|
|
|
list[i] = newEndpointResponse(&v) |
137
|
|
|
} |
138
|
|
|
result.Item = list |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
return result |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
type EndpointResponse struct { |
|
|
|
|
145
|
|
|
Address string // Email | Push Token | Tel No. |
146
|
|
|
ApplicationID string |
147
|
|
|
Attributes map[string][]string |
148
|
|
|
ChannelType ChannelType |
149
|
|
|
CohortID string |
150
|
|
|
CreationDate string |
151
|
|
|
Demographic EndpointDemographic |
152
|
|
|
EffectiveDate string |
153
|
|
|
EndpointStatus string |
154
|
|
|
ID string |
155
|
|
|
Location EndpointLocation |
156
|
|
|
Metrics map[string]float64 |
157
|
|
|
OptOut string |
158
|
|
|
RequestID string |
159
|
|
|
User EndpointUser |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
func newEndpointResponse(o *SDK.EndpointResponse) EndpointResponse { |
163
|
|
|
result := EndpointResponse{} |
164
|
|
|
if o == nil { |
165
|
|
|
return result |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
if o.Address != nil { |
169
|
|
|
result.Address = *o.Address |
170
|
|
|
} |
171
|
|
|
if o.ApplicationId != nil { |
172
|
|
|
result.ApplicationID = *o.ApplicationId |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
result.Attributes = o.Attributes |
176
|
|
|
result.ChannelType = ChannelType(o.ChannelType) |
177
|
|
|
|
178
|
|
|
if o.CohortId != nil { |
179
|
|
|
result.CohortID = *o.CohortId |
180
|
|
|
} |
181
|
|
|
if o.CreationDate != nil { |
182
|
|
|
result.CreationDate = *o.CreationDate |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
result.Demographic = newEndpointDemographic(o.Demographic) |
186
|
|
|
|
187
|
|
|
if o.EffectiveDate != nil { |
188
|
|
|
result.EffectiveDate = *o.EffectiveDate |
189
|
|
|
} |
190
|
|
|
if o.EndpointStatus != nil { |
191
|
|
|
result.EndpointStatus = *o.EndpointStatus |
192
|
|
|
} |
193
|
|
|
if o.Id != nil { |
194
|
|
|
result.ID = *o.Id |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
result.Location = newEndpointLocation(o.Location) |
198
|
|
|
result.Metrics = o.Metrics |
199
|
|
|
|
200
|
|
|
if o.OptOut != nil { |
201
|
|
|
result.OptOut = *o.OptOut |
202
|
|
|
} |
203
|
|
|
if o.RequestId != nil { |
204
|
|
|
result.RequestID = *o.RequestId |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
result.User = newEndpointUser(o.User) |
208
|
|
|
|
209
|
|
|
return result |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
type EndpointDemographic struct { |
|
|
|
|
213
|
|
|
AppVersion string |
214
|
|
|
Locale string |
215
|
|
|
Make string |
216
|
|
|
Model string |
217
|
|
|
ModelVersion string |
218
|
|
|
Platform string |
219
|
|
|
PlatformVersion string |
220
|
|
|
Timezone string |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
func newEndpointDemographic(o *SDK.EndpointDemographic) EndpointDemographic { |
224
|
|
|
result := EndpointDemographic{} |
225
|
|
|
if o.AppVersion != nil { |
226
|
|
|
result.AppVersion = *o.AppVersion |
227
|
|
|
} |
228
|
|
|
if o.Locale != nil { |
229
|
|
|
result.Locale = *o.Locale |
230
|
|
|
} |
231
|
|
|
if o.Make != nil { |
232
|
|
|
result.Make = *o.Make |
233
|
|
|
} |
234
|
|
|
if o.Model != nil { |
235
|
|
|
result.Model = *o.Model |
236
|
|
|
} |
237
|
|
|
if o.ModelVersion != nil { |
238
|
|
|
result.ModelVersion = *o.ModelVersion |
239
|
|
|
} |
240
|
|
|
if o.Platform != nil { |
241
|
|
|
result.Platform = *o.Platform |
242
|
|
|
} |
243
|
|
|
if o.PlatformVersion != nil { |
244
|
|
|
result.PlatformVersion = *o.PlatformVersion |
245
|
|
|
} |
246
|
|
|
if o.Timezone != nil { |
247
|
|
|
result.Timezone = *o.Timezone |
248
|
|
|
} |
249
|
|
|
return result |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
func (r EndpointDemographic) ToSDK() *SDK.EndpointDemographic { |
|
|
|
|
253
|
|
|
o := SDK.EndpointDemographic{} |
254
|
|
|
|
255
|
|
|
if r.AppVersion != "" { |
256
|
|
|
o.AppVersion = pointers.String(r.AppVersion) |
257
|
|
|
} |
258
|
|
|
if r.Locale != "" { |
259
|
|
|
o.Locale = pointers.String(r.Locale) |
260
|
|
|
} |
261
|
|
|
if r.Make != "" { |
262
|
|
|
o.Make = pointers.String(r.Make) |
263
|
|
|
} |
264
|
|
|
if r.Model != "" { |
265
|
|
|
o.Model = pointers.String(r.Model) |
266
|
|
|
} |
267
|
|
|
if r.ModelVersion != "" { |
268
|
|
|
o.ModelVersion = pointers.String(r.ModelVersion) |
269
|
|
|
} |
270
|
|
|
if r.Platform != "" { |
271
|
|
|
o.Platform = pointers.String(r.Platform) |
272
|
|
|
} |
273
|
|
|
if r.PlatformVersion != "" { |
274
|
|
|
o.PlatformVersion = pointers.String(r.PlatformVersion) |
275
|
|
|
} |
276
|
|
|
if r.Timezone != "" { |
277
|
|
|
o.Timezone = pointers.String(r.Timezone) |
278
|
|
|
} |
279
|
|
|
return &o |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
type EndpointLocation struct { |
|
|
|
|
283
|
|
|
City string |
284
|
|
|
Country string |
285
|
|
|
Latitude float64 |
286
|
|
|
Longitude float64 |
287
|
|
|
PostalCode string |
288
|
|
|
Region string |
289
|
|
|
|
290
|
|
|
HasLatitude bool |
291
|
|
|
HasLongitude bool |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
func newEndpointLocation(o *SDK.EndpointLocation) EndpointLocation { |
295
|
|
|
result := EndpointLocation{} |
296
|
|
|
if o.City != nil { |
297
|
|
|
result.City = *o.City |
298
|
|
|
} |
299
|
|
|
if o.Country != nil { |
300
|
|
|
result.Country = *o.Country |
301
|
|
|
} |
302
|
|
|
if o.Latitude != nil { |
303
|
|
|
result.Latitude = *o.Latitude |
304
|
|
|
} |
305
|
|
|
if o.Longitude != nil { |
306
|
|
|
result.Longitude = *o.Longitude |
307
|
|
|
} |
308
|
|
|
if o.PostalCode != nil { |
309
|
|
|
result.PostalCode = *o.PostalCode |
310
|
|
|
} |
311
|
|
|
if o.Region != nil { |
312
|
|
|
result.Region = *o.Region |
313
|
|
|
} |
314
|
|
|
return result |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
func (r EndpointLocation) ToSDK() *SDK.EndpointLocation { |
|
|
|
|
318
|
|
|
o := SDK.EndpointLocation{} |
319
|
|
|
|
320
|
|
|
if r.City != "" { |
321
|
|
|
o.City = pointers.String(r.City) |
322
|
|
|
} |
323
|
|
|
if r.Country != "" { |
324
|
|
|
o.Country = pointers.String(r.Country) |
325
|
|
|
} |
326
|
|
|
if r.PostalCode != "" { |
327
|
|
|
o.PostalCode = pointers.String(r.PostalCode) |
328
|
|
|
} |
329
|
|
|
if r.Region != "" { |
330
|
|
|
o.Region = pointers.String(r.Region) |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
if r.Latitude != 0 || r.HasLatitude { |
334
|
|
|
o.Latitude = pointers.Float64(r.Latitude) |
335
|
|
|
} |
336
|
|
|
if r.Longitude != 0 || r.HasLongitude { |
337
|
|
|
o.Longitude = pointers.Float64(r.Longitude) |
338
|
|
|
} |
339
|
|
|
return &o |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
type EndpointUser struct { |
|
|
|
|
343
|
|
|
UserAttributes map[string][]string |
344
|
|
|
UserID string |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
func newEndpointUser(o *SDK.EndpointUser) EndpointUser { |
348
|
|
|
result := EndpointUser{} |
349
|
|
|
|
350
|
|
|
result.UserAttributes = o.UserAttributes |
351
|
|
|
|
352
|
|
|
if o.UserId != nil { |
353
|
|
|
result.UserID = *o.UserId |
354
|
|
|
} |
355
|
|
|
return result |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
func (r EndpointUser) ToSDK() *SDK.EndpointUser { |
|
|
|
|
359
|
|
|
o := SDK.EndpointUser{} |
360
|
|
|
|
361
|
|
|
o.UserAttributes = r.UserAttributes |
362
|
|
|
|
363
|
|
|
if r.UserID != "" { |
364
|
|
|
o.UserId = pointers.String(r.UserID) |
365
|
|
|
} |
366
|
|
|
return &o |
367
|
|
|
} |
368
|
|
|
|