diff --git a/CHANGELOG.md b/CHANGELOG.md index bbe79e1..ce97bb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.6.3] - 2024-11-13 + +### Changed + +- Updated HyperTrack SDK iOS to [5.8.1](https://github.com/hypertrack/sdk-ios/releases/tag/5.8.1) +- Updated HyperTrack SDK Android to [7.8.4](https://github.com/hypertrack/sdk-android/releases/tag/7.8.4) + ## [3.6.2] - 2024-09-24 ### Changed @@ -309,3 +316,4 @@ We are excited to announce the release of HyperTrack Ionic Capacitor SDK 2.0.0, [3.6.0]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.6.0 [3.6.1]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.6.1 [3.6.2]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.6.2 +[3.6.3]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.6.3 diff --git a/HypertrackSdkIonicCapacitor.podspec b/HypertrackSdkIonicCapacitor.podspec index 9c97483..e0de4ad 100644 --- a/HypertrackSdkIonicCapacitor.podspec +++ b/HypertrackSdkIonicCapacitor.podspec @@ -14,5 +14,5 @@ Pod::Spec.new do |s| s.ios.deployment_target = '12.0' s.dependency 'Capacitor' s.swift_version = '5.1' - s.dependency 'HyperTrack','5.8.0' + s.dependency 'HyperTrack','5.8.1' end diff --git a/README.md b/README.md index 5d7f8fe..4aae29d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![GitHub](https://img.shields.io/github/license/hypertrack/sdk-ionic-capacitor.svg?color=orange)](./LICENSE) [![npm](https://img.shields.io/npm/v/hypertrack-sdk-ionic-capacitor.svg)](https://www.npmjs.com/package/hypertrack-sdk-ionic-capacitor) -[![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.8.0-brightgreen.svg)](https://github.com/hypertrack/sdk-ios) -[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.8.3-brightgreen.svg)](https://github.com/hypertrack/sdk-android) +[![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.8.1-brightgreen.svg)](https://github.com/hypertrack/sdk-ios) +[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.8.4-brightgreen.svg)](https://github.com/hypertrack/sdk-android) [HyperTrack](https://www.hypertrack.com) lets you add live location tracking to your mobile app. Live location is made available along with ongoing activity, tracking controls and tracking outage with reasons. diff --git a/android/.editorconfig b/android/.editorconfig new file mode 100644 index 0000000..3c40c17 --- /dev/null +++ b/android/.editorconfig @@ -0,0 +1,5 @@ +[**/*.kt] +# TODO: use explicit instead of wildcard imports +ktlint_standard_no-wildcard-imports = disabled +# TODO: align with standard enum case naming +ktlint_standard_enum-entry-name-case = disabled diff --git a/android/build.gradle b/android/build.gradle index cc4b176..7e05ec7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -7,7 +7,7 @@ ext { buildscript { ext.kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '1.9.10' - ext.hypertrack_sdk_version = "7.8.3" + ext.hypertrack_sdk_version = "7.8.4" ext.firebase_messaging_version = "23.1.1" repositories { diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/CapacitorSerialization.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/CapacitorSerialization.kt index b5f17c6..0238dc1 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/CapacitorSerialization.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/CapacitorSerialization.kt @@ -5,18 +5,17 @@ import com.getcapacitor.JSObject import com.getcapacitor.PluginCall import com.hypertrack.sdk.capacitor.common.Failure import com.hypertrack.sdk.capacitor.common.Serialized -import com.hypertrack.sdk.capacitor.common.WrapperResult import com.hypertrack.sdk.capacitor.common.Success +import com.hypertrack.sdk.capacitor.common.WrapperResult import org.json.JSONArray import org.json.JSONObject private const val KEY_ERRORS = "errors" -fun serializeErrorsForCapacitor(errors: List): Serialized { - return mapOf( - KEY_ERRORS to errors +fun serializeErrorsForCapacitor(errors: List): Serialized = + mapOf( + KEY_ERRORS to errors, ) -} @Suppress("UNCHECKED_CAST") internal fun WrapperResult.toPluginCall(call: PluginCall) { @@ -47,8 +46,8 @@ internal fun WrapperResult.toPluginCall(call: PluginCall) { } @Suppress("UNCHECKED_CAST") -internal fun List.toJSArray(): JSArray { - return JSArray().also { writableArray -> +internal fun List.toJSArray(): JSArray = + JSArray().also { writableArray -> forEach { when (it) { is Map<*, *> -> { @@ -63,7 +62,6 @@ internal fun List.toJSArray(): JSArray { } } } -} @Suppress("UNCHECKED_CAST") internal fun Map.toJSObject(): JSObject { @@ -91,7 +89,7 @@ internal fun Map.toJSObject(): JSObject { } null -> { throw IllegalArgumentException( - "Invalid JSON: $this \n Null JSON values are not supported" + "Invalid JSON: $this \n Null JSON values are not supported", ) } else -> { @@ -102,13 +100,14 @@ internal fun Map.toJSObject(): JSObject { } } -fun JSONObject.toMap(): Map { - return keys().asSequence().associateWith { key -> +fun JSONObject.toMap(): Map = + keys().asSequence().associateWith { key -> when (val value = this.get(key)) { is Boolean, is Double, is Int, - is String -> { + is String, + -> { value } is JSONArray -> { @@ -122,15 +121,15 @@ fun JSONObject.toMap(): Map { } } } -} -private fun JSONArray.toList(): List { - return (0..length()).mapNotNull { index -> +private fun JSONArray.toList(): List = + (0..length()).mapNotNull { index -> when (val value = this.get(index)) { is Boolean, is Double, is Int, - is String -> { + is String, + -> { value } is JSONArray -> { @@ -144,4 +143,3 @@ private fun JSONArray.toList(): List { } } } -} diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt index 4cd6c77..29fa64c 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt @@ -14,7 +14,6 @@ import com.hypertrack.sdk.capacitor.common.Serialization.serializeOrders @CapacitorPlugin(name = "HyperTrackCapacitorPlugin") class HyperTrackCapacitorPlugin : Plugin() { - private var locateSubscription: HyperTrack.Cancellable? = null init { @@ -114,9 +113,10 @@ class HyperTrackCapacitorPlugin : Plugin() { @PluginMethod fun onSubscribedToLocate(call: PluginCall) { locateSubscription?.cancel() - locateSubscription = HyperTrack.locate { result -> - sendLocateEvent(result) - } + locateSubscription = + HyperTrack.locate { result -> + sendLocateEvent(result) + } } @PluginMethod @@ -132,42 +132,42 @@ class HyperTrackCapacitorPlugin : Plugin() { private fun sendErrorsEvent(errors: Set) { sendEvent( EVENT_ERRORS, - serializeErrorsForCapacitor(serializeErrors(errors)).toJSObject() + serializeErrorsForCapacitor(serializeErrors(errors)).toJSObject(), ) } private fun sendIsAvailableEvent(isAvailable: Boolean) { sendEvent( EVENT_IS_AVAILABLE, - Serialization.serializeIsAvailable(isAvailable).toJSObject() + Serialization.serializeIsAvailable(isAvailable).toJSObject(), ) } private fun sendIsTrackingEvent(isTracking: Boolean) { sendEvent( EVENT_IS_TRACKING, - Serialization.serializeIsTracking(isTracking).toJSObject() + Serialization.serializeIsTracking(isTracking).toJSObject(), ) } private fun sendLocationEvent(locationResult: Result) { sendEvent( EVENT_LOCATION, - Serialization.serializeLocationResult(locationResult).toJSObject() + Serialization.serializeLocationResult(locationResult).toJSObject(), ) } private fun sendLocateEvent(locateResult: Result>) { sendEvent( EVENT_LOCATE, - Serialization.serializeLocateResult(locateResult).toJSObject() + Serialization.serializeLocateResult(locateResult).toJSObject(), ) } private fun sendOrdersEvent(orders: Collection) { sendEvent( EVENT_ORDERS, - serializeOrders(orders).toJSObject() + serializeOrders(orders).toJSObject(), ) } @@ -195,7 +195,7 @@ class HyperTrackCapacitorPlugin : Plugin() { private fun invokeSdkMethod( method: SdkMethod, - call: PluginCall + call: PluginCall, ): WrapperResult<*> { val argsJson = call.data return when (method) { @@ -290,15 +290,19 @@ class HyperTrackCapacitorPlugin : Plugin() { } } - private fun sendEvent(eventName: String, data: JSObject, retainUntilConsumed: Boolean = false) { + private fun sendEvent( + eventName: String, + data: JSObject, + retainUntilConsumed: Boolean = false, + ) { notifyListeners(eventName, data, retainUntilConsumed) } private inline fun withArgs( args: JSObject, - crossinline sdkMethodCall: (T) -> WrapperResult - ): WrapperResult { - return when (T::class) { + crossinline sdkMethodCall: (T) -> WrapperResult, + ): WrapperResult = + when (T::class) { Map::class -> { sdkMethodCall.invoke(args.toMap() as T) } @@ -307,7 +311,6 @@ class HyperTrackCapacitorPlugin : Plugin() { Failure(IllegalArgumentException(args.toString())) } } - } companion object { private const val EVENT_ERRORS = "errors" diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt index 4616bc4..5dc4db8 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt @@ -31,8 +31,8 @@ typealias Serialized = Map * It receives serialized params. */ internal object HyperTrackSdkWrapper { - fun addGeotag(args: Serialized): WrapperResult { - return deserializeGeotagData(args) + fun addGeotag(args: Serialized): WrapperResult = + deserializeGeotagData(args) .flatMapSuccess { geotag -> // TODO: return proper error if JSON is wrong val geotagMetadata = Json.fromMap(geotag.data)!! @@ -60,18 +60,17 @@ internal object HyperTrackSdkWrapper { ) } else { HyperTrack.addGeotag(geotagMetadata, expectedLocation) - } - .let { - when (it) { - is Result.Failure -> { - serializeLocationErrorFailure(it.failure) - } - - is Result.Success -> { - serializeLocationWithDeviationSuccess(it.success) - } + }.let { + when (it) { + is Result.Failure -> { + serializeLocationErrorFailure(it.failure) + } + + is Result.Success -> { + serializeLocationWithDeviationSuccess(it.success) } } + } } else { if (orderHandle != null || orderStatus != null) { if (orderHandle == null || orderStatus == null) { @@ -84,116 +83,94 @@ internal object HyperTrackSdkWrapper { ) } else { HyperTrack.addGeotag(geotagMetadata) - } - .let { serializeLocationResult(it) } + }.let { serializeLocationResult(it) } }.let { Success(it) } } - } - fun getDeviceId(): WrapperResult { - return Success(serializeDeviceId(HyperTrack.deviceID)) - } + fun getDeviceId(): WrapperResult = Success(serializeDeviceId(HyperTrack.deviceID)) - fun getDynamicPublishableKey(): WrapperResult { - return Success(serializeDynamicPublishableKey(HyperTrack.dynamicPublishableKey)) - } + fun getDynamicPublishableKey(): WrapperResult = Success(serializeDynamicPublishableKey(HyperTrack.dynamicPublishableKey)) - fun getErrors(): WrapperResult> { - return Success(serializeErrors(HyperTrack.errors)) - } + fun getErrors(): WrapperResult> = Success(serializeErrors(HyperTrack.errors)) - fun getIsAvailable(): WrapperResult { - return Success( + fun getIsAvailable(): WrapperResult = + Success( serializeIsAvailable(HyperTrack.isAvailable), ) - } - fun getIsTracking(): WrapperResult { - return Success( + fun getIsTracking(): WrapperResult = + Success( serializeIsTracking(HyperTrack.isTracking), ) - } - fun getLocation(): WrapperResult { - return HyperTrack + fun getLocation(): WrapperResult = + HyperTrack .location .let { when (it) { is Result.Failure -> serializeLocationErrorFailure(it.failure) is Result.Success -> serializeLocationSuccess(it.success) } - } - .let { Success(it) } - } + }.let { Success(it) } - fun getMetadata(): WrapperResult { - return Success( + fun getMetadata(): WrapperResult = + Success( serializeMetadata(HyperTrack.metadata.toMap()), ) - } - fun getName(): WrapperResult { - return Success( + fun getName(): WrapperResult = + Success( serializeName(HyperTrack.name), ) - } - fun getOrders(): WrapperResult { - return Success( + fun getOrders(): WrapperResult = + Success( serializeOrders(HyperTrack.orders.values), ) - } - fun getWorkerHandle(): WrapperResult { - return Success( + fun getWorkerHandle(): WrapperResult = + Success( serializeWorkerHandle(HyperTrack.workerHandle), ) - } - fun setDynamicPublishableKey(args: Serialized): WrapperResult { - return deserializeDynamicPublishableKey(args) + fun setDynamicPublishableKey(args: Serialized): WrapperResult = + deserializeDynamicPublishableKey(args) .mapSuccess { publishableKey -> HyperTrack.dynamicPublishableKey = publishableKey } - } - fun setIsAvailable(args: Serialized): WrapperResult { - return deserializeIsAvailable(args) + fun setIsAvailable(args: Serialized): WrapperResult = + deserializeIsAvailable(args) .mapSuccess { isAvailable -> HyperTrack.isAvailable = isAvailable } - } - fun setIsTracking(args: Serialized): WrapperResult { - return deserializeIsTracking(args) + fun setIsTracking(args: Serialized): WrapperResult = + deserializeIsTracking(args) .mapSuccess { isTracking -> HyperTrack.isTracking = isTracking } - } - fun setMetadata(args: Serialized): WrapperResult { - return deserializeMetadata(args) + fun setMetadata(args: Serialized): WrapperResult = + deserializeMetadata(args) .flatMapSuccess { metadata -> WrapperResult.tryAsResult { // TODO: return proper error if JSON is wrong HyperTrack.metadata = Json.fromMap(metadata)!! } } - } - fun setName(args: Serialized): WrapperResult { - return deserializeName(args) + fun setName(args: Serialized): WrapperResult = + deserializeName(args) .mapSuccess { name -> HyperTrack.name = name } - } - fun setWorkerHandle(args: Serialized): WrapperResult { - return deserializeWorkerHandle(args) + fun setWorkerHandle(args: Serialized): WrapperResult = + deserializeWorkerHandle(args) .mapSuccess { workerHandle -> HyperTrack.workerHandle = workerHandle } - } } diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt index e2c2628..851f67f 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt @@ -9,17 +9,16 @@ import com.hypertrack.sdk.android.Result * to Map or List where T is any JSON-compatible type */ internal object Serialization { - fun deserializeDynamicPublishableKey(args: Serialized): WrapperResult { - return parse(args) { + fun deserializeDynamicPublishableKey(args: Serialized): WrapperResult = + parse(args) { it.assertValue(key = KEY_TYPE, value = TYPE_DYNAMIC_PUBLISHABLE_KEY) it .get(KEY_VALUE) .getOrThrow() } - } - fun deserializeGeotagData(map: Serialized): WrapperResult { - return parse(map) { + fun deserializeGeotagData(map: Serialized): WrapperResult = + parse(map) { val data = it .get(KEY_GEOTAG_DATA) @@ -49,69 +48,61 @@ internal object Serialization { orderStatus = orderStatus, ) } - } - fun deserializeIsAvailable(isAvailable: Serialized): WrapperResult { - return parse(isAvailable) { + fun deserializeIsAvailable(isAvailable: Serialized): WrapperResult = + parse(isAvailable) { it.assertValue(key = KEY_TYPE, value = TYPE_IS_AVAILABLE) it .get(KEY_VALUE) .getOrThrow() } - } - fun deserializeIsTracking(isTracking: Serialized): WrapperResult { - return parse(isTracking) { + fun deserializeIsTracking(isTracking: Serialized): WrapperResult = + parse(isTracking) { it.assertValue(key = KEY_TYPE, value = TYPE_IS_TRACKING) it .get(KEY_VALUE) .getOrThrow() } - } - fun deserializeMetadata(metadata: Serialized): WrapperResult { - return parse(metadata) { + fun deserializeMetadata(metadata: Serialized): WrapperResult = + parse(metadata) { it.assertValue(key = KEY_TYPE, value = TYPE_METADATA) it .get(KEY_VALUE) .getOrThrow() } - } - fun deserializeName(name: Serialized): WrapperResult { - return parse(name) { + fun deserializeName(name: Serialized): WrapperResult = + parse(name) { it.assertValue(key = KEY_TYPE, value = TYPE_NAME) it .get(KEY_VALUE) .getOrThrow() } - } - fun deserializeWorkerHandle(map: Serialized): WrapperResult { - return parse(map) { + fun deserializeWorkerHandle(map: Serialized): WrapperResult = + parse(map) { it.assertValue(key = KEY_TYPE, value = TYPE_WORKER_HANDLE) it .get(KEY_VALUE) .getOrThrow() } - } - fun serializeDeviceId(deviceId: String): Serialized { - return mapOf( + fun serializeDeviceId(deviceId: String): Serialized = + mapOf( KEY_TYPE to TYPE_DEVICE_ID, KEY_VALUE to deviceId, ) - } - fun serializeDynamicPublishableKey(publishableKey: String): Serialized { - return mapOf( + fun serializeDynamicPublishableKey(publishableKey: String): Serialized = + mapOf( KEY_TYPE to TYPE_DYNAMIC_PUBLISHABLE_KEY, KEY_VALUE to publishableKey, ) - } - fun serializeError(error: HyperTrack.Error): Map { - return mapOf( + fun serializeError(error: HyperTrack.Error): Map = + mapOf( KEY_TYPE to TYPE_ERROR, KEY_VALUE to when (error) { @@ -128,30 +119,26 @@ internal object Serialization { HyperTrack.Error.Permissions.Notifications.Denied -> "permissions.notifications.denied" }, ) - } - fun serializeErrors(errors: Set): List> { - return errors.map { + fun serializeErrors(errors: Set): List> = + errors.map { serializeError(it) } - } - fun serializeIsAvailable(isAvailable: Boolean): Serialized { - return mapOf( + fun serializeIsAvailable(isAvailable: Boolean): Serialized = + mapOf( KEY_TYPE to TYPE_IS_AVAILABLE, KEY_VALUE to isAvailable, ) - } - fun serializeIsTracking(isTracking: Boolean): Serialized { - return mapOf( + fun serializeIsTracking(isTracking: Boolean): Serialized = + mapOf( KEY_TYPE to TYPE_IS_TRACKING, KEY_VALUE to isTracking, ) - } - fun serializeLocateResult(locationResult: Result>): Serialized { - return when (locationResult) { + fun serializeLocateResult(locationResult: Result>): Serialized = + when (locationResult) { is Result.Failure -> { serializeFailure(serializeErrors(locationResult.failure)) } @@ -160,10 +147,9 @@ internal object Serialization { serializeLocationSuccess(locationResult.success) } } - } - fun serializeLocationResult(locationResult: Result): Serialized { - return when (locationResult) { + fun serializeLocationResult(locationResult: Result): Serialized = + when (locationResult) { is Result.Failure -> { serializeLocationErrorFailure(locationResult.failure) } @@ -172,40 +158,33 @@ internal object Serialization { serializeLocationSuccess(locationResult.success) } } - } - fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Serialized { - return serializeFailure(serializeLocationError(locationError)) - } + fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Serialized = + serializeFailure(serializeLocationError(locationError)) - fun serializeLocationSuccess(location: HyperTrack.Location): Serialized { - return serializeSuccess(serializeLocation(location)) - } + fun serializeLocationSuccess(location: HyperTrack.Location): Serialized = serializeSuccess(serializeLocation(location)) - fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized { - return serializeSuccess( + fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized = + serializeSuccess( serializeLocationWithDeviation( locationWithDeviation, ), ) - } - fun serializeMetadata(metadata: Serialized): Serialized { - return mapOf( + fun serializeMetadata(metadata: Serialized): Serialized = + mapOf( KEY_TYPE to TYPE_METADATA, KEY_VALUE to metadata, ) - } - fun serializeName(name: String): Serialized { - return mapOf( + fun serializeName(name: String): Serialized = + mapOf( KEY_TYPE to TYPE_NAME, KEY_VALUE to name, ) - } - fun serializeOrders(orders: Collection): Serialized { - return mapOf( + fun serializeOrders(orders: Collection): Serialized = + mapOf( KEY_TYPE to TYPE_ORDERS, KEY_VALUE to orders.mapIndexed { index, order -> @@ -216,17 +195,15 @@ internal object Serialization { ) }, ) - } - fun serializeWorkerHandle(workerHandle: String): Serialized { - return mapOf( + fun serializeWorkerHandle(workerHandle: String): Serialized = + mapOf( KEY_TYPE to TYPE_WORKER_HANDLE, KEY_VALUE to workerHandle, ) - } - private fun deserializeLocation(map: Serialized): WrapperResult { - return parse(map) { + private fun deserializeLocation(map: Serialized): WrapperResult = + parse(map) { it.assertValue(key = KEY_TYPE, value = TYPE_LOCATION) val value = it @@ -247,19 +224,17 @@ internal object Serialization { } }.getOrThrow() } - } - private fun deserializeOrderHandle(map: Serialized): WrapperResult { - return parse(map) { + private fun deserializeOrderHandle(map: Serialized): WrapperResult = + parse(map) { it.assertValue(key = KEY_TYPE, value = TYPE_ORDER_HANDLE) it .get(KEY_VALUE) .getOrThrow() } - } - private fun deserializeOrderStatus(map: Serialized): WrapperResult { - return parse(map) { + private fun deserializeOrderStatus(map: Serialized): WrapperResult = + parse(map) { when (it.get(KEY_TYPE).getOrThrow()) { TYPE_GEOTAG_ORDER_STATUS_CLOCK_IN -> HyperTrack.OrderStatus.ClockIn TYPE_GEOTAG_ORDER_STATUS_CLOCK_OUT -> HyperTrack.OrderStatus.ClockOut @@ -271,10 +246,9 @@ internal object Serialization { else -> throw Error("Unknown order status: $map") } } - } - private fun serializeIsInsideGeofence(isInsideGeofence: Result): Serialized { - return when (isInsideGeofence) { + private fun serializeIsInsideGeofence(isInsideGeofence: Result): Serialized = + when (isInsideGeofence) { is Result.Failure -> { serializeFailure(serializeLocationError(isInsideGeofence.failure)) } @@ -288,10 +262,9 @@ internal object Serialization { ) } } - } - private fun serializeLocation(location: HyperTrack.Location): Serialized { - return mapOf( + private fun serializeLocation(location: HyperTrack.Location): Serialized = + mapOf( KEY_TYPE to TYPE_LOCATION, KEY_VALUE to mapOf( @@ -299,10 +272,9 @@ internal object Serialization { KEY_LONGITUDE to location.longitude, ), ) - } - private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized { - return mapOf( + private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized = + mapOf( KEY_TYPE to TYPE_LOCATION_WITH_DEVIATION, KEY_VALUE to mapOf( @@ -310,31 +282,27 @@ internal object Serialization { KEY_DEVIATION to locationWithDeviation.deviation, ), ) - } - private fun serializeFailure(failure: List): Serialized { - return mapOf( + private fun serializeFailure(failure: List): Serialized = + mapOf( KEY_TYPE to TYPE_RESULT_FAILURE, KEY_VALUE to failure, ) - } - private fun serializeFailure(failure: Serialized): Serialized { - return mapOf( + private fun serializeFailure(failure: Serialized): Serialized = + mapOf( KEY_TYPE to TYPE_RESULT_FAILURE, KEY_VALUE to failure, ) - } - private fun serializeSuccess(success: Serialized): Serialized { - return mapOf( + private fun serializeSuccess(success: Serialized): Serialized = + mapOf( KEY_TYPE to TYPE_RESULT_SUCCESS, KEY_VALUE to success, ) - } - private fun serializeLocationError(locationError: HyperTrack.LocationError): Serialized { - return when (locationError) { + private fun serializeLocationError(locationError: HyperTrack.LocationError): Serialized = + when (locationError) { HyperTrack.LocationError.NotRunning -> { mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_NOT_RUNNING) } @@ -352,7 +320,6 @@ internal object Serialization { ) } } - } fun parse( source: Serialized, @@ -382,8 +349,8 @@ internal object Serialization { private val _exceptions = mutableListOf() val exceptions: List = _exceptions - inline fun get(key: String): WrapperResult { - return try { + inline fun get(key: String): WrapperResult = + try { Success(source[key]!! as T) } catch (e: Exception) { Failure( @@ -393,10 +360,9 @@ internal object Serialization { }, ) } - } - inline fun getOptional(key: String): WrapperResult { - return try { + inline fun getOptional(key: String): WrapperResult = + try { Success(source[key] as T?) } catch (e: Exception) { Failure( @@ -406,7 +372,6 @@ internal object Serialization { }, ) } - } inline fun assertValue( key: String, @@ -422,7 +387,8 @@ internal object Serialization { val source: Any, val exceptions: List, ) : Throwable( - exceptions.joinToString("\n") + exceptions + .joinToString("\n") .let { "Invalid input:\n\n${source}\n\n$it" }, diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/common/WrapperResult.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/common/WrapperResult.kt index cfe8c4e..e72aeee 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/common/WrapperResult.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/common/WrapperResult.kt @@ -1,8 +1,8 @@ package com.hypertrack.sdk.capacitor.common internal sealed class WrapperResult { - fun flatMapSuccess(onSuccess: (SuccessType) -> WrapperResult): WrapperResult { - return when (this) { + fun flatMapSuccess(onSuccess: (SuccessType) -> WrapperResult): WrapperResult = + when (this) { is Success -> { onSuccess.invoke(this.success) } @@ -11,10 +11,9 @@ internal sealed class WrapperResult { Failure(this.failure) } } - } - fun mapSuccess(onSuccess: (SuccessType) -> MappedSuccess): WrapperResult { - return when (this) { + fun mapSuccess(onSuccess: (SuccessType) -> MappedSuccess): WrapperResult = + when (this) { is Success -> { Success(onSuccess.invoke(this.success)) } @@ -23,29 +22,30 @@ internal sealed class WrapperResult { Failure(this.failure) } } - } - fun getOrThrow(): SuccessType { - return when (this) { + fun getOrThrow(): SuccessType = + when (this) { is Success -> this.success is Failure -> throw Exception( "Result unwrapping failed: ${this.failure}", this.failure, ) } - } companion object { - fun tryAsResult(block: () -> SuccessType): WrapperResult { - return try { + fun tryAsResult(block: () -> SuccessType): WrapperResult = + try { Success(block.invoke()) } catch (e: Exception) { Failure(e) } - } } } -internal data class Success(val success: SuccessType) : WrapperResult() +internal data class Success( + val success: SuccessType, +) : WrapperResult() -internal data class Failure(val failure: Throwable) : WrapperResult() +internal data class Failure( + val failure: Throwable, +) : WrapperResult() diff --git a/docs/classes/HyperTrack.html b/docs/classes/HyperTrack.html index 9f55bc1..1e77bea 100644 --- a/docs/classes/HyperTrack.html +++ b/docs/classes/HyperTrack.html @@ -1,4 +1,4 @@ -HyperTrack | HyperTrack Ionic Capacitor SDK API - v3.6.2

