@@ -24,9 +24,22 @@ const {
2424 RNReaderSDKStoreCustomerCard,
2525} = NativeModules ;
2626
27+ function createReaderSDKError ( ex ) {
28+ try {
29+ const errorDetails = JSON . parse ( ex . message ) ;
30+ ex . message = errorDetails . message ; // eslint-disable-line no-param-reassign
31+ ex . debugCode = errorDetails . debugCode ; // eslint-disable-line no-param-reassign
32+ ex . debugMessage = errorDetails . debugMessage ; // eslint-disable-line no-param-reassign
33+ } catch ( parseEx ) {
34+ ex . parseEx = parseEx ; // eslint-disable-line no-param-reassign
35+ }
36+ return ex ;
37+ }
38+
2739export async function authorizeAsync ( authCode ) {
2840 try {
29- return await RNReaderSDKAuthorization . authorize ( authCode ) ;
41+ const value = await RNReaderSDKAuthorization . authorize ( authCode ) ;
42+ return value ;
3043 } catch ( ex ) {
3144 throw createReaderSDKError ( ex ) ;
3245 }
@@ -42,31 +55,35 @@ export async function deauthorizeAsync() {
4255
4356export async function isAuthorizedAsync ( ) {
4457 try {
45- return await RNReaderSDKAuthorization . isAuthorized ( ) ;
58+ const value = await RNReaderSDKAuthorization . isAuthorized ( ) ;
59+ return value ;
4660 } catch ( ex ) {
4761 throw createReaderSDKError ( ex ) ;
4862 }
4963}
5064
5165export async function isAuthorizationInProgressAsync ( ) {
5266 try {
53- return await RNReaderSDKAuthorization . isAuthorizationInProgress ( ) ;
67+ const value = await RNReaderSDKAuthorization . isAuthorizationInProgress ( ) ;
68+ return value ;
5469 } catch ( ex ) {
5570 throw createReaderSDKError ( ex ) ;
5671 }
5772}
5873
5974export async function canDeauthorizeAsync ( ) {
6075 try {
61- return await RNReaderSDKAuthorization . canDeauthorize ( ) ;
76+ const value = await RNReaderSDKAuthorization . canDeauthorize ( ) ;
77+ return value ;
6278 } catch ( ex ) {
6379 throw createReaderSDKError ( ex ) ;
6480 }
6581}
6682
6783export async function getAuthorizedLocationAsync ( ) {
6884 try {
69- return await RNReaderSDKAuthorization . authorizedLocation ( ) ;
85+ const value = await RNReaderSDKAuthorization . authorizedLocation ( ) ;
86+ return value ;
7087 } catch ( ex ) {
7188 throw createReaderSDKError ( ex ) ;
7289 }
@@ -75,7 +92,8 @@ export async function getAuthorizedLocationAsync() {
7592export async function startCheckoutAsync ( checkoutParams ) {
7693 try {
7794 ValidateCheckoutParameters ( checkoutParams ) ;
78- return await RNReaderSDKCheckout . startCheckout ( checkoutParams ) ;
95+ const value = await RNReaderSDKCheckout . startCheckout ( checkoutParams ) ;
96+ return value ;
7997 } catch ( ex ) {
8098 throw createReaderSDKError ( ex ) ;
8199 }
@@ -91,7 +109,8 @@ export async function startReaderSettingsAsync() {
91109
92110export async function startStoreCardAsync ( customerId ) {
93111 try {
94- return await RNReaderSDKStoreCustomerCard . startStoreCard ( customerId ) ;
112+ const value = await RNReaderSDKStoreCustomerCard . startStoreCard ( customerId ) ;
113+ return value ;
95114 } catch ( ex ) {
96115 throw createReaderSDKError ( ex ) ;
97116 }
@@ -114,16 +133,3 @@ export const StoreCustomerCardCancelled = 'STORE_CUSTOMER_CARD_CANCELED';
114133export const StoreCustomerCardInvalidCustomerId = 'STORE_CUSTOMER_CARD_INVALID_CUSTOMER_ID' ;
115134export const StoreCustomerCardSdkNotAuthorized = 'STORE_CUSTOMER_CARD_SDK_NOT_AUTHORIZED' ;
116135export const StoreCustomerCardNoNetwork = 'STORE_CUSTOMER_CARD_NO_NETWORK' ;
117-
118- function createReaderSDKError ( ex ) {
119- try {
120- const errorDetails = JSON . parse ( ex . message ) ;
121- ex . message = errorDetails . message ; // eslint-disable-line no-param-reassign
122- ex . debugCode = errorDetails . debugCode ; // eslint-disable-line no-param-reassign
123- ex . debugMessage = errorDetails . debugMessage ; // eslint-disable-line no-param-reassign
124- } catch ( parseEx ) {
125- ex . parseEx = parseEx ; // eslint-disable-line no-param-reassign
126- }
127-
128- return ex ;
129- }
0 commit comments