@@ -24,9 +24,22 @@ const {
24
24
RNReaderSDKStoreCustomerCard,
25
25
} = NativeModules ;
26
26
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
+
27
39
export async function authorizeAsync ( authCode ) {
28
40
try {
29
- return await RNReaderSDKAuthorization . authorize ( authCode ) ;
41
+ const value = await RNReaderSDKAuthorization . authorize ( authCode ) ;
42
+ return value ;
30
43
} catch ( ex ) {
31
44
throw createReaderSDKError ( ex ) ;
32
45
}
@@ -42,31 +55,35 @@ export async function deauthorizeAsync() {
42
55
43
56
export async function isAuthorizedAsync ( ) {
44
57
try {
45
- return await RNReaderSDKAuthorization . isAuthorized ( ) ;
58
+ const value = await RNReaderSDKAuthorization . isAuthorized ( ) ;
59
+ return value ;
46
60
} catch ( ex ) {
47
61
throw createReaderSDKError ( ex ) ;
48
62
}
49
63
}
50
64
51
65
export async function isAuthorizationInProgressAsync ( ) {
52
66
try {
53
- return await RNReaderSDKAuthorization . isAuthorizationInProgress ( ) ;
67
+ const value = await RNReaderSDKAuthorization . isAuthorizationInProgress ( ) ;
68
+ return value ;
54
69
} catch ( ex ) {
55
70
throw createReaderSDKError ( ex ) ;
56
71
}
57
72
}
58
73
59
74
export async function canDeauthorizeAsync ( ) {
60
75
try {
61
- return await RNReaderSDKAuthorization . canDeauthorize ( ) ;
76
+ const value = await RNReaderSDKAuthorization . canDeauthorize ( ) ;
77
+ return value ;
62
78
} catch ( ex ) {
63
79
throw createReaderSDKError ( ex ) ;
64
80
}
65
81
}
66
82
67
83
export async function getAuthorizedLocationAsync ( ) {
68
84
try {
69
- return await RNReaderSDKAuthorization . authorizedLocation ( ) ;
85
+ const value = await RNReaderSDKAuthorization . authorizedLocation ( ) ;
86
+ return value ;
70
87
} catch ( ex ) {
71
88
throw createReaderSDKError ( ex ) ;
72
89
}
@@ -75,7 +92,8 @@ export async function getAuthorizedLocationAsync() {
75
92
export async function startCheckoutAsync ( checkoutParams ) {
76
93
try {
77
94
ValidateCheckoutParameters ( checkoutParams ) ;
78
- return await RNReaderSDKCheckout . startCheckout ( checkoutParams ) ;
95
+ const value = await RNReaderSDKCheckout . startCheckout ( checkoutParams ) ;
96
+ return value ;
79
97
} catch ( ex ) {
80
98
throw createReaderSDKError ( ex ) ;
81
99
}
@@ -91,7 +109,8 @@ export async function startReaderSettingsAsync() {
91
109
92
110
export async function startStoreCardAsync ( customerId ) {
93
111
try {
94
- return await RNReaderSDKStoreCustomerCard . startStoreCard ( customerId ) ;
112
+ const value = await RNReaderSDKStoreCustomerCard . startStoreCard ( customerId ) ;
113
+ return value ;
95
114
} catch ( ex ) {
96
115
throw createReaderSDKError ( ex ) ;
97
116
}
@@ -114,16 +133,3 @@ export const StoreCustomerCardCancelled = 'STORE_CUSTOMER_CARD_CANCELED';
114
133
export const StoreCustomerCardInvalidCustomerId = 'STORE_CUSTOMER_CARD_INVALID_CUSTOMER_ID' ;
115
134
export const StoreCustomerCardSdkNotAuthorized = 'STORE_CUSTOMER_CARD_SDK_NOT_AUTHORIZED' ;
116
135
export 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