hypertrack-sdk-react-native 13.4.0 → 13.5.0

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.
Files changed (42) hide show
  1. package/android/gradle.properties +1 -1
  2. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +38 -6
  3. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +7 -0
  4. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt +1 -0
  5. package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +80 -44
  6. package/hypertrack-sdk-react-native.podspec +1 -1
  7. package/ios/HyperTrackReactNativePlugin.m +4 -1
  8. package/ios/HyperTrackReactNativePlugin.swift +21 -1
  9. package/ios/common/HyperTrackSDKWrapper.swift +4 -0
  10. package/ios/common/SDKMethod.swift +1 -0
  11. package/ios/common/Serialization.swift +30 -0
  12. package/lib/commonjs/HyperTrack/HyperTrack.js +68 -1
  13. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
  14. package/lib/commonjs/HyperTrack/data_types/Order.js +6 -0
  15. package/lib/commonjs/HyperTrack/data_types/Order.js.map +1 -0
  16. package/lib/commonjs/HyperTrack/data_types/internal/OrderInternal.js +6 -0
  17. package/lib/commonjs/HyperTrack/data_types/internal/OrderInternal.js.map +1 -0
  18. package/lib/commonjs/HyperTrack/data_types/internal/OrdersInternal.js +2 -0
  19. package/lib/commonjs/HyperTrack/data_types/internal/OrdersInternal.js.map +1 -0
  20. package/lib/commonjs/index.js +0 -66
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/module/HyperTrack/HyperTrack.js +68 -1
  23. package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
  24. package/lib/module/HyperTrack/data_types/Order.js +2 -0
  25. package/lib/module/HyperTrack/data_types/Order.js.map +1 -0
  26. package/lib/module/HyperTrack/data_types/internal/OrderInternal.js +2 -0
  27. package/lib/module/HyperTrack/data_types/internal/OrderInternal.js.map +1 -0
  28. package/lib/module/HyperTrack/data_types/internal/OrdersInternal.js +2 -0
  29. package/lib/module/HyperTrack/data_types/internal/OrdersInternal.js.map +1 -0
  30. package/lib/module/index.js +0 -6
  31. package/lib/module/index.js.map +1 -1
  32. package/lib/typescript/HyperTrack/HyperTrack.d.ts +30 -2
  33. package/lib/typescript/HyperTrack/data_types/Order.d.ts +6 -0
  34. package/lib/typescript/HyperTrack/data_types/internal/OrderInternal.d.ts +7 -0
  35. package/lib/typescript/HyperTrack/data_types/internal/OrdersInternal.d.ts +4 -0
  36. package/lib/typescript/index.d.ts +7 -6
  37. package/package.json +2 -2
  38. package/src/HyperTrack/HyperTrack.ts +84 -2
  39. package/src/HyperTrack/data_types/Order.ts +7 -0
  40. package/src/HyperTrack/data_types/internal/OrderInternal.ts +8 -0
  41. package/src/HyperTrack/data_types/internal/OrdersInternal.ts +4 -0
  42. package/src/index.tsx +10 -7
@@ -1,3 +1,3 @@
1
1
  HyperTrackSdk_kotlinVersion=1.6.21
2
- HyperTrackSdk_HyperTrackSDKVersion=7.6.0
2
+ HyperTrackSdk_HyperTrackSDKVersion=7.7.0
3
3
  android.useAndroidX=true
@@ -1,16 +1,23 @@
1
1
  package com.reactnativehypertracksdk
2
2
 
3
- import com.facebook.react.bridge.*
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
+ import com.facebook.react.bridge.ReactMethod
7
+ import com.facebook.react.bridge.ReadableMap
8
+ import com.facebook.react.bridge.WritableArray
9
+ import com.facebook.react.bridge.WritableMap
4
10
  import com.facebook.react.module.annotations.ReactModule
5
11
  import com.facebook.react.modules.core.DeviceEventManagerModule
6
- import com.hypertrack.sdk.*
7
12
  import com.hypertrack.sdk.android.HyperTrack