Constructors

constructor +HyperTrack | HyperTrack Ionic Capacitor SDK API - v3.6.3

Constructors

Properties

Methods

addGeotag getDeviceId @@ -98,4 +98,4 @@

Parameters

  • listener: ((orders) => void)
      • (orders): void
      • Parameters

        • orders: Map<string, Order>

        Returns void

Returns Subscription

Subscription

Example

const subscription = HyperTrack.subscribeToOrders(orders => {
...
})

// later, to stop listening
subscription.remove()
-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/enums/HyperTrackError.html b/docs/enums/HyperTrackError.html index 39ceabd..3a27b93 100644 --- a/docs/enums/HyperTrackError.html +++ b/docs/enums/HyperTrackError.html @@ -1,4 +1,4 @@ -HyperTrackError | HyperTrack Ionic Capacitor SDK API - v3.6.2

Enumeration Members

blockedFromRunning +HyperTrackError | HyperTrack Ionic Capacitor SDK API - v3.6.3

Enumeration Members

permissionsLocationRestricted: "permissions.location.restricted"

[iOS only] The app is not authorized to use location services.

permissionsNotificationsDenied: "permissions.notifications.denied"

[Android only] The user denied notification permissions needed to display a persistent notification needed for foreground location tracking.

-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 01814f7..6a72d15 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,4 +1,4 @@ -HyperTrack Ionic Capacitor SDK API - v3.6.2

