react-native-smallcase-gateway 2.1.0 → 2.2.0
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/CHANGELOG.md +42 -0
- package/android/build.gradle +17 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +4 -0
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -0
- package/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt +106 -1
- package/ios/SmallcaseGateway.m +202 -39
- package/lib/commonjs/ScLoan.js +75 -0
- package/lib/commonjs/ScLoan.js.map +1 -0
- package/lib/commonjs/SmallcaseGateway.js +20 -19
- package/lib/commonjs/SmallcaseGateway.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/ScLoan.js +68 -0
- package/lib/module/ScLoan.js.map +1 -0
- package/lib/module/SmallcaseGateway.js +24 -23
- package/lib/module/SmallcaseGateway.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/package.json +5 -1
- package/react-native-smallcase-gateway.podspec +2 -2
- package/src/ScLoan.js +72 -0
- package/src/SmallcaseGateway.js +74 -58
- package/src/index.js +2 -0
package/src/SmallcaseGateway.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NativeModules, Platform } from
|
|
2
|
-
import { ENV } from
|
|
3
|
-
import { safeObject, platformSpecificColorHex } from
|
|
4
|
-
import { version } from
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { ENV } from './constants';
|
|
3
|
+
import { safeObject, platformSpecificColorHex } from './util';
|
|
4
|
+
import { version } from '../package.json';
|
|
5
5
|
const { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -24,12 +24,13 @@ const { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;
|
|
|
24
24
|
* @property {String} email - email of user
|
|
25
25
|
* @property {String} contact - contact of user
|
|
26
26
|
* @property {String} pinCode - pin-code of user
|
|
27
|
-
*
|
|
27
|
+
*
|
|
28
28
|
* @typedef {Object} SmallplugUiConfig
|
|
29
29
|
* @property {String} headerColor - color of the header background
|
|
30
30
|
* @property {Number} headerOpacity - opacity of the header background
|
|
31
31
|
* @property {String} backIconColor - color of the back icon
|
|
32
32
|
* @property {Number} backIconOpacity - opacity of the back icon
|
|
33
|
+
*
|
|
33
34
|
*/
|
|
34
35
|
|
|
35
36
|
let defaultBrokerList = [];
|
|
@@ -54,9 +55,9 @@ const setConfigEnvironment = async (envConfig) => {
|
|
|
54
55
|
const safeIsLeprechaun = Boolean(isLeprechaun);
|
|
55
56
|
const safeIsAmoEnabled = Boolean(isAmoEnabled);
|
|
56
57
|
const safeBrokerList = Array.isArray(brokerList) ? brokerList : [];
|
|
57
|
-
const safeGatewayName = typeof gatewayName ===
|
|
58
|
+
const safeGatewayName = typeof gatewayName === 'string' ? gatewayName : '';
|
|
58
59
|
const safeEnvName =
|
|
59
|
-
typeof environmentName ===
|
|
60
|
+
typeof environmentName === 'string' ? environmentName : ENV.PROD;
|
|
60
61
|
|
|
61
62
|
defaultBrokerList = safeBrokerList;
|
|
62
63
|
|
|
@@ -77,7 +78,7 @@ const setConfigEnvironment = async (envConfig) => {
|
|
|
77
78
|
*/
|
|
78
79
|
const init = async (sdkToken) => {
|
|
79
80
|
const safeToken = typeof sdkToken === "string" ? sdkToken : "";
|
|
80
|
-
|
|
81
|
+
return SmallcaseGatewayNative.init(safeToken);
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
/**
|
|
@@ -90,7 +91,7 @@ const init = async (sdkToken) => {
|
|
|
90
91
|
*/
|
|
91
92
|
const triggerTransaction = async (transactionId, utmParams, brokerList) => {
|
|
92
93
|
const safeUtm = safeObject(utmParams);
|
|
93
|
-
const safeId = typeof transactionId ===
|
|
94
|
+
const safeId = typeof transactionId === 'string' ? transactionId : '';
|
|
94
95
|
|
|
95
96
|
const safeBrokerList =
|
|
96
97
|
Array.isArray(brokerList) && brokerList.length
|
|
@@ -111,34 +112,29 @@ const triggerTransaction = async (transactionId, utmParams, brokerList) => {
|
|
|
111
112
|
* @returns {Promise<transactionRes>}
|
|
112
113
|
*/
|
|
113
114
|
const triggerMfTransaction = async (transactionId) => {
|
|
114
|
-
const safeTransactionId =
|
|
115
|
+
const safeTransactionId =
|
|
116
|
+
typeof transactionId === 'string' ? transactionId : '';
|
|
115
117
|
|
|
116
|
-
return SmallcaseGatewayNative.triggerMfTransaction(
|
|
117
|
-
|
|
118
|
-
);
|
|
119
|
-
}
|
|
118
|
+
return SmallcaseGatewayNative.triggerMfTransaction(safeTransactionId);
|
|
119
|
+
};
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* launches smallcases module
|
|
123
|
-
*
|
|
123
|
+
*
|
|
124
124
|
* @param {string} targetEndpoint
|
|
125
125
|
* @param {string} params
|
|
126
126
|
*/
|
|
127
|
-
|
|
128
|
-
const safeEndpoint = typeof targetEndpoint ===
|
|
129
|
-
const safeParams = typeof params ===
|
|
130
|
-
|
|
131
|
-
return SmallcaseGatewayNative.launchSmallplug(
|
|
132
|
-
safeEndpoint,
|
|
133
|
-
safeParams
|
|
134
|
-
);
|
|
127
|
+
const launchSmallplug = async (targetEndpoint, params) => {
|
|
128
|
+
const safeEndpoint = typeof targetEndpoint === 'string' ? targetEndpoint : '';
|
|
129
|
+
const safeParams = typeof params === 'string' ? params : '';
|
|
135
130
|
|
|
136
|
-
|
|
131
|
+
return SmallcaseGatewayNative.launchSmallplug(safeEndpoint, safeParams);
|
|
132
|
+
};
|
|
137
133
|
|
|
138
|
-
const safeGatewayName = typeof gatewayName ===
|
|
134
|
+
const safeGatewayName = typeof gatewayName === 'string' ? gatewayName : '';
|
|
139
135
|
/**
|
|
140
136
|
* launches smallcases module
|
|
141
|
-
*
|
|
137
|
+
*
|
|
142
138
|
* @param {string} targetEndpoint
|
|
143
139
|
* @param {string} params
|
|
144
140
|
* @param {string} headerColor
|
|
@@ -146,33 +142,49 @@ const safeGatewayName = typeof gatewayName === "string" ? gatewayName : "";
|
|
|
146
142
|
* @param {string} backIconColor
|
|
147
143
|
* @param {number} backIconOpacity
|
|
148
144
|
*/
|
|
149
|
-
const launchSmallplugWithBranding = async (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
145
|
+
const launchSmallplugWithBranding = async (
|
|
146
|
+
targetEndpoint,
|
|
147
|
+
params,
|
|
148
|
+
headerColor,
|
|
149
|
+
headerOpacity,
|
|
150
|
+
backIconColor,
|
|
151
|
+
backIconOpacity
|
|
152
|
+
) => {
|
|
153
|
+
const safeEndpoint = typeof targetEndpoint === 'string' ? targetEndpoint : '';
|
|
154
|
+
const safeParams = typeof params === 'string' ? params : '';
|
|
155
|
+
const safeHeaderColor =
|
|
156
|
+
typeof headerColor === 'string'
|
|
157
|
+
? headerColor
|
|
158
|
+
: platformSpecificColorHex('2F363F');
|
|
159
|
+
const safeHeaderOpacity =
|
|
160
|
+
typeof headerOpacity === 'number' ? headerOpacity : 1;
|
|
161
|
+
const safeBackIconColor =
|
|
162
|
+
typeof backIconColor === 'string'
|
|
163
|
+
? backIconColor
|
|
164
|
+
: platformSpecificColorHex('FFFFFF');
|
|
165
|
+
const safeBackIconOpacity =
|
|
166
|
+
typeof backIconOpacity === 'number' ? backIconOpacity : 1;
|
|
167
|
+
|
|
168
|
+
return Platform.OS === 'android'
|
|
169
|
+
? SmallcaseGatewayNative.launchSmallplugWithBranding(
|
|
170
|
+
safeEndpoint,
|
|
171
|
+
safeParams,
|
|
172
|
+
{
|
|
173
|
+
headerColor: safeHeaderColor,
|
|
174
|
+
headerOpacity: safeHeaderOpacity,
|
|
175
|
+
backIconColor: safeBackIconColor,
|
|
176
|
+
backIconOpacity: safeBackIconOpacity,
|
|
177
|
+
}
|
|
178
|
+
)
|
|
166
179
|
: SmallcaseGatewayNative.launchSmallplugWithBranding(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
180
|
+
safeEndpoint,
|
|
181
|
+
safeParams,
|
|
182
|
+
safeHeaderColor,
|
|
183
|
+
safeHeaderOpacity,
|
|
184
|
+
safeBackIconColor,
|
|
185
|
+
safeBackIconOpacity
|
|
186
|
+
);
|
|
187
|
+
};
|
|
176
188
|
|
|
177
189
|
/**
|
|
178
190
|
* Logs the user out and removes the web session.
|
|
@@ -188,7 +200,7 @@ const logoutUser = async () => {
|
|
|
188
200
|
/**
|
|
189
201
|
* This will display a list of all the orders that a user recently placed.
|
|
190
202
|
* This includes pending, successful, and failed orders.
|
|
191
|
-
* @returns
|
|
203
|
+
* @returns
|
|
192
204
|
*/
|
|
193
205
|
const showOrders = async () => {
|
|
194
206
|
return SmallcaseGatewayNative.showOrders();
|
|
@@ -217,7 +229,7 @@ const triggerLeadGenWithStatus = async (userDetails) => {
|
|
|
217
229
|
const safeParams = safeObject(userDetails);
|
|
218
230
|
|
|
219
231
|
return SmallcaseGatewayNative.triggerLeadGenWithStatus(safeParams);
|
|
220
|
-
}
|
|
232
|
+
};
|
|
221
233
|
|
|
222
234
|
/**
|
|
223
235
|
* triggers the lead gen flow with an option of "login here" cta
|
|
@@ -227,7 +239,11 @@ const triggerLeadGenWithStatus = async (userDetails) => {
|
|
|
227
239
|
* @param {boolean} [showLoginCta]
|
|
228
240
|
* @returns {Promise}
|
|
229
241
|
*/
|
|
230
|
-
const triggerLeadGenWithLoginCta = async (
|
|
242
|
+
const triggerLeadGenWithLoginCta = async (
|
|
243
|
+
userDetails,
|
|
244
|
+
utmParams,
|
|
245
|
+
showLoginCta
|
|
246
|
+
) => {
|
|
231
247
|
const safeParams = safeObject(userDetails);
|
|
232
248
|
const safeUtm = safeObject(utmParams);
|
|
233
249
|
const safeShowLoginCta = Boolean(showLoginCta);
|
|
@@ -237,7 +253,7 @@ const triggerLeadGenWithLoginCta = async (userDetails, utmParams, showLoginCta)
|
|
|
237
253
|
safeUtm,
|
|
238
254
|
safeShowLoginCta
|
|
239
255
|
);
|
|
240
|
-
}
|
|
256
|
+
};
|
|
241
257
|
|
|
242
258
|
/**
|
|
243
259
|
* Marks a smallcase as archived
|
|
@@ -245,7 +261,7 @@ const triggerLeadGenWithLoginCta = async (userDetails, utmParams, showLoginCta)
|
|
|
245
261
|
* @param {String} iscid
|
|
246
262
|
*/
|
|
247
263
|
const archiveSmallcase = async (iscid) => {
|
|
248
|
-
const safeIscid = typeof iscid ===
|
|
264
|
+
const safeIscid = typeof iscid === 'string' ? iscid : '';
|
|
249
265
|
|
|
250
266
|
return SmallcaseGatewayNative.archiveSmallcase(safeIscid);
|
|
251
267
|
};
|
|
@@ -257,7 +273,7 @@ const archiveSmallcase = async (iscid) => {
|
|
|
257
273
|
*/
|
|
258
274
|
const getSdkVersion = async () => {
|
|
259
275
|
return SmallcaseGatewayNative.getSdkVersion(version);
|
|
260
|
-
}
|
|
276
|
+
};
|
|
261
277
|
|
|
262
278
|
const SmallcaseGateway = {
|
|
263
279
|
init,
|
package/src/index.js
CHANGED