8
- import com.reactnativehypertracksdk.common.*
13
+ import com.reactnativehypertracksdk.common.HyperTrackSdkWrapper
9
14
  import com.reactnativehypertracksdk.common.Serialization.serializeErrors
10
15
  import com.reactnativehypertracksdk.common.Serialization.serializeIsAvailable
11
16
  import com.reactnativehypertracksdk.common.Serialization.serializeIsTracking
12
17
  import com.reactnativehypertracksdk.common.Serialization.serializeLocateResult
13
18
  import com.reactnativehypertracksdk.common.Serialization.serializeLocationResult
19
+ import com.reactnativehypertracksdk.common.Serialization.serializeOrders
20
+ import com.reactnativehypertracksdk.common.Success
14
21
 
15
22
  @ReactModule(name = HyperTrackReactNativePlugin.NAME)
16
23
  class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) :
@@ -40,15 +47,28 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) :
40
47
  EVENT_ERRORS -> {
41
48
  emitEvent(EVENT_ERRORS, serializeErrors(HyperTrack.errors).toWriteableArray())
42
49
  }
50
+
43
51
  EVENT_IS_AVAILABLE -> {
44
- emitEvent(EVENT_IS_AVAILABLE, serializeIsAvailable(HyperTrack.isAvailable).toWritableMap())
52
+ emitEvent(
53
+ EVENT_IS_AVAILABLE,
54
+ serializeIsAvailable(HyperTrack.isAvailable).toWritableMap(),
55
+ )
45
56
  }
57
+
46
58
  EVENT_IS_TRACKING -> {
47
- emitEvent(EVENT_IS_TRACKING, serializeIsTracking(HyperTrack.isTracking).toWritableMap())
59
+ emitEvent(
60
+ EVENT_IS_TRACKING,
61
+ serializeIsTracking(HyperTrack.isTracking).toWritableMap(),
62
+ )
48
63
  }
64
+
49
65
  EVENT_LOCATION -> {
50
- emitEvent(EVENT_LOCATION, serializeLocationResult(HyperTrack.location).toWritableMap())
66
+ emitEvent(
67
+ EVENT_LOCATION,
68
+ serializeLocationResult(HyperTrack.location).toWritableMap(),
69
+ )
51
70
  }
71
+
52
72
  else -> Unit
53
73
  }
54
74
  // Keep: Required for RN built in Event Emitter Calls.
@@ -111,6 +131,11 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) :
111
131
  HyperTrackSdkWrapper.getName().toPromise(promise)
112
132
  }
113
133
 
134
+ @ReactMethod
135
+ fun getOrders(promise: Promise) {
136
+ HyperTrackSdkWrapper.getOrders().toPromise(promise)
137
+ }
138
+
114
139
  @ReactMethod
115
140
  fun getWorkerHandle(promise: Promise) {
116
141
  HyperTrackSdkWrapper.getWorkerHandle().toPromise(promise)
@@ -181,6 +206,12 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) :
181
206
  }.also {
182
207
  result.add(it)
183
208
  }
209
+
210
+ HyperTrack.subscribeToOrders {
211
+ emitEvent(EVENT_ORDERS, serializeOrders(it.values).toWritableMap())
212
+ }.also {
213
+ result.add(it)
214
+ }
184
215
  }
185
216
  }
186
217
 
@@ -209,6 +240,7 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) :
209
240
  private const val EVENT_IS_TRACKING = "isTracking"
210
241
  private const val EVENT_LOCATE = "locate"
211
242
  private const val EVENT_LOCATION = "location"
243
+ private const val EVENT_ORDERS = "orders"
212
244
 
213
245
  const val NAME = "HyperTrackReactNativePlugin"
214
246
  }
@@ -21,6 +21,7 @@ import com.reactnativehypertracksdk.common.Serialization.serializeLocationSucces
21
21
  import com.reactnativehypertracksdk.common.Serialization.serializeLocationWithDeviationSuccess
22
22
  import com.reactnativehypertracksdk.common.Serialization.serializeMetadata
23
23
  import com.reactnativehypertracksdk.common.Serialization.serializeName
