react-native-rook-sdk 4.0.0 → 5.0.0-beta.1
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/LICENSE +1 -1
- package/README.md +35 -3
- package/RNRookSdk.podspec +22 -0
- package/android/build.gradle +21 -40
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/rooksdk/RookSdkModule.kt +1709 -117
- package/android/src/main/java/com/rooksdk/RookSdkPackage.kt +26 -42
- package/android/src/main/java/com/rooksdk/broadcasts/AndroidPermissionsReceiverTransmitter.kt +34 -37
- package/android/src/main/java/com/rooksdk/broadcasts/HealthConnectPermissionsReceiverTransmitter.kt +8 -14
- package/android/src/main/java/com/rooksdk/broadcasts/SamsungHealthPermissionsReceiverTransmitter.kt +8 -16
- package/android/src/main/java/com/rooksdk/utils/{DatasourcesUtils.kt → DatasourceUtils.kt} +10 -9
- package/android/src/main/java/com/rooksdk/utils/{PermissionConversion.kt → PermissionConvertions.kt} +1 -1
- package/android/src/main/java/com/rooksdk/utils/ReadableToWritable.kt +0 -1
- package/android/src/main/java/com/rooksdk/utils/RookGsonBuilder.kt +3 -0
- package/android/src/main/java/com/rooksdk/utils/SamsungAvailability.kt +1 -0
- package/android/src/main/java/com/rooksdk/utils/serializers/InstantSerializer.kt +0 -1
- package/android/src/main/java/com/rooksdk/utils/serializers/ZoneDateTimeSerializer.kt +18 -0
- package/ios/DateHelper.swift +4 -4
- package/ios/Encodable.swift +25 -0
- package/ios/EncodableDataSource.swift +2 -3
- package/ios/EncodableDataSourceAuthorizer.swift +2 -3
- package/ios/EncodableSDKState.swift +3 -2
- package/ios/{EncodableHeartRate.swift → HearRateMapper.swift} +3 -3
- package/ios/NutritionMapper.swift +3 -3
- package/ios/RookBackground.swift +5 -8
- package/ios/RookConfiguration.swift +33 -30
- package/ios/{RookLocalData.swift → RookData.swift} +76 -69
- package/ios/RookEntry.swift +62 -0
- package/ios/RookPermissions.swift +36 -40
- package/ios/RookSdk-Bridging-Header.h +12 -0
- package/ios/RookSdk.h +3 -3
- package/ios/RookSdk.mm +390 -134
- package/ios/RookSources.swift +60 -54
- package/ios/RookSync.swift +48 -78
- package/ios/boost-boost_privacy-Bridging-Header.h +4 -0
- package/lib/{commonjs/types/AppleHealthPermissions.js → module/NativeRookSdk.js} +50 -6
- package/lib/module/NativeRookSdk.js.map +1 -0
- package/lib/module/context/RookSyncGateContext.js +2 -0
- package/lib/module/context/RookSyncGateContext.js.map +1 -1
- package/lib/module/context/RookSyncGateProvider.js +17 -18
- package/lib/module/context/RookSyncGateProvider.js.map +1 -1
- package/lib/module/context/RookSyncGateReducer.js +2 -0
- package/lib/module/context/RookSyncGateReducer.js.map +1 -1
- package/lib/module/context/RookSyncGateTypes.js +2 -0
- package/lib/module/hooks/useRookAPISources.js +10 -16
- package/lib/module/hooks/useRookAPISources.js.map +1 -1
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js +11 -12
- package/lib/module/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
- package/lib/module/hooks/useRookAppleHealth.js +9 -10
- package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
- package/lib/module/hooks/useRookConfiguration.js +17 -22
- package/lib/module/hooks/useRookConfiguration.js.map +1 -1
- package/lib/module/hooks/useRookData.js +33 -38
- package/lib/module/hooks/useRookData.js.map +1 -1
- package/lib/module/hooks/useRookHealthConnect.js +9 -10
- package/lib/module/hooks/useRookHealthConnect.js.map +1 -1
- package/lib/module/hooks/useRookPermissions.js +34 -45
- package/lib/module/hooks/useRookPermissions.js.map +1 -1
- package/lib/module/hooks/useRookSamsungHealth.js +8 -20
- package/lib/module/hooks/useRookSamsungHealth.js.map +1 -1
- package/lib/module/hooks/useRookSync.js +23 -32
- package/lib/module/hooks/useRookSync.js.map +1 -1
- package/lib/module/hooks/useRookVariables.js +26 -29
- package/lib/module/hooks/useRookVariables.js.map +1 -1
- package/lib/module/index.js +18 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/components/RookStateManager.js +31 -0
- package/lib/module/modules/components/RookStateManager.js.map +1 -0
- package/lib/module/modules/hook/useRookAutoSync.js +24 -36
- package/lib/module/modules/hook/useRookAutoSync.js.map +1 -1
- package/lib/module/modules/hook/useRookEmitter.js +61 -0
- package/lib/module/modules/hook/useRookEmitter.js.map +1 -0
- package/lib/module/modules/types/sendMessageBroadcast.js +1 -1
- package/lib/module/modules/utils/errors.js +2 -0
- package/lib/module/modules/utils/errors.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types/ActivityEvent.js +2 -0
- package/lib/module/types/AppleHealthNutritionEvent.js +2 -0
- package/lib/module/types/AppleHealthNutritionEvent.js.map +1 -1
- package/lib/module/types/AppleHealthPermissions.js +2 -0
- package/lib/module/types/AppleHealthPermissions.js.map +1 -1
- package/lib/module/types/AuthorizedSources.js +2 -0
- package/lib/module/types/BodySummary.js +2 -0
- package/lib/module/types/DataSource.js +2 -0
- package/lib/module/types/DataSource.js.map +1 -1
- package/lib/module/types/HCMealData.js +3 -1
- package/lib/module/types/HCMealData.js.map +1 -1
- package/lib/module/types/HeartRateEvent.js +1 -1
- package/lib/module/types/PermissionsType.js +1 -1
- package/lib/module/types/PhysicalSummary.js +2 -0
- package/lib/module/types/Rook.js +2 -0
- package/lib/{commonjs/types/BodySummary.js.map → module/types/Rook.js.map} +1 -1
- package/lib/module/types/SDKSources.js +2 -0
- package/lib/module/types/SDKSources.js.map +1 -1
- package/lib/module/types/SamsungHealthPermissions.js +3 -0
- package/lib/module/types/SamsungHealthPermissions.js.map +1 -1
- package/lib/module/types/SleepSummary.js +2 -0
- package/lib/module/types/SummaryTypes.js +1 -1
- package/lib/module/types/SyncTypes.js +2 -0
- package/lib/module/types/SyncTypes.js.map +1 -1
- package/lib/module/types/WriteNutrition.js +2 -0
- package/lib/module/types/WriteNutrition.js.map +1 -1
- package/lib/module/utils/isModuleReady.js +2 -0
- package/lib/module/utils/isModuleReady.js.map +1 -1
- package/lib/module/utils/isRunningOnAndroid.js +2 -0
- package/lib/module/utils/isRunningOnAndroid.js.map +1 -1
- package/lib/module/utils/isRunningOniOS.js +2 -0
- package/lib/module/utils/isRunningOniOS.js.map +1 -1
- package/lib/module/utils/isValidDate.js +2 -0
- package/lib/module/utils/isValidDate.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeRookSdk.d.ts +705 -0
- package/lib/typescript/src/NativeRookSdk.d.ts.map +1 -0
- package/lib/typescript/src/context/RookSyncGateContext.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateProvider.d.ts.map +1 -1
- package/lib/typescript/src/context/RookSyncGateReducer.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAPISources.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookAppleHealth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts +1 -1
- package/lib/typescript/src/hooks/useRookConfiguration.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookData.d.ts +1 -1
- package/lib/typescript/src/hooks/useRookData.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookHealthConnect.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookPermissions.d.ts +1 -1
- package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts +0 -6
- package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookSync.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useRookVariables.d.ts +1 -1
- package/lib/typescript/src/hooks/useRookVariables.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +18 -8
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/modules/components/RookStateManager.d.ts +10 -0
- package/lib/typescript/src/modules/components/RookStateManager.d.ts.map +1 -0
- package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts.map +1 -1
- package/lib/typescript/src/modules/hook/useRookEmitter.d.ts +4 -0
- package/lib/typescript/src/modules/hook/useRookEmitter.d.ts.map +1 -0
- package/lib/typescript/src/types/AppleHealthNutritionEvent.d.ts.map +1 -1
- package/lib/typescript/src/types/AuthorizedSources.d.ts +11 -0
- package/lib/typescript/src/types/AuthorizedSources.d.ts.map +1 -1
- package/lib/typescript/src/types/HCMealData.d.ts.map +1 -1
- package/lib/typescript/src/types/HeartRateEvent.d.ts +2 -2
- package/lib/typescript/src/types/HeartRateEvent.d.ts.map +1 -1
- package/lib/typescript/src/types/Rook.d.ts +9 -0
- package/lib/typescript/src/types/Rook.d.ts.map +1 -0
- package/lib/typescript/src/types/SamsungHealthPermissions.d.ts +1 -0
- package/lib/typescript/src/types/SamsungHealthPermissions.d.ts.map +1 -1
- package/lib/typescript/src/types/SyncTypes.d.ts +5 -1
- package/lib/typescript/src/types/SyncTypes.d.ts.map +1 -1
- package/lib/typescript/src/utils/isModuleReady.d.ts.map +1 -1
- package/lib/typescript/src/utils/isValidDate.d.ts.map +1 -1
- package/package.json +94 -98
- package/src/NativeRookSdk.ts +839 -0
- package/{lib/commonjs/context/RookSyncGateContext.js → src/context/RookSyncGateContext.ts} +10 -13
- package/src/context/RookSyncGateProvider.tsx +82 -0
- package/{lib/commonjs/context/RookSyncGateReducer.js → src/context/RookSyncGateReducer.ts} +14 -41
- package/src/context/RookSyncGateTypes.ts +40 -0
- package/{lib/commonjs/hooks/useRookAPISources.js → src/hooks/useRookAPISources.ts} +40 -36
- package/src/hooks/useRookAndroidBackgroundSteps.ts +81 -0
- package/src/hooks/useRookAppleHealth.ts +55 -0
- package/src/hooks/useRookConfiguration.ts +106 -0
- package/src/hooks/useRookData.ts +133 -0
- package/src/hooks/useRookHealthConnect.ts +59 -0
- package/src/hooks/useRookPermissions.ts +240 -0
- package/src/hooks/useRookSamsungHealth.ts +37 -0
- package/src/hooks/useRookSync.ts +157 -0
- package/src/hooks/useRookVariables.ts +98 -0
- package/src/index.tsx +29 -0
- package/src/modules/components/RookStateManager.tsx +41 -0
- package/{lib/commonjs/modules/hook/useRookAutoSync.js → src/modules/hook/useRookAutoSync.ts} +141 -95
- package/src/modules/hook/useRookEmitter.ts +94 -0
- package/src/modules/types/sendMessageBroadcast.ts +5 -0
- package/src/modules/utils/errors.ts +9 -0
- package/src/types/ActivityEvent.ts +159 -0
- package/src/types/AppleHealthNutritionEvent.ts +142 -0
- package/src/types/AppleHealthPermissions.ts +49 -0
- package/src/types/AuthorizedSources.ts +33 -0
- package/src/types/BodySummary.ts +116 -0
- package/src/types/DataSource.ts +16 -0
- package/{lib/commonjs/types/HCMealData.js → src/types/HCMealData.ts} +60 -11
- package/src/types/HeartRateEvent.ts +26 -0
- package/src/types/PermissionsType.ts +9 -0
- package/src/types/PhysicalSummary.ts +84 -0
- package/src/types/Rook.ts +8 -0
- package/src/types/SDKSources.ts +5 -0
- package/src/types/SamsungHealthPermissions.ts +16 -0
- package/src/types/SleepSummary.ts +66 -0
- package/src/types/SummaryTypes.ts +70 -0
- package/src/types/SyncTypes.ts +63 -0
- package/src/types/WriteNutrition.ts +66 -0
- package/{lib/commonjs/utils/isModuleReady.js → src/utils/isModuleReady.ts} +4 -10
- package/src/utils/isRunningOnAndroid.ts +10 -0
- package/src/utils/isRunningOniOS.ts +10 -0
- package/{lib/commonjs/utils/isValidDate.js → src/utils/isValidDate.ts} +12 -14
- package/android/src/main/AndroidManifestNew.xml +0 -36
- package/android/src/main/java/com/rooksdk/modules/RookBackgroundSyncModule.kt +0 -99
- package/android/src/main/java/com/rooksdk/modules/RookConfigurationModule.kt +0 -182
- package/android/src/main/java/com/rooksdk/modules/RookLocalData.kt +0 -301
- package/android/src/main/java/com/rooksdk/modules/RookPermissionsModule.kt +0 -359
- package/android/src/main/java/com/rooksdk/modules/RookSourcesModule.kt +0 -102
- package/android/src/main/java/com/rooksdk/modules/RookStepsModule.kt +0 -119
- package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +0 -551
- package/android/src/main/res/drawable/ic_health_connect.xml +0 -19
- package/android/src/main/res/values/themes.xml +0 -3
- package/ios/EncodableRookDataSource.swift +0 -36
- package/ios/EncodableStatusDataSources.swift +0 -47
- package/ios/RookBackgroundModule.h +0 -5
- package/ios/RookBackgroundModule.mm +0 -15
- package/ios/RookConfigurationModule.h +0 -5
- package/ios/RookConfigurationModule.mm +0 -22
- package/ios/RookExternalModule.h +0 -5
- package/ios/RookExternalModule.m +0 -31
- package/ios/RookPermissionsModule.h +0 -5
- package/ios/RookPermissionsModule.mm +0 -20
- package/ios/RookSourcesModule.h +0 -5
- package/ios/RookSourcesModule.mm +0 -18
- package/ios/RookSync.h +0 -5
- package/ios/RookSync.m +0 -35
- package/ios/SwiftTest.swift +0 -18
- package/ios/react-native-rook-sdk-Bridging-Header.h +0 -12
- package/lib/commonjs/context/RookSyncGateContext.js.map +0 -1
- package/lib/commonjs/context/RookSyncGateProvider.js +0 -108
- package/lib/commonjs/context/RookSyncGateProvider.js.map +0 -1
- package/lib/commonjs/context/RookSyncGateReducer.js.map +0 -1
- package/lib/commonjs/context/RookSyncGateTypes.js +0 -6
- package/lib/commonjs/context/RookSyncGateTypes.js.map +0 -1
- package/lib/commonjs/context/index.js +0 -14
- package/lib/commonjs/context/index.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -76
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/useRookAPISources.js.map +0 -1
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +0 -88
- package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +0 -1
- package/lib/commonjs/hooks/useRookAppleHealth.js +0 -63
- package/lib/commonjs/hooks/useRookAppleHealth.js.map +0 -1
- package/lib/commonjs/hooks/useRookConfiguration.js +0 -113
- package/lib/commonjs/hooks/useRookConfiguration.js.map +0 -1
- package/lib/commonjs/hooks/useRookData.js +0 -116
- package/lib/commonjs/hooks/useRookData.js.map +0 -1
- package/lib/commonjs/hooks/useRookHealthConnect.js +0 -70
- package/lib/commonjs/hooks/useRookHealthConnect.js.map +0 -1
- package/lib/commonjs/hooks/useRookPermissions.js +0 -211
- package/lib/commonjs/hooks/useRookPermissions.js.map +0 -1
- package/lib/commonjs/hooks/useRookSamsungHealth.js +0 -54
- package/lib/commonjs/hooks/useRookSamsungHealth.js.map +0 -1
- package/lib/commonjs/hooks/useRookSync.js +0 -148
- package/lib/commonjs/hooks/useRookSync.js.map +0 -1
- package/lib/commonjs/hooks/useRookVariables.js +0 -93
- package/lib/commonjs/hooks/useRookVariables.js.map +0 -1
- package/lib/commonjs/index.js +0 -121
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/modules/hook/useRookAutoSync.js.map +0 -1
- package/lib/commonjs/modules/types/sendMessageBroadcast.js +0 -2
- package/lib/commonjs/modules/types/sendMessageBroadcast.js.map +0 -1
- package/lib/commonjs/modules/utils/errors.js +0 -12
- package/lib/commonjs/modules/utils/errors.js.map +0 -1
- package/lib/commonjs/types/ActivityEvent.js +0 -6
- package/lib/commonjs/types/ActivityEvent.js.map +0 -1
- package/lib/commonjs/types/AppleHealthNutritionEvent.js +0 -77
- package/lib/commonjs/types/AppleHealthNutritionEvent.js.map +0 -1
- package/lib/commonjs/types/AppleHealthPermissions.js.map +0 -1
- package/lib/commonjs/types/AuthorizedSources.js +0 -6
- package/lib/commonjs/types/AuthorizedSources.js.map +0 -1
- package/lib/commonjs/types/BodySummary.js +0 -6
- package/lib/commonjs/types/DataSource.js +0 -16
- package/lib/commonjs/types/DataSource.js.map +0 -1
- package/lib/commonjs/types/DiagnosticState.js +0 -2
- package/lib/commonjs/types/DiagnosticState.js.map +0 -1
- package/lib/commonjs/types/HCMealData.js.map +0 -1
- package/lib/commonjs/types/HeartRateEvent.js +0 -2
- package/lib/commonjs/types/HeartRateEvent.js.map +0 -1
- package/lib/commonjs/types/PermissionsType.js +0 -2
- package/lib/commonjs/types/PermissionsType.js.map +0 -1
- package/lib/commonjs/types/PhysicalSummary.js +0 -6
- package/lib/commonjs/types/PhysicalSummary.js.map +0 -1
- package/lib/commonjs/types/SDKSources.js +0 -13
- package/lib/commonjs/types/SDKSources.js.map +0 -1
- package/lib/commonjs/types/SamsungHealthPermissions.js +0 -23
- package/lib/commonjs/types/SamsungHealthPermissions.js.map +0 -1
- package/lib/commonjs/types/SleepSummary.js +0 -6
- package/lib/commonjs/types/SleepSummary.js.map +0 -1
- package/lib/commonjs/types/SummaryTypes.js +0 -2
- package/lib/commonjs/types/SummaryTypes.js.map +0 -1
- package/lib/commonjs/types/SyncTypes.js +0 -33
- package/lib/commonjs/types/SyncTypes.js.map +0 -1
- package/lib/commonjs/types/WriteNutrition.js +0 -18
- package/lib/commonjs/types/WriteNutrition.js.map +0 -1
- package/lib/commonjs/utils/getNativeModule.js +0 -29
- package/lib/commonjs/utils/getNativeModule.js.map +0 -1
- package/lib/commonjs/utils/getRookModule.js +0 -28
- package/lib/commonjs/utils/getRookModule.js.map +0 -1
- package/lib/commonjs/utils/isModuleReady.js.map +0 -1
- package/lib/commonjs/utils/isRunningOnAndroid.js +0 -15
- package/lib/commonjs/utils/isRunningOnAndroid.js.map +0 -1
- package/lib/commonjs/utils/isRunningOniOS.js +0 -15
- package/lib/commonjs/utils/isRunningOniOS.js.map +0 -1
- package/lib/commonjs/utils/isValidDate.js.map +0 -1
- package/lib/commonjs/utils/nativeModules.js +0 -29
- package/lib/commonjs/utils/nativeModules.js.map +0 -1
- package/lib/commonjs/utils/packageInfo.js +0 -13
- package/lib/commonjs/utils/packageInfo.js.map +0 -1
- package/lib/module/context/index.js +0 -2
- package/lib/module/context/index.js.map +0 -1
- package/lib/module/hooks/index.js +0 -11
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/types/DiagnosticState.js +0 -2
- package/lib/module/types/DiagnosticState.js.map +0 -1
- package/lib/module/utils/getNativeModule.js +0 -23
- package/lib/module/utils/getNativeModule.js.map +0 -1
- package/lib/module/utils/getRookModule.js +0 -22
- package/lib/module/utils/getRookModule.js.map +0 -1
- package/lib/module/utils/nativeModules.js +0 -23
- package/lib/module/utils/nativeModules.js.map +0 -1
- package/lib/module/utils/packageInfo.js +0 -7
- package/lib/module/utils/packageInfo.js.map +0 -1
- package/lib/typescript/src/context/index.d.ts +0 -2
- package/lib/typescript/src/context/index.d.ts.map +0 -1
- package/lib/typescript/src/hooks/index.d.ts +0 -11
- package/lib/typescript/src/hooks/index.d.ts.map +0 -1
- package/lib/typescript/src/types/DiagnosticState.d.ts +0 -13
- package/lib/typescript/src/types/DiagnosticState.d.ts.map +0 -1
- package/lib/typescript/src/utils/getNativeModule.d.ts +0 -10
- package/lib/typescript/src/utils/getNativeModule.d.ts.map +0 -1
- package/lib/typescript/src/utils/getRookModule.d.ts +0 -9
- package/lib/typescript/src/utils/getRookModule.d.ts.map +0 -1
- package/lib/typescript/src/utils/nativeModules.d.ts +0 -24
- package/lib/typescript/src/utils/nativeModules.d.ts.map +0 -1
- package/lib/typescript/src/utils/packageInfo.d.ts +0 -6
- package/lib/typescript/src/utils/packageInfo.d.ts.map +0 -1
- package/react-native-rook-sdk.podspec +0 -45
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
package com.rooksdk.modules
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.Arguments
|
|
4
|
-
import com.facebook.react.bridge.Callback
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
8
|
-
import com.facebook.react.bridge.ReactMethod
|
|
9
|
-
import com.google.gson.Gson
|
|
10
|
-
import com.google.gson.GsonBuilder
|
|
11
|
-
import com.rookmotion.rook.sdk.RookSyncManager
|
|
12
|
-
import com.rookmotion.rook.sdk.domain.enums.SyncStatus
|
|
13
|
-
import com.rookmotion.rook.sdk.domain.exception.HCException
|
|
14
|
-
import com.rookmotion.rook.sdk.domain.exception.HCRecordsNotFoundException
|
|
15
|
-
import com.rookmotion.rook.sdk.domain.model.HCHeartRate
|
|
16
|
-
import com.rookmotion.rook.sdk.domain.model.SyncStatusWithData
|
|
17
|
-
import com.rooksdk.utils.RookDateTime
|
|
18
|
-
import com.rooksdk.utils.SamsungAvailability
|
|
19
|
-
import com.rooksdk.utils.StringToSyncType
|
|
20
|
-
import com.rooksdk.utils.serializers.InstantSerializer
|
|
21
|
-
import com.rooksdk.utils.serializers.LocalDateSerializer
|
|
22
|
-
import io.tryrook.sdk.samsung.RookSamsung
|
|
23
|
-
import io.tryrook.sdk.samsung.domain.enums.SHSyncStatus
|
|
24
|
-
import io.tryrook.sdk.samsung.domain.exception.SHException
|
|
25
|
-
import io.tryrook.sdk.samsung.domain.model.SHSyncStatusWithData
|
|
26
|
-
import kotlinx.coroutines.CoroutineScope
|
|
27
|
-
import kotlinx.coroutines.Dispatchers
|
|
28
|
-
import kotlinx.coroutines.SupervisorJob
|
|
29
|
-
import kotlinx.coroutines.launch
|
|
30
|
-
import java.time.Instant
|
|
31
|
-
import java.time.LocalDate
|
|
32
|
-
|
|
33
|
-
class RookSyncModule(
|
|
34
|
-
reactContext: ReactApplicationContext,
|
|
35
|
-
private val rookSamsung: RookSamsung
|
|
36
|
-
): ReactContextBaseJavaModule(reactContext) {
|
|
37
|
-
|
|
38
|
-
private val rookSync by lazy {
|
|
39
|
-
RookSyncManager(reactContext)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private val scope: CoroutineScope by lazy {
|
|
43
|
-
CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private val gsonBuilder: Gson by lazy {
|
|
47
|
-
GsonBuilder()
|
|
48
|
-
.registerTypeAdapter(Instant::class.java, InstantSerializer())
|
|
49
|
-
.registerTypeAdapter(LocalDate::class.java, LocalDateSerializer())
|
|
50
|
-
.create()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@ReactMethod
|
|
54
|
-
fun enableSamsungSync(promise: Promise) {
|
|
55
|
-
scope.launch {
|
|
56
|
-
rookSamsung.schedule(true)
|
|
57
|
-
promise.resolve(true)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@ReactMethod
|
|
62
|
-
fun isSamsungSyncEnabled(promise: Promise) {
|
|
63
|
-
scope.launch {
|
|
64
|
-
rookSamsung.isScheduled().fold(
|
|
65
|
-
{
|
|
66
|
-
promise.resolve(it)
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
if (it is SHException) {
|
|
70
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
71
|
-
} else {
|
|
72
|
-
promise.reject("1001", it.message, it)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@ReactMethod
|
|
80
|
-
fun disableSamsungSync(promise: Promise) {
|
|
81
|
-
scope.launch {
|
|
82
|
-
rookSamsung.cancel()
|
|
83
|
-
promise.resolve(true)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@ReactMethod
|
|
88
|
-
fun syncTodaySamsungHealthStepsCount(promise: Promise) {
|
|
89
|
-
scope.launch {
|
|
90
|
-
rookSamsung.getTodayStepsCount().fold({
|
|
91
|
-
when (it) {
|
|
92
|
-
SHSyncStatusWithData.RecordsNotFound -> {
|
|
93
|
-
promise.reject("SamsungStepsCount", "Records Not Found")
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
is SHSyncStatusWithData.Synced -> {
|
|
97
|
-
val steps = it.data
|
|
98
|
-
promise.resolve(steps)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
if (it is SHException) {
|
|
103
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
104
|
-
} else {
|
|
105
|
-
promise.reject("1001", it.message, it)
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Synchronizes the step count for the current day from Health Connect.
|
|
113
|
-
* This method queries the Health Connect platform via the Rook SDK to retrieve
|
|
114
|
-
* the step count for today. If no records are found, it rejects the promise with an error message.
|
|
115
|
-
*
|
|
116
|
-
* @param promise A promise object that resolves with the step count if data is found,
|
|
117
|
-
* or rejects with an error if records are not found or synchronization fails.
|
|
118
|
-
*/
|
|
119
|
-
@ReactMethod
|
|
120
|
-
fun syncTodayHealthConnectStepsCount(promise: Promise) {
|
|
121
|
-
scope.launch {
|
|
122
|
-
rookSync.getTodayStepsCount().fold(
|
|
123
|
-
{
|
|
124
|
-
when (it) {
|
|
125
|
-
SyncStatusWithData.RecordsNotFound -> {
|
|
126
|
-
promise.reject("HealthConnectStepsCount", "Records Not Found")
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
is SyncStatusWithData.Synced -> {
|
|
130
|
-
val steps = it.data
|
|
131
|
-
promise.resolve(steps)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
if (it is HCException) {
|
|
137
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
138
|
-
} else {
|
|
139
|
-
promise.reject("1001", it.message, it)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@ReactMethod
|
|
147
|
-
fun syncSHTodayCaloriesCount(promise: Promise) {
|
|
148
|
-
scope.launch {
|
|
149
|
-
rookSamsung.getTodayCaloriesCount().fold(
|
|
150
|
-
{
|
|
151
|
-
when (it) {
|
|
152
|
-
SHSyncStatusWithData.RecordsNotFound -> {
|
|
153
|
-
promise.reject("7", "The SDK could not find any health data related with calories")
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
is SHSyncStatusWithData.Synced -> {
|
|
157
|
-
val data = Arguments.createMap().apply {
|
|
158
|
-
putDouble("basal", it.data.basal ?: 0.0)
|
|
159
|
-
putDouble("active", it.data.active ?: 0.0)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
promise.resolve(data)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
if (it is SHException) {
|
|
168
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
169
|
-
} else {
|
|
170
|
-
promise.reject("1001", it.message, it)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Synchronizes the calories count for the current day from Health Connect.
|
|
179
|
-
* This method queries the Health Connect platform via the Rook SDK to retrieve
|
|
180
|
-
* the calories count for today. If no records are found, it rejects the promise with an error message.
|
|
181
|
-
*
|
|
182
|
-
* @param promise A promise object that resolves with the step count if data is found,
|
|
183
|
-
* or rejects with an error if records are not found or synchronization fails.
|
|
184
|
-
*/
|
|
185
|
-
@ReactMethod
|
|
186
|
-
fun syncTodayCaloriesCount(promise: Promise) {
|
|
187
|
-
scope.launch {
|
|
188
|
-
rookSync.getTodayCaloriesCount().fold(
|
|
189
|
-
{
|
|
190
|
-
when (it) {
|
|
191
|
-
SyncStatusWithData.RecordsNotFound -> {
|
|
192
|
-
promise.reject("7", "The SDK could not find any health data related with calories")
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
is SyncStatusWithData.Synced -> {
|
|
196
|
-
val data = Arguments.createMap().apply {
|
|
197
|
-
putDouble("basal", it.data.basal ?: 0.0)
|
|
198
|
-
putDouble("active", it.data.active ?: 0.0)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
promise.resolve(data)
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
if (it is HCException) {
|
|
207
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
208
|
-
} else {
|
|
209
|
-
promise.reject("1001", it.message, it)
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
)
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
@ReactMethod
|
|
217
|
-
fun getTodayHeartRate(promise: Promise) {
|
|
218
|
-
scope.launch {
|
|
219
|
-
rookSync.getTodayHeartRate().fold(
|
|
220
|
-
{ syncStatus ->
|
|
221
|
-
when (syncStatus) {
|
|
222
|
-
SyncStatusWithData.RecordsNotFound -> {
|
|
223
|
-
promise.reject("7", "The SDK could not find any health data related with calories")
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
is SyncStatusWithData.Synced -> {
|
|
227
|
-
promise.resolve(gsonBuilder.toJson(syncStatus.data))
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
if (it is HCException) {
|
|
233
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
234
|
-
} else {
|
|
235
|
-
promise.reject("1001", it.message, it)
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
)
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
@ReactMethod
|
|
243
|
-
fun getSHTodayHeartRate(promise: Promise) {
|
|
244
|
-
scope.launch {
|
|
245
|
-
rookSamsung.getTodayHeartRate().fold(
|
|
246
|
-
{ syncStatus ->
|
|
247
|
-
when (syncStatus) {
|
|
248
|
-
SHSyncStatusWithData.RecordsNotFound -> {
|
|
249
|
-
promise.reject("7", "The SDK could not find any health data related with calories")
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
is SHSyncStatusWithData.Synced -> {
|
|
253
|
-
promise.resolve(gsonBuilder.toJson(syncStatus.data))
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
if (it is HCException) {
|
|
259
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
260
|
-
} else {
|
|
261
|
-
promise.reject("1001", it.message, it)
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
)
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
@ReactMethod
|
|
269
|
-
fun sync(enableLogs: Boolean, callback: Callback) {
|
|
270
|
-
scope.launch {
|
|
271
|
-
rookSync.sync(enableLogs).fold({ result ->
|
|
272
|
-
callback.invoke(null, result)
|
|
273
|
-
}, {
|
|
274
|
-
val params = Arguments.createMap().apply {
|
|
275
|
-
if (it is HCException) {
|
|
276
|
-
putString(it.code.toString(), it.message)
|
|
277
|
-
} else {
|
|
278
|
-
putString("1001", it.localizedMessage ?: it.message)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
callback.invoke(params, false)
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
@ReactMethod
|
|
288
|
-
fun syncByDate(date: String, callback: Callback) {
|
|
289
|
-
val localDate = RookDateTime.stringToLocalDate(date)
|
|
290
|
-
|
|
291
|
-
scope.launch {
|
|
292
|
-
val result = rookSync.sync(localDate)
|
|
293
|
-
|
|
294
|
-
try {
|
|
295
|
-
val sleepSummaryStatus = result.sleepSummary.getOrThrow()
|
|
296
|
-
val physicalSummaryStatus = result.physicalSummary.getOrThrow()
|
|
297
|
-
val bodySummaryStatus = result.bodySummary.getOrThrow()
|
|
298
|
-
|
|
299
|
-
val noSleepData = sleepSummaryStatus == SyncStatus.RECORDS_NOT_FOUND
|
|
300
|
-
val noPhysicalData = physicalSummaryStatus == SyncStatus.RECORDS_NOT_FOUND
|
|
301
|
-
val noBodyData = bodySummaryStatus == SyncStatus.RECORDS_NOT_FOUND
|
|
302
|
-
|
|
303
|
-
if (noSleepData && noPhysicalData && noBodyData) {
|
|
304
|
-
val throwable = HCRecordsNotFoundException("Sleep, Physical and Body summary")
|
|
305
|
-
|
|
306
|
-
val params = Arguments.createMap().apply {
|
|
307
|
-
putString(throwable.code.toString(), throwable.message)
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
callback.invoke(params, false)
|
|
311
|
-
} else {
|
|
312
|
-
callback.invoke(null, true)
|
|
313
|
-
}
|
|
314
|
-
} catch (e: Exception) {
|
|
315
|
-
val params = Arguments.createMap().apply {
|
|
316
|
-
if (e is HCException){
|
|
317
|
-
putString(e.code.toString(), e.message)
|
|
318
|
-
} else {
|
|
319
|
-
putString("1001", e.message ?: "Unknown error")
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
callback.invoke(params, false)
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
@ReactMethod
|
|
329
|
-
fun syncByDefinition(summary: String, date: String, callback: Callback) {
|
|
330
|
-
val localDate = RookDateTime.stringToLocalDate(date)
|
|
331
|
-
val type = StringToSyncType.stringToSummary(summary)
|
|
332
|
-
|
|
333
|
-
scope.launch {
|
|
334
|
-
val result = rookSync.sync(localDate, type)
|
|
335
|
-
result.onSuccess {
|
|
336
|
-
when (it) {
|
|
337
|
-
SyncStatus.RECORDS_NOT_FOUND -> {
|
|
338
|
-
val throwable = HCRecordsNotFoundException(type.toString())
|
|
339
|
-
|
|
340
|
-
val params = Arguments.createMap().apply {
|
|
341
|
-
putString(throwable.code.toString(), throwable.message)
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
callback.invoke(params, false)
|
|
345
|
-
}
|
|
346
|
-
SyncStatus.SYNCED -> callback.invoke(null, true)
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
result.onFailure {
|
|
351
|
-
val params = Arguments.createMap().apply {
|
|
352
|
-
if (it is HCException) {
|
|
353
|
-
putString(it.code.toString(), it.message)
|
|
354
|
-
} else {
|
|
355
|
-
putString("1001", it.localizedMessage ?: it.message)
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
callback.invoke(params, false)
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
@ReactMethod
|
|
365
|
-
fun syncEvent(date: String, event: String, promise: Promise) {
|
|
366
|
-
val localDate = RookDateTime.stringToLocalDate(date)
|
|
367
|
-
val type = StringToSyncType.stringToEvent(event)
|
|
368
|
-
|
|
369
|
-
scope.launch {
|
|
370
|
-
rookSync.syncEvents(localDate, type).fold({ result ->
|
|
371
|
-
when(result) {
|
|
372
|
-
SyncStatus.RECORDS_NOT_FOUND -> {
|
|
373
|
-
val throwable = HCRecordsNotFoundException(type.toString())
|
|
374
|
-
|
|
375
|
-
promise.reject(throwable.code.toString(), throwable.message, throwable)
|
|
376
|
-
}
|
|
377
|
-
SyncStatus.SYNCED -> promise.resolve(true)
|
|
378
|
-
}
|
|
379
|
-
}, {
|
|
380
|
-
if (it is HCException) {
|
|
381
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
382
|
-
} else {
|
|
383
|
-
promise.reject("1001", it.message, it)
|
|
384
|
-
}
|
|
385
|
-
})
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
@ReactMethod
|
|
390
|
-
fun shSync(enableLogs: Boolean, callback: Callback) {
|
|
391
|
-
scope.launch {
|
|
392
|
-
if (!SamsungAvailability.isSamsungAvailable(rookSamsung)){
|
|
393
|
-
val params = Arguments.createMap().apply {
|
|
394
|
-
putString("5", "Samsung health is not available")
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
callback.invoke(params, false)
|
|
398
|
-
return@launch
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
rookSamsung.sync(enableLogs).fold(
|
|
402
|
-
{
|
|
403
|
-
callback(null, true)
|
|
404
|
-
}, {
|
|
405
|
-
val params = Arguments.createMap().apply {
|
|
406
|
-
if (it is SHException) {
|
|
407
|
-
putString(it.code.toString(), it.message)
|
|
408
|
-
} else {
|
|
409
|
-
putString("1001", it.localizedMessage ?: it.message)
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
callback.invoke(params, false)
|
|
414
|
-
}
|
|
415
|
-
)
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
@ReactMethod
|
|
420
|
-
fun shSyncByDate(date: String, callback: Callback) {
|
|
421
|
-
val localDate = RookDateTime.stringToLocalDate(date)
|
|
422
|
-
|
|
423
|
-
scope.launch {
|
|
424
|
-
if (!SamsungAvailability.isSamsungAvailable(rookSamsung)){
|
|
425
|
-
val params = Arguments.createMap().apply {
|
|
426
|
-
putString("5", "Samsung health is not available")
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
callback.invoke(params, false)
|
|
430
|
-
return@launch
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
val result = rookSamsung.sync(localDate)
|
|
434
|
-
|
|
435
|
-
try {
|
|
436
|
-
val sleepSummaryStatus = result.sleepSummary.getOrThrow()
|
|
437
|
-
val physicalSummaryStatus = result.physicalSummary.getOrThrow()
|
|
438
|
-
val bodySummaryStatus = result.bodySummary.getOrThrow()
|
|
439
|
-
|
|
440
|
-
val noSleepData = sleepSummaryStatus == SHSyncStatus.RECORDS_NOT_FOUND
|
|
441
|
-
val noPhysicalData = physicalSummaryStatus == SHSyncStatus.RECORDS_NOT_FOUND
|
|
442
|
-
val noBodyData = bodySummaryStatus == SHSyncStatus.RECORDS_NOT_FOUND
|
|
443
|
-
|
|
444
|
-
if (noSleepData && noPhysicalData && noBodyData) {
|
|
445
|
-
val throwable = HCRecordsNotFoundException("Sleep, Physical and Body summary")
|
|
446
|
-
|
|
447
|
-
val params = Arguments.createMap().apply {
|
|
448
|
-
putString(throwable.code.toString(), throwable.message)
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
callback.invoke(params, false)
|
|
452
|
-
} else {
|
|
453
|
-
callback.invoke(null, true)
|
|
454
|
-
}
|
|
455
|
-
} catch (e: Exception) {
|
|
456
|
-
val params = Arguments.createMap().apply {
|
|
457
|
-
if (e is HCException){
|
|
458
|
-
putString(e.code.toString(), e.message)
|
|
459
|
-
} else {
|
|
460
|
-
putString("1001", e.message ?: "Unknown error")
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
callback.invoke(params, false)
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
@ReactMethod
|
|
470
|
-
fun shSyncByDefinition(summary: String, date: String, callback: Callback) {
|
|
471
|
-
val localDate = RookDateTime.stringToLocalDate(date)
|
|
472
|
-
val type = StringToSyncType.stringToSamsungPillar(summary)
|
|
473
|
-
|
|
474
|
-
scope.launch {
|
|
475
|
-
if (!SamsungAvailability.isSamsungAvailable(rookSamsung)){
|
|
476
|
-
val params = Arguments.createMap().apply {
|
|
477
|
-
putString("5", "Samsung health is not available")
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
callback.invoke(params, false)
|
|
481
|
-
return@launch
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
val result = rookSamsung.sync(localDate, type)
|
|
485
|
-
result.onSuccess {
|
|
486
|
-
when (it) {
|
|
487
|
-
SHSyncStatus.RECORDS_NOT_FOUND -> {
|
|
488
|
-
val throwable = HCRecordsNotFoundException(type.toString())
|
|
489
|
-
|
|
490
|
-
val params = Arguments.createMap().apply {
|
|
491
|
-
putString(throwable.code.toString(), throwable.message)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
callback.invoke(params, false)
|
|
495
|
-
}
|
|
496
|
-
SHSyncStatus.SYNCED -> callback.invoke(null, true)
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
result.onFailure {
|
|
501
|
-
val params = Arguments.createMap().apply {
|
|
502
|
-
if (it is HCException) {
|
|
503
|
-
putString(it.code.toString(), it.message)
|
|
504
|
-
} else {
|
|
505
|
-
putString("1001", it.localizedMessage ?: it.message)
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
callback.invoke(params, false)
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
@ReactMethod
|
|
515
|
-
fun shSyncEvent(date: String, event: String, promise: Promise) {
|
|
516
|
-
val localDate = RookDateTime.stringToLocalDate(date)
|
|
517
|
-
val type = StringToSyncType.stringToSamsungEvent(event)
|
|
518
|
-
|
|
519
|
-
scope.launch {
|
|
520
|
-
if (!SamsungAvailability.isSamsungAvailable(rookSamsung)){
|
|
521
|
-
promise.reject(
|
|
522
|
-
"5",
|
|
523
|
-
"Samsung health is not available",
|
|
524
|
-
Throwable("Samsung health is not available")
|
|
525
|
-
)
|
|
526
|
-
return@launch
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
rookSamsung.syncEvents(localDate, type).fold({ result ->
|
|
530
|
-
when(result) {
|
|
531
|
-
SHSyncStatus.RECORDS_NOT_FOUND -> {
|
|
532
|
-
val throwable = HCRecordsNotFoundException(type.toString())
|
|
533
|
-
|
|
534
|
-
promise.reject(throwable.code.toString(), throwable.message, throwable)
|
|
535
|
-
}
|
|
536
|
-
SHSyncStatus.SYNCED -> promise.resolve(true)
|
|
537
|
-
}
|
|
538
|
-
}, {
|
|
539
|
-
if (it is HCException) {
|
|
540
|
-
promise.reject(it.code.toString(), it.message, it)
|
|
541
|
-
} else {
|
|
542
|
-
promise.reject("1001", it.message, it)
|
|
543
|
-
}
|
|
544
|
-
})
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
override fun getName(): String {
|
|
548
|
-
return "RookSyncModule"
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
android:width="200dp"
|
|
4
|
-
android:height="200dp"
|
|
5
|
-
android:viewportWidth="512"
|
|
6
|
-
android:viewportHeight="512">
|
|
7
|
-
<path
|
|
8
|
-
android:fillColor="#4285F4"
|
|
9
|
-
android:pathData="M258.3,431.3c-35.1,0 -68.1,-13.3 -92.9,-37.6l44.2,-45.4c26.9,26.2 70.6,26.2 97.6,0l94.4,-92c12.7,-12.4 19.8,-28.9 19.8,-46.3s-7,-33.9 -19.8,-46.3c-26.9,-26.2 -70.6,-26.2 -97.6,0l-17.1,16.7L242.6,135l17.1,-16.7c25,-24.3 58,-37.6 93,-37.6c35.1,0 68.1,13.3 92.9,37.6c25.1,24.4 38.9,57 38.9,91.7s-13.8,67.2 -38.9,91.7l-94.4,92.1C326.4,417.9 293.4,431.3 258.3,431.3z" />
|
|
10
|
-
<path
|
|
11
|
-
android:fillColor="#3DDB85"
|
|
12
|
-
android:pathData="M165.6,393.7L66.5,302l-0.3,-0.3c-25.1,-24.4 -38.9,-57 -38.9,-91.7s13.8,-67.2 38.9,-91.7c24.9,-24.2 57.9,-37.6 92.9,-37.6c35.1,0 68.1,13.3 93,37.5l25.2,24.6l-44.2,45.4L208,163.7c-26.9,-26.2 -70.7,-26.2 -97.6,0c-12.7,12.4 -19.8,28.9 -19.8,46.3c0,17.3 6.9,33.7 19.5,46.1l98.5,91.2L165.6,393.7z" />
|
|
13
|
-
<path
|
|
14
|
-
android:fillColor="#4285F4"
|
|
15
|
-
android:pathData="M165.3,393.7c-24.9,-24.2 -38.6,-56.5 -38.8,-90.9c-0.1,-35.1 13.9,-68.4 39.5,-93.7l0.2,-0.2l91.4,-88.5l44.1,45.5l-91.2,88.4c-13.4,13.3 -20.7,30.4 -20.6,48.3c0.1,17.3 7,33.5 19.6,45.8L165.3,393.7z" />
|
|
16
|
-
<path
|
|
17
|
-
android:fillColor="#3DDB85"
|
|
18
|
-
android:pathData="M302.5,211.3a50.7,50.7 0,1 0,101.4 0a50.7,50.7 0,1 0,-101.4 0z" />
|
|
19
|
-
</vector>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// EncodableRookDataSource.swift
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Created by Javier Villanueva on 08/10/25.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import RookSDK
|
|
10
|
-
|
|
11
|
-
struct EncodableRookDataSource: Encodable {
|
|
12
|
-
|
|
13
|
-
private let dataSource: RookSDK.RookDataSource
|
|
14
|
-
|
|
15
|
-
init(_ dataSource: RookSDK.RookDataSource) {
|
|
16
|
-
self.dataSource = dataSource
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private enum CodingKeys: String, CodingKey {
|
|
20
|
-
case name
|
|
21
|
-
case description
|
|
22
|
-
case imageUrl
|
|
23
|
-
case connected
|
|
24
|
-
case authorizationURL
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
func encode(to encoder: Encoder) throws {
|
|
28
|
-
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
29
|
-
|
|
30
|
-
try container.encode(dataSource.name, forKey: .name)
|
|
31
|
-
try container.encode(dataSource.description, forKey: .description)
|
|
32
|
-
try container.encode(dataSource.imageUrl, forKey: .imageUrl)
|
|
33
|
-
try container.encode(dataSource.connected, forKey: .connected)
|
|
34
|
-
try container.encode(dataSource.authorizationURL, forKey: .authorizationURL)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// EncodableStatusDataSources.swift
|
|
3
|
-
// react-native-rook-sdk
|
|
4
|
-
//
|
|
5
|
-
// Created by Javier Villanueva on 08/10/25.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import RookSDK
|
|
10
|
-
|
|
11
|
-
struct EncodableStatusDataSources: Encodable {
|
|
12
|
-
private let status: RookSDK.StatusDataSources
|
|
13
|
-
|
|
14
|
-
init(_ status: RookSDK.StatusDataSources) {
|
|
15
|
-
self.status = status
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
private enum CodingKeys: String, CodingKey {
|
|
19
|
-
case oura
|
|
20
|
-
case polar
|
|
21
|
-
case whoop
|
|
22
|
-
case fitbit
|
|
23
|
-
case garmin
|
|
24
|
-
case withings
|
|
25
|
-
case googleFit
|
|
26
|
-
case appleHealth
|
|
27
|
-
case healthConnect
|
|
28
|
-
case android
|
|
29
|
-
case dexcom
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func encode(to encoder: Encoder) throws {
|
|
33
|
-
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
34
|
-
|
|
35
|
-
try container.encode(status.oura, forKey: .oura)
|
|
36
|
-
try container.encode(status.polar, forKey: .polar)
|
|
37
|
-
try container.encode(status.whoop, forKey: .whoop)
|
|
38
|
-
try container.encode(status.fitbit, forKey: .fitbit)
|
|
39
|
-
try container.encode(status.garmin, forKey: .garmin)
|
|
40
|
-
try container.encode(status.withings, forKey: .withings)
|
|
41
|
-
try container.encode(status.googleFit, forKey: .googleFit)
|
|
42
|
-
try container.encode(status.appleHealth, forKey: .appleHealth)
|
|
43
|
-
try container.encode(status.healthConnect, forKey: .healthConnect)
|
|
44
|
-
try container.encode(status.android, forKey: .android)
|
|
45
|
-
try container.encode(status.dexcom, forKey: .dexcom)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <React/RCTBridgeModule.h>
|
|
3
|
-
|
|
4
|
-
@interface RCT_EXTERN_MODULE(RookBackground, NSObject)
|
|
5
|
-
|
|
6
|
-
RCT_EXTERN_METHOD(enableBackGroundUpdates: (RCTPromiseResolveBlock)resolve
|
|
7
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
8
|
-
|
|
9
|
-
RCT_EXTERN_METHOD(disableBackGroundUpdates: (RCTPromiseResolveBlock)resolve
|
|
10
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
11
|
-
|
|
12
|
-
RCT_EXTERN_METHOD(isBackgroundUpdatesEnabled: (RCTPromiseResolveBlock)resolve
|
|
13
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
14
|
-
|
|
15
|
-
@end
|