1
|
|
|
package pinpoint |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/pinpoint" |
5
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
6
|
|
|
) |
7
|
|
|
|
8
|
|
|
type GPSPointDimension struct { |
|
|
|
|
9
|
|
|
CoordinatesLatitude float64 |
10
|
|
|
CoordinatesLongitude float64 |
11
|
|
|
|
12
|
|
|
// optional |
13
|
|
|
RangeInKilometers float64 |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
func newGPSPointDimension(o *SDK.GPSPointDimension) GPSPointDimension { |
17
|
|
|
result := GPSPointDimension{} |
18
|
|
|
if o == nil { |
19
|
|
|
return result |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
if v := o.Coordinates; v != nil { |
23
|
|
|
if v.Latitude != nil { |
24
|
|
|
result.CoordinatesLatitude = *v.Latitude |
25
|
|
|
} |
26
|
|
|
if v.Longitude != nil { |
27
|
|
|
result.CoordinatesLongitude = *v.Longitude |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
if o.RangeInKilometers != nil { |
32
|
|
|
result.RangeInKilometers = *o.RangeInKilometers |
33
|
|
|
} |
34
|
|
|
return result |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
func (r GPSPointDimension) ToSDK() *SDK.GPSPointDimension { |
|
|
|
|
38
|
|
|
o := SDK.GPSPointDimension{} |
39
|
|
|
|
40
|
|
|
o.Coordinates = &SDK.GPSCoordinates{ |
41
|
|
|
Latitude: pointers.Float64(r.CoordinatesLatitude), |
42
|
|
|
Longitude: pointers.Float64(r.CoordinatesLongitude), |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if r.RangeInKilometers != 0 { |
46
|
|
|
o.RangeInKilometers = pointers.Float64(r.RangeInKilometers) |
47
|
|
|
} |
48
|
|
|
return &o |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
type SegmentBehaviors struct { |
|
|
|
|
52
|
|
|
RecencyDuration Duration |
53
|
|
|
RecencyType RecencyType |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
func newSegmentBehaviors(o *SDK.SegmentBehaviors) SegmentBehaviors { |
57
|
|
|
result := SegmentBehaviors{} |
58
|
|
|
if o == nil { |
59
|
|
|
return result |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if o.Recency != nil { |
63
|
|
|
result.RecencyDuration = Duration(o.Recency.Duration) |
64
|
|
|
result.RecencyType = RecencyType(o.Recency.RecencyType) |
65
|
|
|
} |
66
|
|
|
return result |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
func (r SegmentBehaviors) ToSDK() *SDK.SegmentBehaviors { |
|
|
|
|
70
|
|
|
o := SDK.SegmentBehaviors{} |
71
|
|
|
|
72
|
|
|
o.Recency.Duration = SDK.Duration(r.RecencyDuration) |
73
|
|
|
o.Recency.RecencyType = SDK.RecencyType(r.RecencyType) |
74
|
|
|
return &o |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
type SegmentDemographics struct { |
|
|
|
|
78
|
|
|
AppVersion SetDimension |
79
|
|
|
Channel SetDimension |
80
|
|
|
DeviceType SetDimension |
81
|
|
|
Make SetDimension |
82
|
|
|
Model SetDimension |
83
|
|
|
Platform SetDimension |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
func newSegmentDemographics(o *SDK.SegmentDemographics) SegmentDemographics { |
87
|
|
|
result := SegmentDemographics{} |
88
|
|
|
if o == nil { |
89
|
|
|
return result |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
result.AppVersion = newSetDimension(o.AppVersion) |
93
|
|
|
result.Channel = newSetDimension(o.Channel) |
94
|
|
|
result.DeviceType = newSetDimension(o.DeviceType) |
95
|
|
|
result.Make = newSetDimension(o.Make) |
96
|
|
|
result.Model = newSetDimension(o.Model) |
97
|
|
|
result.Platform = newSetDimension(o.Platform) |
98
|
|
|
return result |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
func (r SegmentDemographics) ToSDK() *SDK.SegmentDemographics { |
|
|
|
|
102
|
|
|
o := SDK.SegmentDemographics{} |
103
|
|
|
|
104
|
|
|
o.AppVersion = r.AppVersion.ToSDK() |
105
|
|
|
o.Channel = r.Channel.ToSDK() |
106
|
|
|
o.DeviceType = r.DeviceType.ToSDK() |
107
|
|
|
o.Make = r.Make.ToSDK() |
108
|
|
|
o.Model = r.Model.ToSDK() |
109
|
|
|
o.Platform = r.Platform.ToSDK() |
110
|
|
|
return &o |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
type SegmentDimensions struct { |
|
|
|
|
114
|
|
|
Attributes map[string]AttributeDimension |
115
|
|
|
Behavior SegmentBehaviors |
116
|
|
|
Demographic SegmentDemographics |
117
|
|
|
Location SegmentLocation |
118
|
|
|
Metrics map[string]MetricDimension |
119
|
|
|
UserAttributes map[string]AttributeDimension |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
func newSegmentDimensions(o *SDK.SegmentDimensions) SegmentDimensions { |
123
|
|
|
result := SegmentDimensions{} |
124
|
|
|
if o == nil { |
125
|
|
|
return result |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
result.Attributes = newAttributeDimensionMap(o.Attributes) |
129
|
|
|
result.Behavior = newSegmentBehaviors(o.Behavior) |
130
|
|
|
result.Demographic = newSegmentDemographics(o.Demographic) |
131
|
|
|
result.Location = newSegmentLocation(o.Location) |
132
|
|
|
result.Metrics = newMetricDimensionMap(o.Metrics) |
133
|
|
|
result.UserAttributes = newAttributeDimensionMap(o.UserAttributes) |
134
|
|
|
return result |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
func (r SegmentDimensions) ToSDK() SDK.SegmentDimensions { |
|
|
|
|
138
|
|
|
o := SDK.SegmentDimensions{} |
139
|
|
|
|
140
|
|
|
o.Attributes = attributeDimensionMapToSDK(r.Attributes) |
141
|
|
|
o.Behavior = r.Behavior.ToSDK() |
142
|
|
|
o.Demographic = r.Demographic.ToSDK() |
143
|
|
|
o.Location = r.Location.ToSDK() |
144
|
|
|
o.Metrics = metricDimensionMapToSDK(r.Metrics) |
145
|
|
|
o.UserAttributes = attributeDimensionMapToSDK(r.UserAttributes) |
146
|
|
|
return o |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
type SegmentImportResource struct { |
|
|
|
|
150
|
|
|
Format Format |
151
|
|
|
RoleARN string |
152
|
|
|
S3URL string |
153
|
|
|
Size int64 |
154
|
|
|
|
155
|
|
|
// optional |
156
|
|
|
ChannelCounts map[string]int64 |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
func newSegmentImportResource(o *SDK.SegmentImportResource) SegmentImportResource { |
160
|
|
|
result := SegmentImportResource{} |
161
|
|
|
if o == nil { |
162
|
|
|
return result |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
result.Format = Format(o.Format) |
166
|
|
|
|
167
|
|
|
if o.RoleArn != nil { |
168
|
|
|
result.RoleARN = *o.RoleArn |
169
|
|
|
} |
170
|
|
|
if o.S3Url != nil { |
171
|
|
|
result.S3URL = *o.S3Url |
172
|
|
|
} |
173
|
|
|
if o.Size != nil { |
174
|
|
|
result.Size = *o.Size |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
result.ChannelCounts = o.ChannelCounts |
178
|
|
|
return result |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
type SegmentGroup struct { |
|
|
|
|
182
|
|
|
Dimensions []SegmentDimensions |
183
|
|
|
SourceSegments []SegmentReference |
184
|
|
|
SourceType SourceType |
185
|
|
|
Type Type |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
func newSegmentGroup(o *SDK.SegmentGroup) SegmentGroup { |
189
|
|
|
result := SegmentGroup{} |
190
|
|
|
if o == nil { |
191
|
|
|
return result |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
if len(o.Dimensions) != 0 { |
195
|
|
|
list := make([]SegmentDimensions, len(o.Dimensions)) |
196
|
|
|
for i, v := range o.Dimensions { |
197
|
|
|
v := v |
198
|
|
|
list[i] = newSegmentDimensions(&v) |
199
|
|
|
} |
200
|
|
|
result.Dimensions = list |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
if len(o.SourceSegments) != 0 { |
204
|
|
|
list := make([]SegmentReference, len(o.SourceSegments)) |
205
|
|
|
for i, v := range o.SourceSegments { |
206
|
|
|
v := v |
207
|
|
|
list[i] = newSegmentReference(&v) |
208
|
|
|
} |
209
|
|
|
result.SourceSegments = list |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
result.SourceType = SourceType(o.SourceType) |
213
|
|
|
result.Type = Type(o.Type) |
214
|
|
|
return result |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
func (r SegmentGroup) ToSDK() SDK.SegmentGroup { |
|
|
|
|
218
|
|
|
o := SDK.SegmentGroup{} |
219
|
|
|
|
220
|
|
|
if len(r.Dimensions) != 0 { |
221
|
|
|
list := make([]SDK.SegmentDimensions, len(r.Dimensions)) |
222
|
|
|
for i, v := range r.Dimensions { |
223
|
|
|
list[i] = v.ToSDK() |
224
|
|
|
} |
225
|
|
|
o.Dimensions = list |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
if len(r.SourceSegments) != 0 { |
229
|
|
|
list := make([]SDK.SegmentReference, len(r.SourceSegments)) |
230
|
|
|
for i, v := range r.SourceSegments { |
231
|
|
|
list[i] = v.ToSDK() |
232
|
|
|
} |
233
|
|
|
o.SourceSegments = list |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
o.SourceType = SDK.SourceType(r.SourceType) |
237
|
|
|
o.Type = SDK.Type(r.Type) |
238
|
|
|
return o |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
type SegmentGroupList struct { |
|
|
|
|
242
|
|
|
Groups []SegmentGroup |
243
|
|
|
Include Include |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
func newSegmentGroupList(o *SDK.SegmentGroupList) SegmentGroupList { |
247
|
|
|
result := SegmentGroupList{} |
248
|
|
|
if o == nil { |
249
|
|
|
return result |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
if len(o.Groups) != 0 { |
253
|
|
|
list := make([]SegmentGroup, len(o.Groups)) |
254
|
|
|
for i, v := range o.Groups { |
255
|
|
|
v := v |
256
|
|
|
list[i] = newSegmentGroup(&v) |
257
|
|
|
} |
258
|
|
|
result.Groups = list |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
result.Include = Include(o.Include) |
262
|
|
|
return result |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
func (r SegmentGroupList) ToSDK() *SDK.SegmentGroupList { |
|
|
|
|
266
|
|
|
o := SDK.SegmentGroupList{} |
267
|
|
|
|
268
|
|
|
if len(r.Groups) != 0 { |
269
|
|
|
list := make([]SDK.SegmentGroup, len(r.Groups)) |
270
|
|
|
for i, v := range r.Groups { |
271
|
|
|
list[i] = v.ToSDK() |
272
|
|
|
} |
273
|
|
|
o.Groups = list |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
o.Include = SDK.Include(r.Include) |
277
|
|
|
return &o |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
type SegmentLocation struct { |
|
|
|
|
281
|
|
|
Country SetDimension |
282
|
|
|
GPSPoint GPSPointDimension |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
func newSegmentLocation(o *SDK.SegmentLocation) SegmentLocation { |
286
|
|
|
result := SegmentLocation{} |
287
|
|
|
if o == nil { |
288
|
|
|
return result |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
result.Country = newSetDimension(o.Country) |
292
|
|
|
result.GPSPoint = newGPSPointDimension(o.GPSPoint) |
293
|
|
|
return result |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
func (r SegmentLocation) ToSDK() *SDK.SegmentLocation { |
|
|
|
|
297
|
|
|
o := SDK.SegmentLocation{} |
298
|
|
|
|
299
|
|
|
o.Country = r.Country.ToSDK() |
300
|
|
|
o.GPSPoint = r.GPSPoint.ToSDK() |
301
|
|
|
return &o |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
type SegmentReference struct { |
|
|
|
|
305
|
|
|
ID string |
306
|
|
|
|
307
|
|
|
// optional |
308
|
|
|
Version int64 |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
func newSegmentReference(o *SDK.SegmentReference) SegmentReference { |
312
|
|
|
result := SegmentReference{} |
313
|
|
|
if o == nil { |
314
|
|
|
return result |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
if o.Id != nil { |
318
|
|
|
result.ID = *o.Id |
319
|
|
|
} |
320
|
|
|
if o.Version != nil { |
321
|
|
|
result.Version = *o.Version |
322
|
|
|
} |
323
|
|
|
return result |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
func (r SegmentReference) ToSDK() SDK.SegmentReference { |
|
|
|
|
327
|
|
|
o := SDK.SegmentReference{} |
328
|
|
|
|
329
|
|
|
if r.ID != "" { |
330
|
|
|
o.Id = pointers.String(r.ID) |
331
|
|
|
} |
332
|
|
|
if r.Version != 0 { |
333
|
|
|
o.Version = pointers.Long64(r.Version) |
334
|
|
|
} |
335
|
|
|
return o |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
type SegmentResponse struct { |
|
|
|
|
339
|
|
|
ApplicationID string |
340
|
|
|
ARN string |
341
|
|
|
CreationDate string |
342
|
|
|
ID string |
343
|
|
|
SegmentType SegmentType |
344
|
|
|
|
345
|
|
|
// optional |
346
|
|
|
Dimensions SegmentDimensions |
347
|
|
|
ImportDefinition SegmentImportResource |
348
|
|
|
LastModifiedDate string |
349
|
|
|
Name string |
350
|
|
|
SegmentGroups SegmentGroupList |
351
|
|
|
Tags map[string]string |
352
|
|
|
Version int64 |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
func newSegmentResponse(o *SDK.SegmentResponse) SegmentResponse { |
356
|
|
|
result := SegmentResponse{} |
357
|
|
|
if o == nil { |
358
|
|
|
return result |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
if o.ApplicationId != nil { |
362
|
|
|
result.ApplicationID = *o.ApplicationId |
363
|
|
|
} |
364
|
|
|
if o.Arn != nil { |
365
|
|
|
result.ARN = *o.Arn |
366
|
|
|
} |
367
|
|
|
if o.CreationDate != nil { |
368
|
|
|
result.CreationDate = *o.CreationDate |
369
|
|
|
} |
370
|
|
|
if o.Id != nil { |
371
|
|
|
result.ID = *o.Id |
372
|
|
|
} |
373
|
|
|
result.SegmentType = SegmentType(o.SegmentType) |
374
|
|
|
|
375
|
|
|
result.Dimensions = newSegmentDimensions(o.Dimensions) |
376
|
|
|
result.ImportDefinition = newSegmentImportResource(o.ImportDefinition) |
377
|
|
|
|
378
|
|
|
if o.LastModifiedDate != nil { |
379
|
|
|
result.LastModifiedDate = *o.LastModifiedDate |
380
|
|
|
} |
381
|
|
|
if o.Name != nil { |
382
|
|
|
result.Name = *o.Name |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
result.SegmentGroups = newSegmentGroupList(o.SegmentGroups) |
386
|
|
|
result.Tags = o.Tags |
387
|
|
|
|
388
|
|
|
if o.Version != nil { |
389
|
|
|
result.Version = *o.Version |
390
|
|
|
} |
391
|
|
|
return result |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
type SegmentsResponse struct { |
|
|
|
|
395
|
|
|
Item []SegmentResponse |
396
|
|
|
NextToken string |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
func newSegmentsResponse(o *SDK.SegmentsResponse) SegmentsResponse { |
400
|
|
|
result := SegmentsResponse{} |
401
|
|
|
if o == nil { |
402
|
|
|
return result |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
if len(o.Item) != 0 { |
406
|
|
|
list := make([]SegmentResponse, len(o.Item)) |
407
|
|
|
for i, v := range o.Item { |
408
|
|
|
v := v |
409
|
|
|
list[i] = newSegmentResponse(&v) |
410
|
|
|
} |
411
|
|
|
result.Item = list |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
if o.NextToken != nil { |
415
|
|
|
result.NextToken = *o.NextToken |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
return result |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
type WriteSegmentRequest struct { |
|
|
|
|
422
|
|
|
Dimensions SegmentDimensions |
423
|
|
|
Name string |
424
|
|
|
SegmentGroups SegmentGroupList |
425
|
|
|
Tags map[string]string |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
func (r WriteSegmentRequest) ToSDK() *SDK.WriteSegmentRequest { |
|
|
|
|
429
|
|
|
o := SDK.WriteSegmentRequest{} |
430
|
|
|
|
431
|
|
|
vv := r.Dimensions.ToSDK() |
432
|
|
|
o.Dimensions = &vv |
433
|
|
|
|
434
|
|
|
if r.Name != "" { |
435
|
|
|
o.Name = pointers.String(r.Name) |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
o.SegmentGroups = r.SegmentGroups.ToSDK() |
439
|
|
|
o.Tags = r.Tags |
440
|
|
|
return &o |
441
|
|
|
} |
442
|
|
|
|