From 2be5f79a7c2918b95361e201df727d6f3fe60f23 Mon Sep 17 00:00:00 2001 From: haripriyan Date: Wed, 19 Apr 2023 22:45:01 +0530 Subject: [PATCH] fix: fixes android release issue --- android/src/main/AndroidManifest.xml | 2 +- .../ChargebeeReactNativeModule.kt | 33 +++++++++++++++---- .../ChargebeeReactNativePackage.kt | 3 +- .../models/CBExceptionExtensions.kt | 2 +- .../models/CBReactNativeError.kt | 2 +- .../models/PurchaseResult.kt | 2 +- .../models/ReadableMapExtension.kt | 2 +- .../{ => reactnative}/utils/Converter.kt | 4 +-- .../src/newarch/ChargebeeReactNativeSpec.kt | 2 +- .../src/oldarch/ChargebeeReactNativeSpec.kt | 2 +- 10 files changed, 38 insertions(+), 16 deletions(-) rename android/src/main/java/com/chargebee/android/{ => reactnative}/ChargebeeReactNativeModule.kt (81%) rename android/src/main/java/com/chargebee/android/{ => reactnative}/ChargebeeReactNativePackage.kt (92%) rename android/src/main/java/com/chargebee/android/{ => reactnative}/models/CBExceptionExtensions.kt (95%) rename android/src/main/java/com/chargebee/android/{ => reactnative}/models/CBReactNativeError.kt (96%) rename android/src/main/java/com/chargebee/android/{ => reactnative}/models/PurchaseResult.kt (87%) rename android/src/main/java/com/chargebee/android/{ => reactnative}/models/ReadableMapExtension.kt (82%) rename android/src/main/java/com/chargebee/android/{ => reactnative}/utils/Converter.kt (97%) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 9c1555b..2729325 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ + package="com.chargebee.android.reactnative"> diff --git a/android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt b/android/src/main/java/com/chargebee/android/reactnative/ChargebeeReactNativeModule.kt similarity index 81% rename from android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt rename to android/src/main/java/com/chargebee/android/reactnative/ChargebeeReactNativeModule.kt index 3cd6193..70cd8f9 100644 --- a/android/src/main/java/com/chargebee/android/ChargebeeReactNativeModule.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/ChargebeeReactNativeModule.kt @@ -1,5 +1,8 @@ -package com.chargebee.android +package com.chargebee.android.reactnative +import com.chargebee.android.Chargebee +import com.chargebee.android.reactnative.ChargebeeReactNativeSpec +import com.chargebee.android.ErrorDetail import com.chargebee.android.billingservice.CBCallback import com.chargebee.android.billingservice.CBPurchase import com.chargebee.android.billingservice.GPErrorCode @@ -8,7 +11,15 @@ import com.chargebee.android.exceptions.CBProductIDResult import com.chargebee.android.exceptions.ChargebeeResult import com.chargebee.android.models.* import com.chargebee.android.network.ReceiptDetail -import com.chargebee.android.utils.* +import com.chargebee.android.reactnative.models.* +import com.chargebee.android.reactnative.utils.convertArrayToWritableArray +import com.chargebee.android.reactnative.utils.convertAuthenticationDetailToDictionary +import com.chargebee.android.reactnative.utils.convertListToWritableArray +import com.chargebee.android.reactnative.utils.convertPurchaseResultToDictionary +import com.chargebee.android.reactnative.utils.convertQueryParamsToArray +import com.chargebee.android.reactnative.utils.convertReadableArray +import com.chargebee.android.reactnative.utils.convertReadableMapToCustomer +import com.chargebee.android.reactnative.utils.convertSubscriptionsToDictionary import com.facebook.react.bridge.* class ChargebeeReactNativeModule internal constructor(context: ReactApplicationContext) : @@ -34,7 +45,12 @@ class ChargebeeReactNativeModule internal constructor(context: ReactApplicationC } is ChargebeeResult.Error -> { val messageUserInfo = it.exp.messageUserInfo() - promise.reject("${CBReactNativeError.INVALID_SDK_CONFIGURATION.code}", messageUserInfo.getString("message"), it.exp, messageUserInfo) + promise.reject( + "${CBReactNativeError.INVALID_SDK_CONFIGURATION.code}", + messageUserInfo.getString("message"), + it.exp, + messageUserInfo + ) } } } @@ -125,14 +141,19 @@ class ChargebeeReactNativeModule internal constructor(context: ReactApplicationC @ReactMethod override fun retrieveSubscriptions(queryParams: ReadableMap, promise: Promise) { Chargebee.retrieveSubscriptions(queryParams.toMap()) { - when(it){ + when (it) { is ChargebeeResult.Success -> { val subscriptions = (it.data as CBSubscription).list promise.resolve(convertSubscriptionsToDictionary(subscriptions)) } - is ChargebeeResult.Error ->{ + is ChargebeeResult.Error -> { val messageUserInfo = it.exp.messageUserInfo() - promise.reject("${CBReactNativeError.INVALID_SDK_CONFIGURATION.code}", messageUserInfo.getString("message"), it.exp, messageUserInfo) + promise.reject( + "${CBReactNativeError.INVALID_SDK_CONFIGURATION.code}", + messageUserInfo.getString("message"), + it.exp, + messageUserInfo + ) } } } diff --git a/android/src/main/java/com/chargebee/android/ChargebeeReactNativePackage.kt b/android/src/main/java/com/chargebee/android/reactnative/ChargebeeReactNativePackage.kt similarity index 92% rename from android/src/main/java/com/chargebee/android/ChargebeeReactNativePackage.kt rename to android/src/main/java/com/chargebee/android/reactnative/ChargebeeReactNativePackage.kt index d14010a..6d1961a 100644 --- a/android/src/main/java/com/chargebee/android/ChargebeeReactNativePackage.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/ChargebeeReactNativePackage.kt @@ -1,5 +1,6 @@ -package com.chargebee.android +package com.chargebee.android.reactnative +import com.chargebee.android.reactnative.BuildConfig import com.facebook.react.TurboReactPackage import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.NativeModule diff --git a/android/src/main/java/com/chargebee/android/models/CBExceptionExtensions.kt b/android/src/main/java/com/chargebee/android/reactnative/models/CBExceptionExtensions.kt similarity index 95% rename from android/src/main/java/com/chargebee/android/models/CBExceptionExtensions.kt rename to android/src/main/java/com/chargebee/android/reactnative/models/CBExceptionExtensions.kt index 7d5ed1f..121d9e5 100644 --- a/android/src/main/java/com/chargebee/android/models/CBExceptionExtensions.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/models/CBExceptionExtensions.kt @@ -1,4 +1,4 @@ -package com.chargebee.android.models +package com.chargebee.android.reactnative.models import com.chargebee.android.exceptions.CBException import com.facebook.react.bridge.WritableMap diff --git a/android/src/main/java/com/chargebee/android/models/CBReactNativeError.kt b/android/src/main/java/com/chargebee/android/reactnative/models/CBReactNativeError.kt similarity index 96% rename from android/src/main/java/com/chargebee/android/models/CBReactNativeError.kt rename to android/src/main/java/com/chargebee/android/reactnative/models/CBReactNativeError.kt index 224e6c5..bc37016 100644 --- a/android/src/main/java/com/chargebee/android/models/CBReactNativeError.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/models/CBReactNativeError.kt @@ -1,4 +1,4 @@ -package com.chargebee.android.models +package com.chargebee.android.reactnative.models import com.android.billingclient.api.BillingClient import com.android.billingclient.api.BillingClient.BillingResponseCode.* diff --git a/android/src/main/java/com/chargebee/android/models/PurchaseResult.kt b/android/src/main/java/com/chargebee/android/reactnative/models/PurchaseResult.kt similarity index 87% rename from android/src/main/java/com/chargebee/android/models/PurchaseResult.kt rename to android/src/main/java/com/chargebee/android/reactnative/models/PurchaseResult.kt index 585eeaa..d21c471 100644 --- a/android/src/main/java/com/chargebee/android/models/PurchaseResult.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/models/PurchaseResult.kt @@ -1,4 +1,4 @@ -package com.chargebee.android.models +package com.chargebee.android.reactnative.models import com.chargebee.android.network.ReceiptDetail import java.io.Serializable diff --git a/android/src/main/java/com/chargebee/android/models/ReadableMapExtension.kt b/android/src/main/java/com/chargebee/android/reactnative/models/ReadableMapExtension.kt similarity index 82% rename from android/src/main/java/com/chargebee/android/models/ReadableMapExtension.kt rename to android/src/main/java/com/chargebee/android/reactnative/models/ReadableMapExtension.kt index 0cb6035..bc55e06 100644 --- a/android/src/main/java/com/chargebee/android/models/ReadableMapExtension.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/models/ReadableMapExtension.kt @@ -1,4 +1,4 @@ -package com.chargebee.android.models +package com.chargebee.android.reactnative.models import com.facebook.react.bridge.ReadableMap diff --git a/android/src/main/java/com/chargebee/android/utils/Converter.kt b/android/src/main/java/com/chargebee/android/reactnative/utils/Converter.kt similarity index 97% rename from android/src/main/java/com/chargebee/android/utils/Converter.kt rename to android/src/main/java/com/chargebee/android/reactnative/utils/Converter.kt index 2d89c3f..b465bd5 100644 --- a/android/src/main/java/com/chargebee/android/utils/Converter.kt +++ b/android/src/main/java/com/chargebee/android/reactnative/utils/Converter.kt @@ -1,7 +1,7 @@ -package com.chargebee.android.utils +package com.chargebee.android.reactnative.utils import com.chargebee.android.models.CBProduct -import com.chargebee.android.models.PurchaseResult +import com.chargebee.android.reactnative.models.PurchaseResult import com.chargebee.android.models.SubscriptionDetailsWrapper import com.chargebee.android.network.CBAuthResponse import com.chargebee.android.network.CBCustomer diff --git a/android/src/newarch/ChargebeeReactNativeSpec.kt b/android/src/newarch/ChargebeeReactNativeSpec.kt index ce8834d..3ffc01c 100644 --- a/android/src/newarch/ChargebeeReactNativeSpec.kt +++ b/android/src/newarch/ChargebeeReactNativeSpec.kt @@ -1,4 +1,4 @@ -package com.chargebee.android +package com.chargebee.android.reactnative import com.facebook.react.bridge.ReactApplicationContext diff --git a/android/src/oldarch/ChargebeeReactNativeSpec.kt b/android/src/oldarch/ChargebeeReactNativeSpec.kt index 5b3a8fa..71ac25c 100644 --- a/android/src/oldarch/ChargebeeReactNativeSpec.kt +++ b/android/src/oldarch/ChargebeeReactNativeSpec.kt @@ -1,4 +1,4 @@ -package com.chargebee.android +package com.chargebee.android.reactnative import com.facebook.react.bridge.*