HyperTrack Ionic Capacitor SDK API - v3.6.2

References

default +HyperTrack Ionic Capacitor SDK API - v3.6.3

HyperTrack Ionic Capacitor SDK API - v3.6.3

References

Enumerations

Classes

Interfaces

References

Renames and re-exports HyperTrack
\ No newline at end of file +

References

Renames and re-exports HyperTrack
\ No newline at end of file diff --git a/docs/interfaces/Subscription.html b/docs/interfaces/Subscription.html index 3cbc018..89e7258 100644 --- a/docs/interfaces/Subscription.html +++ b/docs/interfaces/Subscription.html @@ -1,2 +1,2 @@ -Subscription | HyperTrack Ionic Capacitor SDK API - v3.6.2
interface Subscription {
    remove: (() => Promise<Object>);
}

Properties

Properties

remove: (() => Promise<Object>)

Type declaration

    • (): Promise<Object>
    • Returns Promise<Object>

\ No newline at end of file +Subscription | HyperTrack Ionic Capacitor SDK API - v3.6.3
interface Subscription {
    remove: (() => Promise<Object>);
}

Properties

Properties

remove: (() => Promise<Object>)

Type declaration

    • (): Promise<Object>
    • Returns Promise<Object>

\ No newline at end of file diff --git a/docs/types/Errors.html b/docs/types/Errors.html index b45f6ec..157e7a0 100644 --- a/docs/types/Errors.html +++ b/docs/types/Errors.html @@ -1 +1 @@ -Errors | HyperTrack Ionic Capacitor SDK API - v3.6.2
Errors: {
    type: "errors";
    value: HyperTrackError[];
}

