@sentiance-react-native/core 6.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/android/build.gradle +17 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +2 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/package-json-reader.gradle +62 -0
- package/android/sentiance-version-finder.gradle +17 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceConverter.java +364 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceEmitter.java +46 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceHelper.java +207 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceModule.java +529 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/SentiancePackage.java +30 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/UserLinker.java +34 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/base/AbstractSentianceEmitter.java +59 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/base/AbstractSentianceModule.java +33 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/utils/ErrorCodes.java +16 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/utils/SentianceUtils.java +160 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/utils/UserCreationCompletionHandler.java +31 -0
- package/ios/RNSentianceCore+Converter.h +46 -0
- package/ios/RNSentianceCore+Converter.m +986 -0
- package/ios/RNSentianceCore.h +29 -0
- package/ios/RNSentianceCore.m +1036 -0
- package/ios/RNSentianceCore.podspec +24 -0
- package/ios/RNSentianceCore.xcodeproj/project.pbxproj +290 -0
- package/ios/RNSentianceErrorCodes.h +20 -0
- package/ios/RNSentianceErrorCodes.m +22 -0
- package/ios/RNSentianceHelper.h +31 -0
- package/ios/RNSentianceHelper.m +38 -0
- package/ios/RNSentianceNativeInitialization.h +6 -0
- package/ios/RNSentianceNativeInitialization.m +56 -0
- package/lib/core.js +64 -0
- package/lib/index.d.ts +198 -0
- package/lib/index.js +194 -0
- package/lib/utils.js +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,986 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNSentianceConverter.m
|
|
3
|
+
// RNSentiance
|
|
4
|
+
//
|
|
5
|
+
// Created by Sebouh Aguehian on 10/10/2021.
|
|
6
|
+
// Copyright © 2021 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "RNSentianceCore+Converter.h"
|
|
10
|
+
|
|
11
|
+
@interface RNSentianceCore (Private)
|
|
12
|
+
|
|
13
|
+
- (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type;
|
|
14
|
+
- (NSDictionary*)convertGeolocation:(SENTGeolocation*)location;
|
|
15
|
+
- (NSString*)convertVenueSignificance:(SENTVenueSignificance)type;
|
|
16
|
+
- (NSDictionary*)convertVisit:(SENTVisit*)visit;
|
|
17
|
+
- (NSDictionary*)convertVenue:(SENTVenue*)venue;
|
|
18
|
+
- (NSDictionary*)convertVenueCandidate:(SENTVenueCandidate*)candidate;
|
|
19
|
+
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event;
|
|
20
|
+
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode) mode;
|
|
21
|
+
- (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event;
|
|
22
|
+
- (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event;
|
|
23
|
+
- (nullable NSString*)convertSegmentCategoryToString:(SENTSegmentCategory)category;
|
|
24
|
+
- (nullable NSString*)convertSegmentSubcategoryToString:(SENTSegmentSubcategory)subcategory;
|
|
25
|
+
- (nullable NSString*)convertSegmentTypeToString:(SENTSegmentType)type;
|
|
26
|
+
- (NSMutableDictionary*)convertSegmentAttributesToDict:(NSArray<SENTAttribute *>*)attributes;
|
|
27
|
+
- (nullable NSDictionary*)convertSegment:(SENTSegment*)segment;
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation RNSentianceCore (Converter)
|
|
31
|
+
|
|
32
|
+
- (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type {
|
|
33
|
+
switch (type) {
|
|
34
|
+
case SENTTimelineEventTypeStationary:
|
|
35
|
+
return @"STATIONARY";
|
|
36
|
+
case SENTTimelineEventTypeOffTheGrid:
|
|
37
|
+
return @"OFF_THE_GRID";
|
|
38
|
+
case SENTTimelineEventTypeInTransport:
|
|
39
|
+
return @"IN_TRANSPORT";
|
|
40
|
+
case SENTTimelineEventTypeUnknown:
|
|
41
|
+
default:
|
|
42
|
+
return @"UNKNOWN";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (NSDictionary*)convertGeolocation:(SENTGeolocation*)location {
|
|
47
|
+
return @{
|
|
48
|
+
@"latitude": @(location.latitude),
|
|
49
|
+
@"longitude": @(location.longitude),
|
|
50
|
+
@"accuracy": @(location.accuracyInMeters)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (NSString*)convertVenueSignificance:(SENTVenueSignificance)type {
|
|
55
|
+
switch (type) {
|
|
56
|
+
case SENTVenueSignificanceHome:
|
|
57
|
+
return @"HOME";
|
|
58
|
+
case SENTVenueSignificanceWork:
|
|
59
|
+
return @"WORK";
|
|
60
|
+
case SENTVenueSignificancePointOfInterest:
|
|
61
|
+
return @"POINT_OF_INTEREST";
|
|
62
|
+
case SENTVenueSignificanceUnknown:
|
|
63
|
+
default:
|
|
64
|
+
return @"UNKNOWN";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (NSDictionary*)convertVisit:(SENTVisit*)visit {
|
|
69
|
+
return @{
|
|
70
|
+
@"startTime": [visit.startDate description],
|
|
71
|
+
@"startTimeEpoch": [NSString stringWithFormat:@"%d",visit.startDate.timeIntervalSince1970],
|
|
72
|
+
@"endTime": [visit.endDate description],
|
|
73
|
+
@"endTimeEpoch": [NSString stringWithFormat:@"%d",visit.startDate.timeIntervalSince1970],
|
|
74
|
+
@"durationInSeconds": [NSNumber numberWithInt:(int)visit.durationInSeconds],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (NSDictionary*)convertVenue:(SENTVenue*)venue {
|
|
79
|
+
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
80
|
+
|
|
81
|
+
if (venue.name != nil) {
|
|
82
|
+
dict[@"name"] = venue.name;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (venue.location != nil) {
|
|
86
|
+
dict[@"location"] = [self convertGeolocation:venue.location];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
NSMutableDictionary* labels = [[NSMutableDictionary alloc] init];
|
|
90
|
+
[venue.labels enumerateKeysAndObjectsUsingBlock:
|
|
91
|
+
^(NSString * _Nonnull key, NSString * _Nonnull obj, BOOL * _Nonnull stop) {
|
|
92
|
+
labels[key] = obj;
|
|
93
|
+
}];
|
|
94
|
+
dict[@"venueLabels"] = labels;
|
|
95
|
+
|
|
96
|
+
return dict;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (NSDictionary*)convertVenueCandidate:(SENTVenueCandidate*)candidate {
|
|
100
|
+
NSMutableArray* visits = [[NSMutableArray alloc] init];
|
|
101
|
+
for (SENTVisit* visit in candidate.visits) {
|
|
102
|
+
[visits addObject:[self convertVisit:visit]];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return @{
|
|
106
|
+
@"venue": [self convertVenue:candidate.venue],
|
|
107
|
+
@"likelihood": @(candidate.likelihood),
|
|
108
|
+
@"visits": visits
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event {
|
|
113
|
+
if (event.location != nil) {
|
|
114
|
+
dict[@"location"] = [self convertGeolocation:event.location];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
dict[@"venueSignificance"] = [self convertVenueSignificance:event.venueSignificance];
|
|
118
|
+
|
|
119
|
+
NSMutableArray* venueCandidates = [[NSMutableArray alloc] init];
|
|
120
|
+
for (SENTVenueCandidate* candidate in event.venueCandidates) {
|
|
121
|
+
[venueCandidates addObject:[self convertVenueCandidate:candidate]];
|
|
122
|
+
}
|
|
123
|
+
dict[@"venueCandidates"] = venueCandidates;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode)mode {
|
|
127
|
+
switch (mode) {
|
|
128
|
+
case SENTTimelineTransportModeWalking:
|
|
129
|
+
return @"WALKING";
|
|
130
|
+
case SENTTimelineTransportModeRunning:
|
|
131
|
+
return @"RUNNING";
|
|
132
|
+
case SENTTimelineTransportModeBicycle:
|
|
133
|
+
return @"BYCICLE";
|
|
134
|
+
case SENTTimelineTransportModeVehicle:
|
|
135
|
+
return @"VEHICLE";
|
|
136
|
+
case SENTTimelineTransportModeRail:
|
|
137
|
+
return @"RAIL";
|
|
138
|
+
case SENTTimelineTransportModeUnknown:
|
|
139
|
+
default:
|
|
140
|
+
return @"UNKNOWN";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event {
|
|
145
|
+
dict[@"transportMode"] = [self convertTransportModeToString:event.transportMode];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event {
|
|
149
|
+
NSMutableDictionary *eventDict = [[NSMutableDictionary alloc] init];
|
|
150
|
+
eventDict[@"startTime"] = [event.startDate description];
|
|
151
|
+
if (event.endDate != nil) {
|
|
152
|
+
eventDict[@"endTime"] = [event.endDate description];
|
|
153
|
+
|
|
154
|
+
NSInteger durationInSeconds = event.durationInSeconds;
|
|
155
|
+
if (durationInSeconds != SENTDurationUnknown) {
|
|
156
|
+
eventDict[@"durationInSeconds"] = [NSNumber numberWithInt:(int)durationInSeconds];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
eventDict[@"type"] = [self convertTimelineEventTypeToString:event.type];
|
|
161
|
+
|
|
162
|
+
if (event.type == SENTTimelineEventTypeStationary) {
|
|
163
|
+
[self addStationaryEventInfoToDict:eventDict event:(SENTStationaryEvent*)event];
|
|
164
|
+
}
|
|
165
|
+
else if (event.type == SENTTimelineEventTypeInTransport) {
|
|
166
|
+
[self addTransportEventInfoToDict:eventDict event:(SENTTransportEvent*)event];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return eventDict;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
- (nullable NSString*)convertSegmentCategoryToString:(SENTSegmentCategory)category {
|
|
173
|
+
switch (category) {
|
|
174
|
+
case SENTSegmentCategoryLeisure:
|
|
175
|
+
return @"LEISURE";
|
|
176
|
+
case SENTSegmentCategoryMobility:
|
|
177
|
+
return @"MOBILITY";
|
|
178
|
+
case SENTSegmentCategoryWorkLife:
|
|
179
|
+
return @"WORK_LIFE";
|
|
180
|
+
default:
|
|
181
|
+
return nil;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
- (nullable NSString*)convertSegmentSubcategoryToString:(SENTSegmentSubcategory)subcategory {
|
|
186
|
+
switch (subcategory) {
|
|
187
|
+
case SENTSegmentSubcategoryCommute:
|
|
188
|
+
return @"COMMUTE";
|
|
189
|
+
case SENTSegmentSubcategoryDriving:
|
|
190
|
+
return @"DRIVING";
|
|
191
|
+
case SENTSegmentSubcategoryEntertainment:
|
|
192
|
+
return @"ENTERTAINMENT";
|
|
193
|
+
case SENTSegmentSubcategoryFamily:
|
|
194
|
+
return @"FAMILY";
|
|
195
|
+
case SENTSegmentSubcategoryHome:
|
|
196
|
+
return @"HOME";
|
|
197
|
+
case SENTSegmentSubcategoryShopping:
|
|
198
|
+
return @"SHOPPING";
|
|
199
|
+
case SENTSegmentSubcategorySocial:
|
|
200
|
+
return @"SOCIAL";
|
|
201
|
+
case SENTSegmentSubcategoryTransport:
|
|
202
|
+
return @"TRANSPORT";
|
|
203
|
+
case SENTSegmentSubcategoryTravel:
|
|
204
|
+
return @"TRAVEL";
|
|
205
|
+
case SENTSegmentSubcategoryWellbeing:
|
|
206
|
+
return @"WELLBEING";
|
|
207
|
+
case SENTSegmentSubcategoryWiningAndDining:
|
|
208
|
+
return @"WINING_AND_DINING";
|
|
209
|
+
case SENTSegmentSubcategoryWork:
|
|
210
|
+
return @"WORK";
|
|
211
|
+
default:
|
|
212
|
+
return nil;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
- (nullable NSString*)convertSegmentTypeToString:(SENTSegmentType)type {
|
|
217
|
+
switch (type) {
|
|
218
|
+
case SENTSegmentTypeAggressiveDriver:
|
|
219
|
+
return @"AGGRESSIVE_DRIVER";
|
|
220
|
+
case SENTSegmentTypeAnticipativeDriver:
|
|
221
|
+
return @"ANTICIPATIVE_DRIVER";
|
|
222
|
+
case SENTSegmentTypeBarGoer:
|
|
223
|
+
return @"BAR_GOER";
|
|
224
|
+
case SENTSegmentTypeBeautyQueen:
|
|
225
|
+
return @"BEAUTY_QUEEN";
|
|
226
|
+
case SENTSegmentTypeBrandLoyalBar:
|
|
227
|
+
return @"BRAND_LOYAL__BAR";
|
|
228
|
+
case SENTSegmentTypeBrandLoyalCafe:
|
|
229
|
+
return @"BRAND_LOYAL__CAFE";
|
|
230
|
+
case SENTSegmentTypeBrandLoyalRestaurant:
|
|
231
|
+
return @"BRAND_LOYAL__RESTAURANT";
|
|
232
|
+
case SENTSegmentTypeBrandLoyalRetail:
|
|
233
|
+
return @"BRAND_LOYAL__RETAIL";
|
|
234
|
+
case SENTSegmentTypeBrandLoyalty:
|
|
235
|
+
return @"BRAND_LOYALTY";
|
|
236
|
+
case SENTSegmentTypeBrandLoyaltyGasStations:
|
|
237
|
+
return @"BRAND_LOYALTY__GAS_STATIONS";
|
|
238
|
+
case SENTSegmentTypeBrandLoyaltyRestaurantBar:
|
|
239
|
+
return @"BRAND_LOYALTY__RESTAURANT_BAR";
|
|
240
|
+
case SENTSegmentTypeBrandLoyaltySupermarket:
|
|
241
|
+
return @"BRAND_LOYALTY__SUPERMARKET";
|
|
242
|
+
case SENTSegmentTypeCityDriver:
|
|
243
|
+
return @"CITY_DRIVER";
|
|
244
|
+
case SENTSegmentTypeCityHome:
|
|
245
|
+
return @"CITY_HOME";
|
|
246
|
+
case SENTSegmentTypeCityWorker:
|
|
247
|
+
return @"CITY_WORKER";
|
|
248
|
+
case SENTSegmentTypeClubber:
|
|
249
|
+
return @"CLUBBER";
|
|
250
|
+
case SENTSegmentTypeCultureBuff:
|
|
251
|
+
return @"CULTURE_BUFF";
|
|
252
|
+
case SENTSegmentTypeDieHardDriver:
|
|
253
|
+
return @"DIE_HARD_DRIVER";
|
|
254
|
+
case SENTSegmentTypeDistractedDriver:
|
|
255
|
+
return @"DISTRACTED_DRIVER";
|
|
256
|
+
case SENTSegmentTypeDoItYourselver:
|
|
257
|
+
return @"DO_IT_YOURSELVER";
|
|
258
|
+
case SENTSegmentTypeDogWalker:
|
|
259
|
+
return @"DOG_WALKER";
|
|
260
|
+
case SENTSegmentTypeEarlyBird:
|
|
261
|
+
return @"EARLY_BIRD";
|
|
262
|
+
case SENTSegmentTypeEasyCommuter:
|
|
263
|
+
return @"EASY_COMMUTER";
|
|
264
|
+
case SENTSegmentTypeEfficientDriver:
|
|
265
|
+
return @"EFFICIENT_DRIVER";
|
|
266
|
+
case SENTSegmentTypeFashionista:
|
|
267
|
+
return @"FASHIONISTA";
|
|
268
|
+
case SENTSegmentTypeFoodie:
|
|
269
|
+
return @"FOODIE";
|
|
270
|
+
case SENTSegmentTypeFrequentFlyer:
|
|
271
|
+
return @"FREQUENT_FLYER";
|
|
272
|
+
case SENTSegmentTypeFulltimeWorker:
|
|
273
|
+
return @"FULLTIME_WORKER";
|
|
274
|
+
case SENTSegmentTypeGamer:
|
|
275
|
+
return @"GAMER";
|
|
276
|
+
case SENTSegmentTypeGreenCommuter:
|
|
277
|
+
return @"GREEN_COMMUTER";
|
|
278
|
+
case SENTSegmentTypeHealthyBiker:
|
|
279
|
+
return @"HEALTHY_BIKER";
|
|
280
|
+
case SENTSegmentTypeHealthyWalker:
|
|
281
|
+
return @"HEALTHY_WALKER";
|
|
282
|
+
case SENTSegmentTypeHeavyCommuter:
|
|
283
|
+
return @"HEAVY_COMMUTER";
|
|
284
|
+
case SENTSegmentTypeHomeBound:
|
|
285
|
+
return @"HOME_BOUND";
|
|
286
|
+
case SENTSegmentTypeHomebody:
|
|
287
|
+
return @"HOMEBODY";
|
|
288
|
+
case SENTSegmentTypeHomeworker:
|
|
289
|
+
return @"HOMEWORKER";
|
|
290
|
+
case SENTSegmentTypeIllegalDriver:
|
|
291
|
+
return @"ILLEGAL_DRIVER";
|
|
292
|
+
case SENTSegmentTypeLateWorker:
|
|
293
|
+
return @"LATE_WORKER";
|
|
294
|
+
case SENTSegmentTypeLegalDriver:
|
|
295
|
+
return @"LEGAL_DRIVER";
|
|
296
|
+
case SENTSegmentTypeLongCommuter:
|
|
297
|
+
return @"LONG_COMMUTER";
|
|
298
|
+
case SENTSegmentTypeMobility:
|
|
299
|
+
return @"MOBILITY";
|
|
300
|
+
case SENTSegmentTypeMobilityHigh:
|
|
301
|
+
return @"MOBILITY__HIGH";
|
|
302
|
+
case SENTSegmentTypeMobilityLimited:
|
|
303
|
+
return @"MOBILITY__LIMITED";
|
|
304
|
+
case SENTSegmentTypeMobilityModerate:
|
|
305
|
+
return @"MOBILITY__MODERATE";
|
|
306
|
+
case SENTSegmentTypeMotorwayDriver:
|
|
307
|
+
return @"MOTORWAY_DRIVER";
|
|
308
|
+
case SENTSegmentTypeMusicLover:
|
|
309
|
+
return @"MUSIC_LOVER";
|
|
310
|
+
case SENTSegmentTypeNatureLover:
|
|
311
|
+
return @"NATURE_LOVER";
|
|
312
|
+
case SENTSegmentTypeNightOwl:
|
|
313
|
+
return @"NIGHT_OWL";
|
|
314
|
+
case SENTSegmentTypeNightworker:
|
|
315
|
+
return @"NIGHTWORKER";
|
|
316
|
+
case SENTSegmentTypeNormalCommuter:
|
|
317
|
+
return @"NORMAL_COMMUTER";
|
|
318
|
+
case SENTSegmentTypeParttimeWorker:
|
|
319
|
+
return @"PARTTIME_WORKER";
|
|
320
|
+
case SENTSegmentTypePetOwner:
|
|
321
|
+
return @"PET_OWNER";
|
|
322
|
+
case SENTSegmentTypePhysicalActivityHigh:
|
|
323
|
+
return @"PHYSICAL_ACTIVITY__HIGH";
|
|
324
|
+
case SENTSegmentTypePhysicalActivityLimited:
|
|
325
|
+
return @"PHYSICAL_ACTIVITY__LIMITED";
|
|
326
|
+
case SENTSegmentTypePhysicalActivityModerate:
|
|
327
|
+
return @"PHYSICAL_ACTIVITY__MODERATE";
|
|
328
|
+
case SENTSegmentTypePublicTransportsCommuter:
|
|
329
|
+
return @"PUBLIC_TRANSPORTS_COMMUTER";
|
|
330
|
+
case SENTSegmentTypePublicTransportsUser:
|
|
331
|
+
return @"PUBLIC_TRANSPORTS_USER";
|
|
332
|
+
case SENTSegmentTypeRecentlyChangedJob:
|
|
333
|
+
return @"RECENTLY_CHANGED_JOB";
|
|
334
|
+
case SENTSegmentTypeRecentlyMovedHome:
|
|
335
|
+
return @"RECENTLY_MOVED_HOME";
|
|
336
|
+
case SENTSegmentTypeRestoLover:
|
|
337
|
+
return @"RESTO_LOVER";
|
|
338
|
+
case SENTSegmentTypeRestoLoverAmerican:
|
|
339
|
+
return @"RESTO_LOVER__AMERICAN";
|
|
340
|
+
case SENTSegmentTypeRestoLoverAsian:
|
|
341
|
+
return @"RESTO_LOVER__ASIAN";
|
|
342
|
+
case SENTSegmentTypeRestoLoverBarbecue:
|
|
343
|
+
return @"RESTO_LOVER__BARBECUE";
|
|
344
|
+
case SENTSegmentTypeRestoLoverFastfood:
|
|
345
|
+
return @"RESTO_LOVER__FASTFOOD";
|
|
346
|
+
case SENTSegmentTypeRestoLoverFrench:
|
|
347
|
+
return @"RESTO_LOVER__FRENCH";
|
|
348
|
+
case SENTSegmentTypeRestoLoverGerman:
|
|
349
|
+
return @"RESTO_LOVER__GERMAN";
|
|
350
|
+
case SENTSegmentTypeRestoLoverGreek:
|
|
351
|
+
return @"RESTO_LOVER__GREEK";
|
|
352
|
+
case SENTSegmentTypeRestoLoverGrill:
|
|
353
|
+
return @"RESTO_LOVER__GRILL";
|
|
354
|
+
case SENTSegmentTypeRestoLoverInternational:
|
|
355
|
+
return @"RESTO_LOVER__INTERNATIONAL";
|
|
356
|
+
case SENTSegmentTypeRestoLoverItalian:
|
|
357
|
+
return @"RESTO_LOVER__ITALIAN";
|
|
358
|
+
case SENTSegmentTypeRestoLoverMediterranean:
|
|
359
|
+
return @"RESTO_LOVER__MEDITERRANEAN";
|
|
360
|
+
case SENTSegmentTypeRestoLoverMexican:
|
|
361
|
+
return @"RESTO_LOVER__MEXICAN";
|
|
362
|
+
case SENTSegmentTypeRestoLoverSeafood:
|
|
363
|
+
return @"RESTO_LOVER__SEAFOOD";
|
|
364
|
+
case SENTSegmentTypeRestoLoverSnack:
|
|
365
|
+
return @"RESTO_LOVER__SNACK";
|
|
366
|
+
case SENTSegmentTypeRuralHome:
|
|
367
|
+
return @"RURAL_HOME";
|
|
368
|
+
case SENTSegmentTypeRuralWorker:
|
|
369
|
+
return @"RURAL_WORKER";
|
|
370
|
+
case SENTSegmentTypeShopaholic:
|
|
371
|
+
return @"SHOPAHOLIC";
|
|
372
|
+
case SENTSegmentTypeShortCommuter:
|
|
373
|
+
return @"SHORT_COMMUTER";
|
|
374
|
+
case SENTSegmentTypeSleepDeprived:
|
|
375
|
+
return @"SLEEP_DEPRIVED";
|
|
376
|
+
case SENTSegmentTypeSocialActivity:
|
|
377
|
+
return @"SOCIAL_ACTIVITY";
|
|
378
|
+
case SENTSegmentTypeSocialActivityHigh:
|
|
379
|
+
return @"SOCIAL_ACTIVITY__HIGH";
|
|
380
|
+
case SENTSegmentTypeSocialActivityLimited:
|
|
381
|
+
return @"SOCIAL_ACTIVITY__LIMITED";
|
|
382
|
+
case SENTSegmentTypeSocialActivityModerate:
|
|
383
|
+
return @"SOCIAL_ACTIVITY__MODERATE";
|
|
384
|
+
case SENTSegmentTypeSportive:
|
|
385
|
+
return @"SPORTIVE";
|
|
386
|
+
case SENTSegmentTypeStudent:
|
|
387
|
+
return @"STUDENT";
|
|
388
|
+
case SENTSegmentTypeTownHome:
|
|
389
|
+
return @"TOWN_HOME";
|
|
390
|
+
case SENTSegmentTypeTownWorker:
|
|
391
|
+
return @"TOWN_WORKER";
|
|
392
|
+
case SENTSegmentTypeUberParent:
|
|
393
|
+
return @"UBER_PARENT";
|
|
394
|
+
case SENTSegmentTypeWorkLifeBalance:
|
|
395
|
+
return @"WORK_LIFE_BALANCE";
|
|
396
|
+
case SENTSegmentTypeWorkTraveller:
|
|
397
|
+
return @"WORK_TRAVELLER";
|
|
398
|
+
case SENTSegmentTypeWorkaholic:
|
|
399
|
+
return @"WORKAHOLIC";
|
|
400
|
+
default:
|
|
401
|
+
return nil;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
- (NSMutableDictionary*)convertSegmentAttributesToDict:(NSArray<SENTAttribute *>*)attributes {
|
|
406
|
+
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
407
|
+
|
|
408
|
+
for (SENTAttribute* attribute in attributes) {
|
|
409
|
+
dict[attribute.name] = @(attribute.value);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return dict;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
- (nullable NSDictionary*)convertSegment:(SENTSegment*)segment {
|
|
416
|
+
NSString* category = [self convertSegmentCategoryToString:segment.category];
|
|
417
|
+
NSString* subcategory = [self convertSegmentSubcategoryToString:segment.subcategory];
|
|
418
|
+
NSString* type = [self convertSegmentTypeToString:segment.type];
|
|
419
|
+
|
|
420
|
+
if (category == nil || subcategory == nil || type == nil) {
|
|
421
|
+
return nil;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
425
|
+
dict[@"category"] = category;
|
|
426
|
+
dict[@"subcategory"] = subcategory;
|
|
427
|
+
dict[@"type"] = type;
|
|
428
|
+
dict[@"id"] = @(segment.uniqueId);
|
|
429
|
+
dict[@"startTime"] = [segment.startDate description];
|
|
430
|
+
dict[@"startTimeEpoch"] = [NSString stringWithFormat:@"%d",segment.startDate.timeIntervalSince1970];
|
|
431
|
+
|
|
432
|
+
if (segment.endDate != nil) {
|
|
433
|
+
dict[@"endTime"] = [segment.endDate description];
|
|
434
|
+
dict[@"endTimeEpoch"] = [NSString stringWithFormat:@"%d",segment.endDate.timeIntervalSince1970];
|
|
435
|
+
}
|
|
436
|
+
dict[@"attributes"] = [self convertSegmentAttributesToDict:segment.attributes];
|
|
437
|
+
|
|
438
|
+
return dict;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
- (NSDictionary*)convertUserContextToDict:(SENTUserContext*)userContext {
|
|
442
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
443
|
+
|
|
444
|
+
// Events
|
|
445
|
+
NSMutableArray *events = [[NSMutableArray alloc] init];
|
|
446
|
+
for (SENTTimelineEvent* event in userContext.events) {
|
|
447
|
+
[events addObject:[self convertEvent:event]];
|
|
448
|
+
}
|
|
449
|
+
dict[@"events"] = events;
|
|
450
|
+
|
|
451
|
+
// Segments
|
|
452
|
+
NSMutableArray *segments = [[NSMutableArray alloc] init];
|
|
453
|
+
for (SENTSegment* segment in userContext.activeSegments) {
|
|
454
|
+
[segments addObject:[self convertSegment:segment]];
|
|
455
|
+
}
|
|
456
|
+
dict[@"activeSegments"] = segments;
|
|
457
|
+
|
|
458
|
+
// Last know location
|
|
459
|
+
if (userContext.lastKnownLocation != nil) {
|
|
460
|
+
dict[@"lastKnownLocation"] = [self convertGeolocation:userContext.lastKnownLocation];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Home
|
|
464
|
+
if (userContext.home != nil) {
|
|
465
|
+
dict[@"home"] = [self convertVenue:userContext.home];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Home
|
|
469
|
+
if (userContext.work != nil) {
|
|
470
|
+
dict[@"work"] = [self convertVenue:userContext.work];
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return [dict copy];
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
- (NSMutableArray*)convertUserContextCriteriaToArray:(SENTUserContextUpdateCriteria)criteriaMask {
|
|
477
|
+
NSMutableArray* criteria = [[NSMutableArray alloc] init];
|
|
478
|
+
|
|
479
|
+
if (criteriaMask & SENTUserContextUpdateCriteriaCurrentEvent) {
|
|
480
|
+
[criteria addObject:@"CURRENT_EVENT"];
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (criteriaMask & SENTUserContextUpdateCriteriaActiveMoments) {
|
|
484
|
+
[criteria addObject:@"ACTIVE_MOMENTS"];
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
if (criteriaMask & SENTUserContextUpdateCriteriaVisitedVenues) {
|
|
488
|
+
[criteria addObject:@"VISITED_VENUES"];
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (criteriaMask & SENTUserContextUpdateCriteriaActiveSegments) {
|
|
492
|
+
[criteria addObject:@"ACTIVE_SEGMENTS"];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return criteria;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
- (NSDictionary*)convertUserActivityToDict:(SENTUserActivity*)userActivity {
|
|
499
|
+
if(userActivity == nil) {
|
|
500
|
+
return @{};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
//SENTUserActivity
|
|
504
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
505
|
+
|
|
506
|
+
//SENTUserActivityType
|
|
507
|
+
NSString *userActivityType = [self convertUserActivityTypeToString:userActivity.type];
|
|
508
|
+
[dict setObject:userActivityType forKey:@"type"];
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
//SENTTripInfo
|
|
512
|
+
if(userActivity.type == SENTUserActivityTypeTRIP ) {
|
|
513
|
+
NSMutableDictionary *tripInfoDict = [[NSMutableDictionary alloc] init];
|
|
514
|
+
NSString *tripInfo = [self convertTripTypeToString:userActivity.tripInfo.type];
|
|
515
|
+
|
|
516
|
+
if(tripInfo.length > 0) {
|
|
517
|
+
[tripInfoDict setObject:tripInfo forKey:@"type"];
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if(tripInfoDict.allKeys.count > 0) {
|
|
521
|
+
[dict setObject:tripInfoDict forKey:@"tripInfo"];
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
//SENTStationaryInfo
|
|
526
|
+
if(userActivity.type == SENTUserActivityTypeSTATIONARY) {
|
|
527
|
+
NSMutableDictionary *stationaryInfoDict = [[NSMutableDictionary alloc] init];
|
|
528
|
+
|
|
529
|
+
if(userActivity.stationaryInfo.location) {
|
|
530
|
+
NSDictionary *location = @{
|
|
531
|
+
@"latitude": @(userActivity.stationaryInfo.location.coordinate.latitude),
|
|
532
|
+
@"longitude": @(userActivity.stationaryInfo.location.coordinate.longitude)
|
|
533
|
+
};
|
|
534
|
+
[stationaryInfoDict setObject:location forKey:@"location"];
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if(stationaryInfoDict.allKeys.count > 0) {
|
|
538
|
+
[dict setObject:stationaryInfoDict forKey:@"stationaryInfo"];
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return [dict copy];
|
|
544
|
+
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
- (NSDictionary*)convertSdkStatusToDict:(SENTSDKStatus*) status {
|
|
548
|
+
if (status == nil) {
|
|
549
|
+
return @{};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
NSDictionary *dict = @{
|
|
553
|
+
@"startStatus":[self convertStartStatusToString:status.startStatus],
|
|
554
|
+
@"detectionStatus":[self convertDetectionStatusToString:status.detectionStatus],
|
|
555
|
+
@"canDetect":@(status.canDetect),
|
|
556
|
+
@"isRemoteEnabled":@(status.isRemoteEnabled),
|
|
557
|
+
@"locationPermission":[self convertLocationPermissionToString:status.locationPermission],
|
|
558
|
+
@"isPreciseLocationAuthorizationGranted":@(status.isPreciseLocationAuthorizationGranted),
|
|
559
|
+
@"isAccelPresent":@(status.isAccelPresent),
|
|
560
|
+
@"isGyroPresent":@(status.isGyroPresent),
|
|
561
|
+
@"isGpsPresent":@(status.isGpsPresent),
|
|
562
|
+
@"wifiQuotaStatus":[self convertQuotaStatusToString:status.wifiQuotaStatus],
|
|
563
|
+
@"mobileQuotaStatus":[self convertQuotaStatusToString:status.mobileQuotaStatus],
|
|
564
|
+
@"diskQuotaStatus":[self convertQuotaStatusToString:status.diskQuotaStatus]
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
return dict;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
- (NSDictionary*)convertInstallIdToDict:(NSString*) installId {
|
|
571
|
+
return @{ @"installId":installId };
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
- (NSDictionary*)convertTokenToDict:(NSString*) token {
|
|
576
|
+
if (token.length == 0) {
|
|
577
|
+
return @{};
|
|
578
|
+
}
|
|
579
|
+
return @{ @"tokenId":token };
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
- (NSString*)convertInitIssueToString:(SENTInitIssue) issue {
|
|
583
|
+
if (issue == SENTInitIssueInvalidCredentials) {
|
|
584
|
+
return @"INVALID_CREDENTIALS";
|
|
585
|
+
} else if (issue == SENTInitIssueChangedCredentials) {
|
|
586
|
+
return @"CHANGED_CREDENTIALS";
|
|
587
|
+
} else if (issue == SENTInitIssueServiceUnreachable) {
|
|
588
|
+
return @"SERVICE_UNREACHABLE";
|
|
589
|
+
} else if (issue == SENTInitIssueLinkFailed) {
|
|
590
|
+
return @"LINK_FAILED";
|
|
591
|
+
} else if (issue == SENTInitIssueResetInProgress) {
|
|
592
|
+
return @"SDK_RESET_IN_PROGRESS";
|
|
593
|
+
} else
|
|
594
|
+
return @"INITIALIZATION_ERROR";
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
- (NSString*)convertQuotaStatusToString:(SENTQuotaStatus) status {
|
|
598
|
+
switch (status) {
|
|
599
|
+
case SENTQuotaStatusOK:
|
|
600
|
+
return @"OK";
|
|
601
|
+
case SENTQuotaStatusWarning:
|
|
602
|
+
return @"WARNING";
|
|
603
|
+
case SENTQuotaStatusExceeded:
|
|
604
|
+
return @"EXCEEDED";
|
|
605
|
+
default:
|
|
606
|
+
return @"UNRECOGNIZED_STATUS";
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
- (NSString*)convertLocationPermissionToString:(SENTLocationPermission) status {
|
|
611
|
+
switch (status) {
|
|
612
|
+
case SENTLocationPermissionAlways:
|
|
613
|
+
return @"ALWAYS";
|
|
614
|
+
case SENTLocationPermissionWhileInUse:
|
|
615
|
+
return @"ONLY_WHILE_IN_USE";
|
|
616
|
+
case SENTLocationPermissionNever:
|
|
617
|
+
default:
|
|
618
|
+
return @"NEVER";
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
- (NSString*)convertInitStateToString:(SENTSDKInitState) state {
|
|
623
|
+
switch (state) {
|
|
624
|
+
case SENTNotInitialized:
|
|
625
|
+
return @"NOT_INITIALIZED";
|
|
626
|
+
case SENTInitInProgress:
|
|
627
|
+
return @"INIT_IN_PROGRESS";
|
|
628
|
+
case SENTInitialized:
|
|
629
|
+
return @"INITIALIZED";
|
|
630
|
+
case SENTResetting:
|
|
631
|
+
return @"RESETTING";
|
|
632
|
+
default:
|
|
633
|
+
return @"UNRECOGNIZED_STATE";
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
- (NSString*)convertUserActivityTypeToString:(SENTUserActivityType) activityType {
|
|
638
|
+
switch (activityType) {
|
|
639
|
+
case SENTUserActivityTypeTRIP:
|
|
640
|
+
return @"USER_ACTIVITY_TYPE_TRIP";
|
|
641
|
+
case SENTUserActivityTypeSTATIONARY:
|
|
642
|
+
return @"USER_ACTIVITY_TYPE_STATIONARY";
|
|
643
|
+
case SENTUserActivityTypeUNKNOWN:
|
|
644
|
+
return @"USER_ACTIVITY_TYPE_UNKNOWN";
|
|
645
|
+
default:
|
|
646
|
+
return @"USER_ACTIVITY_TYPE_UNRECOGNIZED";
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
- (NSString*)convertTripTypeToString:(SENTTripType) tripType {
|
|
651
|
+
switch (tripType) {
|
|
652
|
+
case SENTTripTypeSDK:
|
|
653
|
+
return @"TRIP_TYPE_SDK";
|
|
654
|
+
case SENTTripTypeExternal:
|
|
655
|
+
return @"TRIP_TYPE_EXTERNAL";
|
|
656
|
+
default:
|
|
657
|
+
return @"TRIP_TYPE_UNRECOGNIZED";
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
- (NSDictionary*)convertVehicleCrashEventToDict:(SENTVehicleCrashEvent*) crashEvent {
|
|
662
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
663
|
+
double time = [crashEvent.date timeIntervalSince1970] * 1000;
|
|
664
|
+
dict[@"time"] = @(time);
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
if(crashEvent.location != nil) {
|
|
668
|
+
NSDictionary *location = @{
|
|
669
|
+
@"latitude": @(crashEvent.location.coordinate.latitude),
|
|
670
|
+
@"longitude": @(crashEvent.location.coordinate.longitude)
|
|
671
|
+
};
|
|
672
|
+
dict[@"location"] = location;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
dict[@"magnitude"] = @(crashEvent.magnitude);
|
|
676
|
+
dict[@"speedAtImpact"] = @(crashEvent.speedAtImpact);
|
|
677
|
+
dict[@"deltaV"] = @(crashEvent.deltaV);
|
|
678
|
+
dict[@"confidence"] = @(crashEvent.confidence);
|
|
679
|
+
return [dict copy];
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
- (NSDictionary *)convertUserCreationResult:(SENTUserCreationResult *)userCreationResult {
|
|
683
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
684
|
+
|
|
685
|
+
dict[@"userId"] = userCreationResult.userInfo.userId;
|
|
686
|
+
dict[@"tokenId"] = userCreationResult.userInfo.token.tokenId;
|
|
687
|
+
dict[@"tokenExpiryDate"] = userCreationResult.userInfo.token.expiryDate;
|
|
688
|
+
dict[@"isTokenExpired"] = @(NO);
|
|
689
|
+
|
|
690
|
+
return dict;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
- (NSString *)stringifyUserCreationError:(SENTUserCreationError *)userCreationError {
|
|
694
|
+
NSString *reason;
|
|
695
|
+
switch (userCreationError.failureReason) {
|
|
696
|
+
case SENTUserCreationFailureReasonSdkResetInProgress:
|
|
697
|
+
reason = @"SDK_RESET_IN_PROGRESS";
|
|
698
|
+
break;
|
|
699
|
+
case SENTUserCreationFailureReasonUserCreationInProgress:
|
|
700
|
+
reason = @"USER_CREATION_IN_PROGRESS";
|
|
701
|
+
case SENTUserCreationFailureReasonUserAlreadyExists:
|
|
702
|
+
reason = @"USER_ALREADY_EXISTS";
|
|
703
|
+
break;
|
|
704
|
+
case SENTUserCreationFailureReasonNetworkError:
|
|
705
|
+
reason = @"NETWORK_ERROR";
|
|
706
|
+
break;
|
|
707
|
+
case SENTUserCreationFailureReasonServerError:
|
|
708
|
+
reason = @"SERVER_ERROR";
|
|
709
|
+
break;
|
|
710
|
+
case SENTUserCreationFailureReasonUnexpectedError:
|
|
711
|
+
reason = @"UNEXPECTED_ERROR";
|
|
712
|
+
break;
|
|
713
|
+
case SENTUserCreationFailureReasonAppSideLinkingFailed:
|
|
714
|
+
reason = @"APP_SIDE_LINKING_FAILED";
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, userCreationError.details];
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
- (NSString*)convertStartStatusToString:(SENTStartStatus) status {
|
|
721
|
+
switch (status) {
|
|
722
|
+
case SENTStartStatusNotStarted:
|
|
723
|
+
return @"NOT_STARTED";
|
|
724
|
+
case SENTStartStatusPending:
|
|
725
|
+
return @"PENDING";
|
|
726
|
+
case SENTStartStatusStarted:
|
|
727
|
+
return @"STARTED";
|
|
728
|
+
case SENTStartStatusExpired:
|
|
729
|
+
return @"EXPIRED";
|
|
730
|
+
default:
|
|
731
|
+
return @"UNRECOGNIZED_STATUS";
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
- (NSString*)convertDetectionStatusToString:(SENTDetectionStatus) detectionStatus {
|
|
736
|
+
switch (detectionStatus) {
|
|
737
|
+
|
|
738
|
+
case SENTDetectionStatusDisabled:
|
|
739
|
+
return @"DISABLED";
|
|
740
|
+
case SENTDetectionStatusExpired:
|
|
741
|
+
return @"EXPIRED";
|
|
742
|
+
case SENTDetectionStatusEnabledButBlocked:
|
|
743
|
+
return @"ENABLED_BUT_BLOCKED";
|
|
744
|
+
case SENTDetectionStatusEnabledAndDetecting:
|
|
745
|
+
return @"ENABLED_AND_DETECTING";
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
- (NSDictionary *)convertUserLinkingResult:(SENTUserLinkingResult *)userLinkingResult {
|
|
750
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
751
|
+
|
|
752
|
+
dict[@"userId"] = userLinkingResult.userInfo.userId;
|
|
753
|
+
dict[@"tokenId"] = userLinkingResult.userInfo.token.tokenId;
|
|
754
|
+
dict[@"tokenExpiryDate"] = userLinkingResult.userInfo.token.expiryDate;
|
|
755
|
+
dict[@"isTokenExpired"] = @(NO);
|
|
756
|
+
|
|
757
|
+
return dict;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
- (NSString *)stringifyUserLinkingError:(SENTUserLinkingError *)userLinkingError {
|
|
761
|
+
NSString *reason;
|
|
762
|
+
switch (userLinkingError.failureReason) {
|
|
763
|
+
case SENTUserLinkingFailureReasonNoUser:
|
|
764
|
+
reason = @"NO_USER";
|
|
765
|
+
break;
|
|
766
|
+
case SENTUserLinkingFailureReasonUserAlreadyLinked:
|
|
767
|
+
reason = @"USER_ALREADY_LINKED";
|
|
768
|
+
break;
|
|
769
|
+
case SENTUserLinkingFailureReasonNetworkError:
|
|
770
|
+
reason = @"NETWORK_ERROR";
|
|
771
|
+
break;
|
|
772
|
+
case SENTUserLinkingFailureReasonServerError:
|
|
773
|
+
reason = @"SERVER_ERROR";
|
|
774
|
+
break;
|
|
775
|
+
case SENTUserLinkingFailureReasonUserDisabledRemotely:
|
|
776
|
+
reason = @"USER_DISABLED_REMOTELY";
|
|
777
|
+
break;
|
|
778
|
+
case SENTUserLinkingFailureReasonUnexpectedError:
|
|
779
|
+
reason = @"UNEXPECTED_ERROR";
|
|
780
|
+
break;
|
|
781
|
+
case SENTUserLinkingFailureReasonAppSideLinkingFailed:
|
|
782
|
+
reason = @"APP_SIDE_LINKING_FAILED";
|
|
783
|
+
break;
|
|
784
|
+
}
|
|
785
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, userLinkingError.details];
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
- (NSDictionary *)convertResetResult:(SENTResetResult *)resetResult {
|
|
789
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
790
|
+
dict[@"initState"] = [self convertInitStateToString:resetResult.initState];
|
|
791
|
+
|
|
792
|
+
return dict;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
- (NSString *)stringifyResetError:(SENTResetError *)resetError {
|
|
796
|
+
NSString *reason;
|
|
797
|
+
NSString *details;
|
|
798
|
+
switch (resetError.failureReason) {
|
|
799
|
+
case SENTResetFailureReasonInitInProgress:
|
|
800
|
+
reason = @"SDK_INIT_IN_PROGRESS";
|
|
801
|
+
details = @"SDK initialization is in progress. Resetting at this time is not allowed.";
|
|
802
|
+
break;
|
|
803
|
+
case SENTResetFailureReasonResetting:
|
|
804
|
+
reason = @"SDK_RESET_IN_PROGRESS";
|
|
805
|
+
details = @"SDK initialization is in progress. Resetting at this time is not allowed.";
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
- (NSDictionary *)convertStartTripResult:(SENTStartTripResult *)startTripResult {
|
|
812
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
813
|
+
// empty object
|
|
814
|
+
|
|
815
|
+
return dict;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
- (NSString *)stringifyStartTripError:(SENTStartTripError *)startTripError {
|
|
819
|
+
NSString *reason;
|
|
820
|
+
NSString *details;
|
|
821
|
+
switch (startTripError.failureReason) {
|
|
822
|
+
case SENTStartTripFailureReasonNoUser:
|
|
823
|
+
reason = @"NO_USER";
|
|
824
|
+
details = @"No Sentiance user present on the device.";
|
|
825
|
+
break;
|
|
826
|
+
case SENTStartTripFailureReasonDetectionsDisabled:
|
|
827
|
+
reason = @"DETECTIONS_DISABLED";
|
|
828
|
+
details = @"Detections are disabled. Enable them first before starting a trip.";
|
|
829
|
+
break;
|
|
830
|
+
case SENTStartTripFailureReasonDetectionsBlocked:
|
|
831
|
+
reason = @"DETECTIONS_BLOCKED";
|
|
832
|
+
details = @"Detections are enabled but not running. Check the SDK's status to find out why.";
|
|
833
|
+
break;
|
|
834
|
+
case SENTStartTripFailureReasonTripAlreadyStarted:
|
|
835
|
+
reason = @"TRIP_ALREADY_STARTED";
|
|
836
|
+
details = @"An external trip is already started. To start a new trip, call `stopTrip()` first.";
|
|
837
|
+
break;
|
|
838
|
+
case SENTStartTripFailureReasonUserDisabledRemotely:
|
|
839
|
+
reason = @"USER_DISABLED_REMOTELY";
|
|
840
|
+
details = @"The user is disabled remotely.";
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
- (NSDictionary *)convertStopTripResult:(SENTStopTripResult *)stopTripResult {
|
|
847
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
848
|
+
// empty object
|
|
849
|
+
|
|
850
|
+
return dict;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
- (NSString *)stringifyStopTripError:(SENTStopTripError *)stopTripError {
|
|
854
|
+
NSString *reason;
|
|
855
|
+
NSString *details;
|
|
856
|
+
switch (stopTripError.failureReason) {
|
|
857
|
+
case SENTStopTripFailureReasonNoOngoingTrip:
|
|
858
|
+
reason = @"NO_ONGOING_TRIP";
|
|
859
|
+
details = @"There is no ongoing external trip.";
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
863
|
+
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
- (NSDictionary *)convertRequestUserAccessTokenResult:(SENTUserAccessTokenResult *)userAccessTokenResult {
|
|
867
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
868
|
+
|
|
869
|
+
dict[@"tokenId"] = userAccessTokenResult.token.tokenId;
|
|
870
|
+
dict[@"expiryDate"] = userAccessTokenResult.token.expiryDate;
|
|
871
|
+
|
|
872
|
+
return dict;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
- (NSString *)stringifyRequestUserAccessTokenError:(SENTUserAccessTokenError *)userAccessTokenError {
|
|
876
|
+
NSString *reason;
|
|
877
|
+
NSString *details;
|
|
878
|
+
switch (userAccessTokenError.failureReason) {
|
|
879
|
+
case SENTUserAccessTokenFailureReasonNoUser:
|
|
880
|
+
reason = @"NO_USER";
|
|
881
|
+
details = @"No Sentiance user present on the device.";
|
|
882
|
+
break;
|
|
883
|
+
case SENTUserAccessTokenFailureReasonNetworkError:
|
|
884
|
+
reason = @"NETWORK_ERROR";
|
|
885
|
+
details = @"A network error occurred. This can happen when the existing token is expired, and it was not possible to contact the Sentiance Platform to refresh it.";
|
|
886
|
+
break;
|
|
887
|
+
case SENTUserAccessTokenFailureReasonUserDisabledRemotely:
|
|
888
|
+
reason = @"USER_DISABLED_REMOTELY";
|
|
889
|
+
details = @"The user is disabled remotely.";
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
- (NSDictionary *)convertSubmitDetectionsResult:(SENTSubmitDetectionsResult *)submitDetectionsResult {
|
|
896
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
897
|
+
// empty object
|
|
898
|
+
|
|
899
|
+
return dict;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
- (NSString *)stringifySubmitDetectionsError:(SENTSubmitDetectionsError *)submitDetectionsError {
|
|
903
|
+
NSString *reason;
|
|
904
|
+
NSString *details;
|
|
905
|
+
switch (submitDetectionsError.failureReason) {
|
|
906
|
+
|
|
907
|
+
case SENTSubmitDetectionsFailureReasonNoUser:
|
|
908
|
+
reason = @"NO_USER";
|
|
909
|
+
details = @"No Sentiance user present on the device.";
|
|
910
|
+
break;
|
|
911
|
+
case SENTSubmitDetectionsFailureReasonNetworkError:
|
|
912
|
+
reason = @"NETWORK_ERROR";
|
|
913
|
+
details = @"A network error occurred.";
|
|
914
|
+
break;
|
|
915
|
+
case SENTSubmitDetectionsFailureReasonUserDisabledRemotely:
|
|
916
|
+
reason = @"USER_DISABLED_REMOTELY";
|
|
917
|
+
details = @"The user is disabled remotely.";
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
- (NSDictionary *)convertEnableDetectionsResult:(SENTEnableDetectionsResult *)enableDetectionsResult {
|
|
924
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
925
|
+
|
|
926
|
+
dict[@"sdkStatus"] = [self convertSdkStatusToDict:enableDetectionsResult.sdkStatus];
|
|
927
|
+
dict[@"detectionStatus"] = [self convertDetectionStatusToString:enableDetectionsResult.detectionStatus];
|
|
928
|
+
|
|
929
|
+
return dict;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
- (NSString *)stringifyEnableDetectionsError:(SENTEnableDetectionsError *)enableDetectionsError {
|
|
933
|
+
NSString *reason;
|
|
934
|
+
NSString *details;
|
|
935
|
+
switch (enableDetectionsError.failureReason) {
|
|
936
|
+
|
|
937
|
+
case SENTEnableDetectionsFailureReasonNoUser:
|
|
938
|
+
reason = @"NO_USER";
|
|
939
|
+
details = @"No Sentiance user present on the device.";
|
|
940
|
+
break;
|
|
941
|
+
case SENTEnableDetectionsFailureReasonPastExpiryDate:
|
|
942
|
+
reason = @"PAST_EXPIRY_DATE";
|
|
943
|
+
details = @"Expiry date is in past.";
|
|
944
|
+
break;
|
|
945
|
+
case SENTEnableDetectionsFailureReasonUserDisabledRemotely:
|
|
946
|
+
reason = @"USER_DISABLED_REMOTELY";
|
|
947
|
+
details = @"The user is disabled remotely.";
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
- (NSDictionary *)convertDisableDetectionsResult:(SENTDisableDetectionsResult *)disableDetectionsResult {
|
|
954
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
955
|
+
|
|
956
|
+
dict[@"sdkStatus"] = [self convertSdkStatusToDict:disableDetectionsResult.sdkStatus];
|
|
957
|
+
dict[@"detectionStatus"] = [self convertDetectionStatusToString:disableDetectionsResult.detectionStatus];
|
|
958
|
+
|
|
959
|
+
return dict;
|
|
960
|
+
}
|
|
961
|
+
- (NSString *)stringifyDisableDetectionsError:(SENTDisableDetectionsError *)disableDetectionsError {
|
|
962
|
+
// Disable detections always succeed
|
|
963
|
+
return @"";
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
- (NSString *)stringifyUserContextError:(SENTRequestUserContextError *)userContextError {
|
|
967
|
+
NSString *reason;
|
|
968
|
+
NSString *details;
|
|
969
|
+
|
|
970
|
+
switch (userContextError.failureReason) {
|
|
971
|
+
case SENTRequestUserContextFailureReasonNoUser:
|
|
972
|
+
reason = @"NO_USER";
|
|
973
|
+
details = @"No Sentiance user present on the device.";
|
|
974
|
+
break;
|
|
975
|
+
case SENTRequestUserContextFailureReasonFeatureNotEnabled:
|
|
976
|
+
reason = @"FEATURE_NOT_ENABLED";
|
|
977
|
+
details = @"Feature not enabled. Contact Sentiance support to enable it.";
|
|
978
|
+
break;
|
|
979
|
+
case SENTRequestUserContextFailureReasonUserDisabledRemotely:
|
|
980
|
+
reason = @"USER_DISABLED_REMOTELY";
|
|
981
|
+
details = @"The user is disabled remotely.";
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
return [NSString stringWithFormat:@"Reason: %@ - %@", reason, details];
|
|
985
|
+
}
|
|
986
|
+
@end
|