24
+ import com.reactnativehypertracksdk.common.Serialization.serializeOrders
24
25
  import com.reactnativehypertracksdk.common.Serialization.serializeWorkerHandle
25
26
 
26
27
  typealias Serialized = Map<String, Any?>
@@ -139,6 +140,12 @@ internal object HyperTrackSdkWrapper {
139
140
  )
140
141
  }
141
142
 
143
+ fun getOrders(): WrapperResult<Serialized> {
144
+ return Success(
145
+ serializeOrders(HyperTrack.orders.values),
146
+ )
147
+ }
148
+
142
149
  fun getWorkerHandle(): WrapperResult<Serialized> {
143
150
  return Success(
144
151
  serializeWorkerHandle(HyperTrack.workerHandle),
@@ -16,6 +16,7 @@ internal enum class SdkMethod {
16
16
  getLocation,
17
17
  getMetadata,
18
18
  getName,
19
+ getOrders,
19
20
  getWorkerHandle,
20
21
  locate,
21
22
  setDynamicPublishableKey,
@@ -18,15 +18,15 @@ internal object Serialization {
18
18
  }
19
19
  }
20
20
 
21
- fun deserializeGeotagData(map: Map<String, Any?>): WrapperResult<GeotagData> {
21
+ fun deserializeGeotagData(map: Serialized): WrapperResult<GeotagData> {
22
22
  return parse(map) {
23
23
  val data =
24
24
  it
25
- .get<Map<String, Any?>>(KEY_GEOTAG_DATA)
25
+ .get<Serialized>(KEY_GEOTAG_DATA)
26
26
  .getOrThrow()
27
27
  val expectedLocationData =
28
28
  it
29
- .getOptional<Map<String, Any?>>(KEY_GEOTAG_EXPECTED_LOCATION)
29
+ .getOptional<Serialized>(KEY_GEOTAG_EXPECTED_LOCATION)
30
30
  .getOrThrow()
31
31
  val expectedLocation =
32
32
  expectedLocationData?.let {
@@ -34,12 +34,12 @@ internal object Serialization {
34
34
  }
35
35
  val orderHandleData =
36
36
  it
37
- .getOptional<Map<String, Any?>>(KEY_GEOTAG_ORDER_HANDLE)
37
+ .getOptional<Serialized>(KEY_GEOTAG_ORDER_HANDLE)
38
38
  .getOrThrow()
39
39
  val orderHandle = orderHandleData?.let { deserializeOrderHandle(it).getOrThrow() }
40
40
  val orderStatusData =
41
41
  it
42
- .getOptional<Map<String, Any?>>(KEY_GEOTAG_ORDER_STATUS)
42
+ .getOptional<Serialized>(KEY_GEOTAG_ORDER_STATUS)
43
43
  .getOrThrow()
44
44
  val orderStatus = orderStatusData?.let { deserializeOrderStatus(it).getOrThrow() }
45
45
  GeotagData(
@@ -51,7 +51,7 @@ internal object Serialization {
51
51
  }
52
52
  }
53
53
 
54
- fun deserializeIsAvailable(isAvailable: Map<String, Any?>): WrapperResult<Boolean> {
54
+ fun deserializeIsAvailable(isAvailable: Serialized): WrapperResult<Boolean> {
55
55
  return parse(isAvailable) {
56
56
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_IS_AVAILABLE)
57
57
  it
@@ -60,7 +60,7 @@ internal object Serialization {
60
60
  }
61
61
  }
62
62
 
63
- fun deserializeIsTracking(isTracking: Map<String, Any?>): WrapperResult<Boolean> {
63
+ fun deserializeIsTracking(isTracking: Serialized): WrapperResult<Boolean> {
64
64
  return parse(isTracking) {
65
65
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_IS_TRACKING)
66
66
  it
@@ -69,16 +69,16 @@ internal object Serialization {
69
69
  }
70
70
  }
71
71
 
72
- fun deserializeMetadata(metadata: Map<String, Any?>): WrapperResult<Map<String, Any?>> {
72
+ fun deserializeMetadata(metadata: Serialized): WrapperResult<Serialized> {
73
73
  return parse(metadata) {
74
74
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_METADATA)
75
75
  it
76
- .get<Map<String, Any?>>(KEY_VALUE)
76
+ .get<Serialized>(KEY_VALUE)
77
77
  .getOrThrow()
78
78
  }
79
79
  }
80
80
 
81
- fun deserializeName(name: Map<String, Any?>): WrapperResult<String> {
81
+ fun deserializeName(name: Serialized): WrapperResult<String> {
82
82
  return parse(name) {
83
83
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_NAME)
84
84
  it
@@ -87,7 +87,7 @@ internal object Serialization {
87
87
  }
88
88
  }
89
89
 
90
- fun deserializeWorkerHandle(map: Map<String, Any?>): WrapperResult<String> {
90
+ fun deserializeWorkerHandle(map: Serialized): WrapperResult<String> {
91
91
  return parse(map) {
92
92
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_WORKER_HANDLE)
93
93
  it
@@ -96,7 +96,7 @@ internal object Serialization {
96
96
  }
97
97
  }
98
98
 
99
- fun serializeDeviceId(deviceId: String): Map<String, Any?> {
99
+ fun serializeDeviceId(deviceId: String): Serialized {
100
100
  return mapOf(
101
101
  KEY_TYPE to TYPE_DEVICE_ID,
102
102
  KEY_VALUE to deviceId,
@@ -136,21 +136,21 @@ internal object Serialization {
136
136
  }
137
137
  }
138
138
 
139
- fun serializeIsAvailable(isAvailable: Boolean): Map<String, Any?> {
139
+ fun serializeIsAvailable(isAvailable: Boolean): Serialized {
140
140
  return mapOf(
141
141
  KEY_TYPE to TYPE_IS_AVAILABLE,
142
142
  KEY_VALUE to isAvailable,
143
143
  )
144
144
  }
145
145
 
146
- fun serializeIsTracking(isTracking: Boolean): Map<String, Any?> {
146
+ fun serializeIsTracking(isTracking: Boolean): Serialized {
147
147
  return mapOf(
148
148
  KEY_TYPE to TYPE_IS_TRACKING,
149
149
  KEY_VALUE to isTracking,
150
150
  )
151
151
  }
152
152
 
153
- fun serializeLocateResult(locationResult: Result<HyperTrack.Location, Set<HyperTrack.Error>>): Map<String, Any?> {
153
+ fun serializeLocateResult(locationResult: Result<HyperTrack.Location, Set<HyperTrack.Error>>): Serialized {
154
154
  return when (locationResult) {
155
155
  is Result.Failure -> {
156
156
  serializeFailure(serializeErrors(locationResult.failure))
@@ -162,7 +162,7 @@ internal object Serialization {
162
162
  }
163
163
  }
164
164
 
165
- fun serializeLocationResult(locationResult: Result<HyperTrack.Location, HyperTrack.LocationError>): Map<String, Any?> {
165
+ fun serializeLocationResult(locationResult: Result<HyperTrack.Location, HyperTrack.LocationError>): Serialized {
166
166
  return when (locationResult) {
167
167
  is Result.Failure -> {
168
168
  serializeLocationErrorFailure(locationResult.failure)
@@ -174,15 +174,15 @@ internal object Serialization {
174
174
  }
175
175
  }
176
176
 
177
- fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Map<String, Any?> {
177
+ fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Serialized {
178
178
  return serializeFailure(serializeLocationError(locationError))
179
179
  }
180
180
 
181
- fun serializeLocationSuccess(location: HyperTrack.Location): Map<String, Any?> {
181
+ fun serializeLocationSuccess(location: HyperTrack.Location): Serialized {
182
182
  return serializeSuccess(serializeLocation(location))
183
183
  }
184
184
 
185
- fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Map<String, Any?> {
185
+ fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized {
186
186
  return serializeSuccess(
187
187
  serializeLocationWithDeviation(
188
188
  locationWithDeviation,
@@ -190,44 +190,47 @@ internal object Serialization {
190
190
  )
191
191
  }
192
192
 
193
- fun serializeLocation(location: HyperTrack.Location): Map<String, Any?> {
194
- return mapOf(
195
- KEY_TYPE to TYPE_LOCATION,
196
- KEY_VALUE to
197
- mapOf(
198
- KEY_LATITUDE to location.latitude,
199
- KEY_LONGITUDE to location.longitude,
200
- ),
201
- )
202
- }
203
-
204
- fun serializeMetadata(metadata: Map<String, Any?>): Map<String, Any?> {
193
+ fun serializeMetadata(metadata: Serialized): Serialized {
205
194
  return mapOf(
206
195
  KEY_TYPE to TYPE_METADATA,
207
196
  KEY_VALUE to metadata,
208
197
  )
209
198
  }
210
199
 
211
- fun serializeName(name: String): Map<String, Any?> {
200
+ fun serializeName(name: String): Serialized {
212
201
  return mapOf(
213
202
  KEY_TYPE to TYPE_NAME,
214
203
  KEY_VALUE to name,
215
204
  )
216
205
  }
217
206
 
218
- fun serializeWorkerHandle(workerHandle: String): Map<String, Any?> {
207
+ fun serializeOrders(orders: Collection<HyperTrack.Order>): Serialized {
208
+ return mapOf(
209
+ KEY_TYPE to TYPE_ORDERS,
210
+ KEY_VALUE to
211
+ orders.mapIndexed { index, order ->
212
+ mapOf(
213
+ KEY_ORDER_HANDLE to order.orderHandle,
214
+ KEY_ORDER_INDEX to index,
215
+ KEY_ORDER_IS_INSIDE_GEOFENCE to serializeIsInsideGeofence(order.isInsideGeofence),
216
+ )
217
+ },
218
+ )
219
+ }
220
+
221
+ fun serializeWorkerHandle(workerHandle: String): Serialized {
219
222
  return mapOf(
220
223
  KEY_TYPE to TYPE_WORKER_HANDLE,
221
224
  KEY_VALUE to workerHandle,
222
225
  )
223
226
  }
224
227
 
225
- private fun deserializeLocation(map: Map<String, Any?>): WrapperResult<Location> {
228
+ private fun deserializeLocation(map: Serialized): WrapperResult<Location> {
226
229
  return parse(map) {
227
230
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_LOCATION)
228
231
  val value =
229
232
  it
230
- .get<Map<String, Any?>>(KEY_VALUE)
233
+ .get<Serialized>(KEY_VALUE)
231
234
  .getOrThrow()
232
235
  parse(value) { parser ->
233
236
  val latitude =
@@ -246,7 +249,7 @@ internal object Serialization {
246
249
  }
247
250
  }
248
251
 
249
- private fun deserializeOrderHandle(map: Map<String, Any?>): WrapperResult<String> {
252
+ private fun deserializeOrderHandle(map: Serialized): WrapperResult<String> {
250
253
  return parse(map) {
251
254
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_ORDER_HANDLE)
252
255
  it
@@ -255,7 +258,7 @@ internal object Serialization {
255
258
  }
256
259
  }
257
260
 
258
- private fun deserializeOrderStatus(map: Map<String, Any?>): WrapperResult<HyperTrack.OrderStatus> {
261
+ private fun deserializeOrderStatus(map: Serialized): WrapperResult<HyperTrack.OrderStatus> {
259
262
  return parse(map) {
260
263
  when (it.get<String>(KEY_TYPE).getOrThrow()) {
261
264
  TYPE_GEOTAG_ORDER_STATUS_CLOCK_IN -> HyperTrack.OrderStatus.ClockIn
@@ -270,7 +273,35 @@ internal object Serialization {
270
273
  }
271
274
  }
272
275
 
273
- private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Map<String, Any?> {
276
+ private fun serializeIsInsideGeofence(isInsideGeofence: Result<Boolean, HyperTrack.LocationError>): Serialized {
277
+ return when (isInsideGeofence) {
278
+ is Result.Failure -> {
279
+ serializeFailure(serializeLocationError(isInsideGeofence.failure))
280
+ }
281
+
282
+ is Result.Success -> {
283
+ serializeSuccess(
284
+ mapOf(
285
+ KEY_TYPE to TYPE_IS_INSIDE_GEOFENCE,
286
+ KEY_VALUE to isInsideGeofence.success,
287
+ ),
288
+ )
289
+ }
290
+ }
291
+ }
292
+
293
+ private fun serializeLocation(location: HyperTrack.Location): Serialized {
294
+ return mapOf(
295
+ KEY_TYPE to TYPE_LOCATION,
296
+ KEY_VALUE to
297
+ mapOf(
298
+ KEY_LATITUDE to location.latitude,
299
+ KEY_LONGITUDE to location.longitude,
300
+ ),
301
+ )
302
+ }
303
+
304
+ private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized {
274
305
  return mapOf(
275
306
  KEY_TYPE to TYPE_LOCATION_WITH_DEVIATION,
276
307
  KEY_VALUE to
@@ -281,28 +312,28 @@ internal object Serialization {
281
312
  )
282
313
  }
283
314
 
284
- private fun serializeFailure(failure: List<Map<String, Any?>>): Map<String, Any?> {
315
+ private fun serializeFailure(failure: List<Serialized>): Serialized {
285
316
  return mapOf(
286
317
  KEY_TYPE to TYPE_RESULT_FAILURE,
287
318
  KEY_VALUE to failure,
288
319
  )
289
320
  }
290
321
 
291
- private fun serializeFailure(failure: Map<String, Any?>): Map<String, Any?> {
322
+ private fun serializeFailure(failure: Serialized): Serialized {
292
323
  return mapOf(
293
324
  KEY_TYPE to TYPE_RESULT_FAILURE,
294
325
  KEY_VALUE to failure,
295
326
  )
296
327
  }
297
328
 
298
- private fun serializeSuccess(success: Map<String, Any?>): Map<String, Any?> {
329
+ private fun serializeSuccess(success: Serialized): Serialized {
299
330
  return mapOf(
300
331
  KEY_TYPE to TYPE_RESULT_SUCCESS,
301
332
  KEY_VALUE to success,
302
333
  )
303
334
  }
304
335
 
305
- private fun serializeLocationError(locationError: HyperTrack.LocationError): Map<String, Any?> {
336
+ private fun serializeLocationError(locationError: HyperTrack.LocationError): Serialized {
306
337
  return when (locationError) {
307
338
  HyperTrack.LocationError.NotRunning -> {
308
339
  mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_NOT_RUNNING)
@@ -324,7 +355,7 @@ internal object Serialization {
324
355
  }
325
356
 
326
357
  fun <T> parse(
327
- source: Map<String, Any?>,
358
+ source: Serialized,
328
359
  parseFunction: (Parser) -> T,
329
360
  ): WrapperResult<T> {
330
361
  val parser = Parser(source)
@@ -346,7 +377,7 @@ internal object Serialization {
346
377
  }
347
378
 
348
379
  internal class Parser(
349
- private val source: Map<String, Any?>,
380
+ private val source: Serialized,
350
381
  ) {
351
382
  private val _exceptions = mutableListOf<Exception>()
352
383
  val exceptions: List<Exception> = _exceptions
@@ -412,11 +443,13 @@ internal object Serialization {
412
443
  private const val TYPE_DYNAMIC_PUBLISHABLE_KEY = "dynamicPublishableKey"
413
444
  private const val TYPE_ERROR = "error"
414
445
  private const val TYPE_IS_AVAILABLE = "isAvailable"
446
+ private const val TYPE_IS_INSIDE_GEOFENCE = "isInsideGeofence"
415
447
  private const val TYPE_IS_TRACKING = "isTracking"
416
448
  private const val TYPE_LOCATION = "location"
417
449
  private const val TYPE_LOCATION_WITH_DEVIATION = "locationWithDeviation"
418
450
  private const val TYPE_METADATA = "metadata"
419
451
  private const val TYPE_NAME = "name"
452
+ private const val TYPE_ORDERS = "orders"
420
453
  private const val TYPE_WORKER_HANDLE = "workerHandle"
421
454
 
422
455
  private const val TYPE_LOCATION_ERROR_ERRORS = "errors"
@@ -436,5 +469,8 @@ internal object Serialization {
436
469
  private const val KEY_GEOTAG_EXPECTED_LOCATION = "expectedLocation"
437
470
  private const val KEY_GEOTAG_ORDER_HANDLE = "orderHandle"
438
471
  private const val KEY_GEOTAG_ORDER_STATUS = "orderStatus"
472
+ private const val KEY_ORDER_IS_INSIDE_GEOFENCE = "isInsideGeofence"
439
473
  private const val KEY_LOCATION = "location"
474
+ private const val KEY_ORDER_HANDLE = "orderHandle"
475
+ private const val KEY_ORDER_INDEX = "orderIndex"
440
476
  }
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
19
 
20
20
  s.dependency "React-Core"
21
- s.dependency 'HyperTrack', '5.6.0'
21
+ s.dependency 'HyperTrack', '5.7.0'
22
22
 
23
23
  # Don't install the dependencies when we run `pod install` in the old architecture.
24
24
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
@@ -37,8 +37,11 @@ RCT_EXTERN_METHOD(getMetadata:(RCTPromiseResolveBlock)resolve
37
37
  RCT_EXTERN_METHOD(getName:(RCTPromiseResolveBlock)resolve
38
38
  rejecter:(RCTPromiseRejectBlock)reject)
39
39
 
40
+ RCT_EXTERN_METHOD(getOrders:(RCTPromiseResolveBlock)resolve
41
+ rejecter:(RCTPromiseRejectBlock)reject)
42
+
40
43
  RCT_EXTERN_METHOD(getWorkerHandle:(RCTPromiseResolveBlock)resolve
41
- rejecter:(RCTPromiseRejectBlock)reject)
44
+ rejecter:(RCTPromiseRejectBlock)reject)
42
45
 
43
46
  RCT_EXTERN_METHOD(locate:(RCTPromiseResolveBlock)resolve
44
47
  rejecter:(RCTPromiseRejectBlock)reject)
@@ -5,6 +5,7 @@ struct Subscriptions {
5
5
  let isAvailableSubscription: HyperTrack.Cancellable
6
6
  let isTrackingSubscription: HyperTrack.Cancellable
7
7
  let errorsSubscription: HyperTrack.Cancellable
8
+ let ordersSubscription: HyperTrack.Cancellable
8
9
  }
9
10
 
10
11
  @objc(HyperTrackReactNativePlugin)
@@ -14,6 +15,7 @@ class HyperTrackReactNativePlugin: RCTEventEmitter {
14
15
  private let eventIsTracking = "isTracking"
15
16
  private let eventLocate = "locate"
16
17
  private let eventLocation = "location"
18
+ private let eventOrders = "orders"
17
19
 
18
20
  private var subscriptions: Subscriptions? = nil
19
21
  private var locateSubscription: HyperTrack.Cancellable? = nil
@@ -29,6 +31,7 @@ class HyperTrackReactNativePlugin: RCTEventEmitter {
29
31
  eventIsTracking,
30
32
  eventLocate,
31
33
  eventLocation,
34
+ eventOrders,
32
35
  ]
33
36
  }
34
37
 
@@ -52,6 +55,8 @@ class HyperTrackReactNativePlugin: RCTEventEmitter {
52
55
  sendEvent(withName: eventErrors, body: serializeErrors(HyperTrack.errors))
53
56
  case eventLocation:
54
57
  sendEvent(withName: eventLocation, body: serializeLocationResult(HyperTrack.location))
58
+ case eventOrders:
59
+ sendEvent(withName: eventOrders, body: serializeOrders(Array(HyperTrack.orders)))
55
60
  default:
56
61
  return
57
62
  }
@@ -168,6 +173,18 @@ class HyperTrackReactNativePlugin: RCTEventEmitter {
168
173
  )
169
174
  }
170
175
 
176
+ @objc func getOrders(
177
+ _ resolve: RCTPromiseResolveBlock,
178
+ rejecter reject: RCTPromiseRejectBlock
179
+ ) {
180
+ sendAsPromise(
181
+ hypertrack_sdk_react_native.getOrders(),
182
+ method: .getOrders,
183
+ resolve,
184
+ reject
185
+ )
186
+ }
187
+
171
188
  @objc func getWorkerHandle(
172
189
  _ resolve: RCTPromiseResolveBlock,
173
190
  rejecter reject: RCTPromiseRejectBlock
@@ -299,7 +316,10 @@ class HyperTrackReactNativePlugin: RCTEventEmitter {
299
316
  let locationSubscription = HyperTrack.subscribeToLocation { locationResult in
300
317
  self.sendEvent(withName: self.eventLocation, body: serializeLocationResult(locationResult))
301
318
  }
302
- return Subscriptions(locationSubscription: locationSubscription, isAvailableSubscription: isAvailableSubscription, isTrackingSubscription: isTrackingSubscription, errorsSubscription: errorsSubscription)
319
+ let ordersSubscription = HyperTrack.subscribeToOrders { orders in
320
+ self.sendEvent(withName: self.eventOrders, body: serializeOrders(Array(orders)))
321
+ }
322
+ return Subscriptions(locationSubscription: locationSubscription, isAvailableSubscription: isAvailableSubscription, isTrackingSubscription: isTrackingSubscription, errorsSubscription: errorsSubscription, ordersSubscription: ordersSubscription)
303
323
  }
304
324
  }
305
325
 
@@ -88,6 +88,10 @@ func getName() -> Result<SuccessResult, FailureResult> {
88
88
  .success(.dict(serializeName(HyperTrack.name)))
89
89
  }
90
90
 
91
+ func getOrders() -> Result<SuccessResult, FailureResult> {
92
+ .success(.dict(serializeOrders(Array(HyperTrack.orders))))
93
+ }
94
+
91
95
  func getWorkerHandle() -> Result<SuccessResult, FailureResult> {
92
96
  .success(.dict(serializeWorkerHandle(HyperTrack.workerHandle)))
93
97
  }
@@ -8,6 +8,7 @@ enum SDKMethod: String {
8
8
  case getLocation
9
9
  case getMetadata
10
10
  case getName
11
+ case getOrders
11
12
  case getWorkerHandle
12
13
  case locate
13
14
  case setDynamicPublishableKey
@@ -250,6 +250,24 @@ func serializeIsAvailable(_ isAvailable: Bool) -> [String: Any] {
250
250
  ]
251
251
  }
252
252
 
253
+ func serializeIsInsideGeofence(_ isInsideGeofence: Result<Bool, HyperTrack.Location.Error>) -> [String: Any] {
254
+ switch isInsideGeofence {
255
+ case let .success(success):
256
+ return [
257
+ keyType: typeSuccess,
258
+ keyValue: [
259
+ keyType: "isInsideGeofence",
260
+ keyValue: success,
261
+ ],
262
+ ]
263
+ case let .failure(failure):
264
+ return [
265
+ keyType: typeFailure,
266
+ keyValue: serializeLocationError(failure),
267
+ ]
268
+ }
269
+ }
270
+
253
271
  func serializeIsTracking(_ isTracking: Bool) -> [String: Any] {
254
272
  return [
255
273
  keyType: typeIsTracking,
@@ -358,6 +376,18 @@ func serializeName(_ name: String) -> [String: Any] {
358
376
  ]
359
377
  }
360
378
 
379
+ func serializeOrders(_ orders: [HyperTrack.Order]) -> [String: Any] {
380
+ return [
381
+ keyType: "orders",
382
+ keyValue: orders.map { order in
383
+ [
384
+ "orderHandle": order.orderHandle,
385
+ "isInsideGeofence": serializeIsInsideGeofence(order.isInsideGeofence),
386
+ ]
387
+ },
388
+ ]
389
+ }
390
+
361
391
  func serializeWorkerHandle(_ workerHandle: String) -> [String: Any] {
362
392
  return [
363
393
  keyType: typeWorkerHandle,