Type declaration

\ No newline at end of file +Errors | HyperTrack Ionic Capacitor SDK API - v3.6.3
Errors: {
    type: "errors";
    value: HyperTrackError[];
}

Type declaration

\ No newline at end of file diff --git a/docs/types/Failure.html b/docs/types/Failure.html index ee90dd2..f51841f 100644 --- a/docs/types/Failure.html +++ b/docs/types/Failure.html @@ -1 +1 @@ -Failure | HyperTrack Ionic Capacitor SDK API - v3.6.2
Failure<F>: {
    type: "failure";
    value: F;
}

Type Parameters

  • F

Type declaration

  • type: "failure"
  • value: F
\ No newline at end of file +Failure | HyperTrack Ionic Capacitor SDK API - v3.6.3
Failure<F>: {
    type: "failure";
    value: F;
}

Type Parameters

  • F

Type declaration

  • type: "failure"
  • value: F
\ No newline at end of file diff --git a/docs/types/Location.html b/docs/types/Location.html index 2db1679..75ba6fe 100644 --- a/docs/types/Location.html +++ b/docs/types/Location.html @@ -1 +1 @@ -Location | HyperTrack Ionic Capacitor SDK API - v3.6.2
Location: {
    latitude: number;
    longitude: number;
}

Type declaration

  • latitude: number
  • longitude: number
\ No newline at end of file +Location | HyperTrack Ionic Capacitor SDK API - v3.6.3
Location: {
    latitude: number;
    longitude: number;
}

Type declaration

  • latitude: number
  • longitude: number
\ No newline at end of file diff --git a/docs/types/LocationError.html b/docs/types/LocationError.html index f71aa5f..a4e9e6e 100644 --- a/docs/types/LocationError.html +++ b/docs/types/LocationError.html @@ -1 +1 @@ -LocationError | HyperTrack Ionic Capacitor SDK API - v3.6.2
\ No newline at end of file +LocationError | HyperTrack Ionic Capacitor SDK API - v3.6.3
\ No newline at end of file diff --git a/docs/types/LocationWithDeviation.html b/docs/types/LocationWithDeviation.html index 6dc65d5..12afda2 100644 --- a/docs/types/LocationWithDeviation.html +++ b/docs/types/LocationWithDeviation.html @@ -1 +1 @@ -LocationWithDeviation | HyperTrack Ionic Capacitor SDK API - v3.6.2
LocationWithDeviation: {
    location: Location;
    deviation: number;
}

Type declaration

\ No newline at end of file +LocationWithDeviation | HyperTrack Ionic Capacitor SDK API - v3.6.3
LocationWithDeviation: {
    location: Location;
    deviation: number;
}

Type declaration

\ No newline at end of file diff --git a/docs/types/NotRunning.html b/docs/types/NotRunning.html index 799b81a..848e64c 100644 --- a/docs/types/NotRunning.html +++ b/docs/types/NotRunning.html @@ -1 +1 @@ -NotRunning | HyperTrack Ionic Capacitor SDK API - v3.6.2
NotRunning: {
    type: "notRunning";
}

Type declaration

  • type: "notRunning"
\ No newline at end of file +NotRunning | HyperTrack Ionic Capacitor SDK API - v3.6.3
NotRunning: {
    type: "notRunning";
}

Type declaration

  • type: "notRunning"
\ No newline at end of file diff --git a/docs/types/Order.html b/docs/types/Order.html index cfd2ed1..3a7f305 100644 --- a/docs/types/Order.html +++ b/docs/types/Order.html @@ -1 +1 @@ -Order | HyperTrack Ionic Capacitor SDK API - v3.6.2
Order: {
    orderHandle: string;
    isInsideGeofence: Result<boolean, LocationError>;
}

Type declaration

\ No newline at end of file +Order | HyperTrack Ionic Capacitor SDK API - v3.6.3
Order: {
    orderHandle: string;
    isInsideGeofence: Result<boolean, LocationError>;
}

Type declaration

\ No newline at end of file diff --git a/docs/types/OrderStatus.html b/docs/types/OrderStatus.html index 10f577a..1231b9b 100644 --- a/docs/types/OrderStatus.html +++ b/docs/types/OrderStatus.html @@ -1 +1 @@ -OrderStatus | HyperTrack Ionic Capacitor SDK API - v3.6.2
OrderStatus: {
    type: "orderStatusClockIn";
} | {
    type: "orderStatusClockOut";
} | {
    type: "orderStatusCustom";
    value: string;
}

Type declaration

  • type: "orderStatusClockIn"

Type declaration

  • type: "orderStatusClockOut"

Type declaration

  • type: "orderStatusCustom"
  • value: string
\ No newline at end of file +OrderStatus | HyperTrack Ionic Capacitor SDK API - v3.6.3
OrderStatus: {
    type: "orderStatusClockIn";
} | {
    type: "orderStatusClockOut";
} | {
    type: "orderStatusCustom";
    value: string;
}

Type declaration

  • type: "orderStatusClockIn"

Type declaration

  • type: "orderStatusClockOut"

Type declaration

  • type: "orderStatusCustom"
  • value: string
\ No newline at end of file diff --git a/docs/types/Result.html b/docs/types/Result.html index 6e59962..3d2d536 100644 --- a/docs/types/Result.html +++ b/docs/types/Result.html @@ -1 +1 @@ -Result | HyperTrack Ionic Capacitor SDK API - v3.6.2
Result<S, F>: Success<S> | Failure<F>

Type Parameters

  • S
  • F
\ No newline at end of file +Result | HyperTrack Ionic Capacitor SDK API - v3.6.3
Result<S, F>: Success<S> | Failure<F>

Type Parameters

  • S
  • F
\ No newline at end of file diff --git a/docs/types/Starting.html b/docs/types/Starting.html index 0e9bdbd..8ce9ba0 100644 --- a/docs/types/Starting.html +++ b/docs/types/Starting.html @@ -1 +1 @@ -Starting | HyperTrack Ionic Capacitor SDK API - v3.6.2
Starting: {
    type: "starting";
}

Type declaration

  • type: "starting"
\ No newline at end of file +Starting | HyperTrack Ionic Capacitor SDK API - v3.6.3
Starting: {
    type: "starting";
}

Type declaration

  • type: "starting"
\ No newline at end of file diff --git a/docs/types/Success.html b/docs/types/Success.html index fa413c8..47724eb 100644 --- a/docs/types/Success.html +++ b/docs/types/Success.html @@ -1 +1 @@ -Success | HyperTrack Ionic Capacitor SDK API - v3.6.2
Success<S>: {
    type: "success";
    value: S;
}

Type Parameters

  • S

Type declaration

  • type: "success"
  • value: S
\ No newline at end of file +Success | HyperTrack Ionic Capacitor SDK API - v3.6.3
Success<S>: {
    type: "success";
    value: S;
}

Type Parameters

  • S

Type declaration

  • type: "success"
  • value: S
\ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 99fa0a9..3823458 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hypertrack-sdk-ionic-capacitor", - "version": "3.6.2", + "version": "3.6.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hypertrack-sdk-ionic-capacitor", - "version": "3.6.2", + "version": "3.6.3", "license": "MIT", "devDependencies": { "@capacitor/android": "^5.6.0", diff --git a/package.json b/package.json index eff86d5..411a4e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hypertrack-sdk-ionic-capacitor", - "version": "3.6.2", + "version": "3.6.3", "description": "Capacitor plugin for HyperTrack generation SDKs", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js",