react-native-smallcase-gateway 2.3.1 → 3.0.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 +12 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt +30 -24
- package/ios/SmallcaseGateway.m +37 -48
- package/lib/commonjs/ScLoan.js +20 -5
- package/lib/commonjs/ScLoan.js.map +1 -1
- package/lib/module/ScLoan.js +20 -5
- package/lib/module/ScLoan.js.map +1 -1
- package/package.json +1 -1
- package/react-native-smallcase-gateway.podspec +1 -1
- package/src/ScLoan.js +20 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.0.0](https://github.com/smallcase/react-native-smallcase-gateway/compare/v2.3.1...v3.0.0) (2024-01-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* loans ([1ac32dc](https://github.com/smallcase/react-native-smallcase-gateway/commit/1ac32dc1506b5511ab7924a73bfd2b31d471fe8a))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **native:** changed Bridge method responses to conform to ScLoanResponse ([6f1a2b6](https://github.com/smallcase/react-native-smallcase-gateway/commit/6f1a2b621f90b7677d37e6dd2150487f46e3d5a7))
|
|
16
|
+
|
|
5
17
|
### [2.3.1](https://github.com/smallcase/react-native-smallcase-gateway/compare/v2.3.0...v2.3.1) (2023-12-08)
|
|
6
18
|
|
|
7
19
|
## [2.3.0](https://github.com/smallcase/react-native-smallcase-gateway/compare/v2.2.2...v2.3.0) (2023-10-17)
|
package/android/build.gradle
CHANGED
|
@@ -148,7 +148,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
148
148
|
dependencies {
|
|
149
149
|
//noinspection GradleDynamicVersion
|
|
150
150
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
151
|
-
implementation 'com.smallcase.gateway:sdk:3.
|
|
151
|
+
implementation 'com.smallcase.gateway:sdk:3.12.2'
|
|
152
152
|
implementation "androidx.core:core-ktx:1.3.1"
|
|
153
153
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
154
154
|
}
|
|
@@ -315,18 +315,13 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
|
|
|
315
315
|
val scGatewayConfig = ScLoanConfig(gateway, scEnvironment)
|
|
316
316
|
val setupResponse = ScLoan.setup(scGatewayConfig, object : ScLoanResult {
|
|
317
317
|
override fun onFailure(error: ScLoanError) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
318
|
+
promise.reject("${error.code}", scLoanResponseToWritableMap(error) ?: return)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
override fun onSuccess(response: ScLoanSuccess) {
|
|
322
|
+
promise.resolve(scLoanResponseToWritableMap(response) ?: return)
|
|
323
|
+
}
|
|
325
324
|
})
|
|
326
|
-
// val writableMap: WritableMap = Arguments.createMap()
|
|
327
|
-
// writableMap.putString("version", setupResponse.version)
|
|
328
|
-
// writableMap.putInt("versionCode", setupResponse.versionCode.toInt())
|
|
329
|
-
// promise.resolve(Gson().toJson(writableMap.toHashMap()))
|
|
330
325
|
}
|
|
331
326
|
|
|
332
327
|
@ReactMethod
|
|
@@ -341,12 +336,11 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
|
|
|
341
336
|
val loanConfigObj = ScLoanInfo(interactionToken)
|
|
342
337
|
ScLoan.apply(appCompatActivity, loanConfigObj, object : ScLoanResult {
|
|
343
338
|
override fun onFailure(error: ScLoanError) {
|
|
344
|
-
|
|
345
|
-
promise.reject("error", errorWritableMap)
|
|
339
|
+
promise.reject("${error.code}", scLoanResponseToWritableMap(error) ?: return)
|
|
346
340
|
}
|
|
347
341
|
|
|
348
342
|
override fun onSuccess(response: ScLoanSuccess) {
|
|
349
|
-
promise.resolve(response
|
|
343
|
+
promise.resolve(scLoanResponseToWritableMap(response) ?: return)
|
|
350
344
|
}
|
|
351
345
|
})
|
|
352
346
|
}
|
|
@@ -363,12 +357,11 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
|
|
|
363
357
|
val loanConfigObj = ScLoanInfo(interactionToken)
|
|
364
358
|
ScLoan.pay(appCompatActivity, loanConfigObj, object : ScLoanResult {
|
|
365
359
|
override fun onFailure(error: ScLoanError) {
|
|
366
|
-
|
|
367
|
-
promise.reject("error", errorWritableMap)
|
|
360
|
+
promise.reject("${error.code}", scLoanResponseToWritableMap(error) ?: return)
|
|
368
361
|
}
|
|
369
362
|
|
|
370
363
|
override fun onSuccess(response: ScLoanSuccess) {
|
|
371
|
-
promise.resolve(response
|
|
364
|
+
promise.resolve(scLoanResponseToWritableMap(response) ?: return)
|
|
372
365
|
}
|
|
373
366
|
})
|
|
374
367
|
}
|
|
@@ -385,16 +378,15 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
|
|
|
385
378
|
val loanConfigObj = ScLoanInfo(interactionToken)
|
|
386
379
|
ScLoan.withdraw(appCompatActivity, loanConfigObj, object : ScLoanResult {
|
|
387
380
|
override fun onFailure(error: ScLoanError) {
|
|
388
|
-
|
|
389
|
-
promise.reject("error", errorWritableMap)
|
|
381
|
+
promise.reject("${error.code}", scLoanResponseToWritableMap(error) ?: return)
|
|
390
382
|
}
|
|
391
383
|
|
|
392
384
|
override fun onSuccess(response: ScLoanSuccess) {
|
|
393
|
-
promise.resolve(response
|
|
385
|
+
promise.resolve(scLoanResponseToWritableMap(response) ?: return)
|
|
394
386
|
}
|
|
395
387
|
})
|
|
396
388
|
}
|
|
397
|
-
|
|
389
|
+
|
|
398
390
|
@ReactMethod
|
|
399
391
|
fun service(loanConfig: ReadableMap, promise: Promise) {
|
|
400
392
|
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
|
|
@@ -407,12 +399,11 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
|
|
|
407
399
|
val loanConfigObj = ScLoanInfo(interactionToken)
|
|
408
400
|
ScLoan.service(appCompatActivity, loanConfigObj, object : ScLoanResult {
|
|
409
401
|
override fun onFailure(error: ScLoanError) {
|
|
410
|
-
|
|
411
|
-
promise.reject("error", errorWritableMap)
|
|
402
|
+
promise.reject("${error.code}", scLoanResponseToWritableMap(error) ?: return)
|
|
412
403
|
}
|
|
413
404
|
|
|
414
405
|
override fun onSuccess(response: ScLoanSuccess) {
|
|
415
|
-
promise.resolve(response
|
|
406
|
+
promise.resolve(scLoanResponseToWritableMap(response) ?: return)
|
|
416
407
|
}
|
|
417
408
|
})
|
|
418
409
|
}
|
|
@@ -472,5 +463,20 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
|
|
|
472
463
|
return errObj
|
|
473
464
|
}
|
|
474
465
|
|
|
466
|
+
private fun scLoanResponseToWritableMap(response: ScLoansResponse?): WritableMap? {
|
|
467
|
+
val map = Arguments.createMap()
|
|
468
|
+
response?.also {
|
|
469
|
+
map.putBoolean("isSuccess", it.isSuccess)
|
|
470
|
+
map.putString("data", it.data)
|
|
471
|
+
}
|
|
472
|
+
if(response is ScLoanError) {
|
|
473
|
+
map.apply {
|
|
474
|
+
putInt("code", response.code)
|
|
475
|
+
putString("message", response.message)
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return map
|
|
479
|
+
}
|
|
480
|
+
|
|
475
481
|
}
|
|
476
482
|
|
package/ios/SmallcaseGateway.m
CHANGED
|
@@ -518,19 +518,10 @@ RCT_REMAP_METHOD(setupLoans,
|
|
|
518
518
|
[ScLoan.instance setupWithConfig:gatewayLoanConfig completion:^(ScLoanSuccess * success, ScLoanError * error) {
|
|
519
519
|
|
|
520
520
|
if(error != nil) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
524
|
-
[responseDict setValue:error.domain forKey:@"errorMessage"];
|
|
525
|
-
|
|
526
|
-
NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];
|
|
527
|
-
|
|
528
|
-
reject(@"apply", @"Error while applying for Loan", err);
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
521
|
+
reject([NSString stringWithFormat:@"%li", (long)error.errorCode], error.errorMessage, [self scLoanErrorToDict:error]);
|
|
522
|
+
return;
|
|
531
523
|
}
|
|
532
|
-
|
|
533
|
-
resolve(@(YES));
|
|
524
|
+
resolve([self scLoanSuccessToDict:success]);
|
|
534
525
|
}];
|
|
535
526
|
}
|
|
536
527
|
|
|
@@ -554,17 +545,10 @@ RCT_REMAP_METHOD(apply,
|
|
|
554
545
|
[ScLoan.instance applyWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] loanInfo:gatewayLoanInfo completion:^(ScLoanSuccess * success, ScLoanError * error) {
|
|
555
546
|
|
|
556
547
|
if(error != nil) {
|
|
557
|
-
|
|
558
|
-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
559
|
-
[responseDict setValue:error.domain forKey:@"errorMessage"];
|
|
560
|
-
|
|
561
|
-
NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];
|
|
562
|
-
|
|
563
|
-
reject(@"apply", @"Error while applying for Loan", err);
|
|
548
|
+
reject([NSString stringWithFormat:@"%li", (long)error.errorCode], error.errorMessage, [self scLoanErrorToDict:error]);
|
|
564
549
|
return;
|
|
565
550
|
}
|
|
566
|
-
|
|
567
|
-
resolve(success.data);
|
|
551
|
+
resolve([self scLoanSuccessToDict:success]);
|
|
568
552
|
}];
|
|
569
553
|
}
|
|
570
554
|
|
|
@@ -588,17 +572,10 @@ RCT_REMAP_METHOD(pay,
|
|
|
588
572
|
[ScLoan.instance payWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] loanInfo:gatewayLoanInfo completion:^(ScLoanSuccess * success, ScLoanError * error) {
|
|
589
573
|
|
|
590
574
|
if(error != nil) {
|
|
591
|
-
|
|
592
|
-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
593
|
-
[responseDict setValue:error.domain forKey:@"errorMessage"];
|
|
594
|
-
|
|
595
|
-
NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];
|
|
596
|
-
|
|
597
|
-
reject(@"apply", @"Error while applying for Loan", err);
|
|
575
|
+
reject([NSString stringWithFormat:@"%li", (long)error.errorCode], error.errorMessage, [self scLoanErrorToDict:error]);
|
|
598
576
|
return;
|
|
599
577
|
}
|
|
600
|
-
|
|
601
|
-
resolve(success.data);
|
|
578
|
+
resolve([self scLoanSuccessToDict:success]);
|
|
602
579
|
}];
|
|
603
580
|
}
|
|
604
581
|
|
|
@@ -622,17 +599,10 @@ RCT_REMAP_METHOD(withdraw,
|
|
|
622
599
|
[ScLoan.instance withdrawWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] loanInfo:gatewayLoanInfo completion:^(ScLoanSuccess * success, ScLoanError * error) {
|
|
623
600
|
|
|
624
601
|
if(error != nil) {
|
|
625
|
-
|
|
626
|
-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
627
|
-
[responseDict setValue:error.domain forKey:@"errorMessage"];
|
|
628
|
-
|
|
629
|
-
NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];
|
|
630
|
-
|
|
631
|
-
reject(@"apply", @"Error while applying for Loan", err);
|
|
602
|
+
reject([NSString stringWithFormat:@"%li", (long)error.errorCode], error.errorMessage, [self scLoanErrorToDict:error]);
|
|
632
603
|
return;
|
|
633
604
|
}
|
|
634
|
-
|
|
635
|
-
resolve(success.data);
|
|
605
|
+
resolve([self scLoanSuccessToDict:success]);
|
|
636
606
|
}];
|
|
637
607
|
}
|
|
638
608
|
|
|
@@ -656,22 +626,41 @@ RCT_REMAP_METHOD(service,
|
|
|
656
626
|
[ScLoan.instance serviceWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] loanInfo:gatewayLoanInfo completion:^(ScLoanSuccess * success, ScLoanError * error) {
|
|
657
627
|
|
|
658
628
|
if(error != nil) {
|
|
659
|
-
|
|
660
|
-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
661
|
-
[responseDict setValue:error.domain forKey:@"errorMessage"];
|
|
662
|
-
|
|
663
|
-
NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];
|
|
664
|
-
|
|
665
|
-
reject(@"apply", @"Error while applying for Loan", err);
|
|
629
|
+
reject([NSString stringWithFormat:@"%li", (long)error.errorCode], error.errorMessage, [self scLoanErrorToDict:error]);
|
|
666
630
|
return;
|
|
667
631
|
}
|
|
668
|
-
|
|
669
|
-
|
|
632
|
+
resolve([self scLoanSuccessToDict:success]);
|
|
633
|
+
|
|
670
634
|
}];
|
|
671
635
|
}
|
|
672
636
|
|
|
673
637
|
});
|
|
674
638
|
}
|
|
675
639
|
|
|
640
|
+
- (NSDictionary *)scLoanSuccessToDict:(ScLoanSuccess *)success {
|
|
641
|
+
NSMutableDictionary *successDict = [NSMutableDictionary dictionary];
|
|
642
|
+
successDict[@"isSuccess"] = @(success.isSuccess);
|
|
643
|
+
|
|
644
|
+
id data = success.data;
|
|
645
|
+
if (data && ![data isKindOfClass:[NSNull class]]) {
|
|
646
|
+
successDict[@"data"] = data;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return successDict;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
- (NSError *)scLoanErrorToDict:(ScLoanError *)error {
|
|
653
|
+
|
|
654
|
+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
|
|
655
|
+
[responseDict setValue:[NSNumber numberWithInteger:error.errorCode] forKey:@"code"];
|
|
656
|
+
[responseDict setValue:error.errorMessage forKey:@"message"];
|
|
657
|
+
[responseDict setValue:error.data forKey:@"data"];
|
|
658
|
+
[responseDict setValue:@NO forKey:@"isSuccess"];
|
|
659
|
+
|
|
660
|
+
NSError *err = [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:responseDict];
|
|
661
|
+
return err;
|
|
662
|
+
|
|
663
|
+
}
|
|
664
|
+
|
|
676
665
|
@end
|
|
677
666
|
|
package/lib/commonjs/ScLoan.js
CHANGED
|
@@ -18,13 +18,24 @@ const {
|
|
|
18
18
|
*
|
|
19
19
|
* @typedef {Object} ScLoanInfo
|
|
20
20
|
* @property {String} interactionToken
|
|
21
|
+
*
|
|
22
|
+
* @typedef {Object} ScLoanSuccess
|
|
23
|
+
* @property {boolean} isSuccess
|
|
24
|
+
* @property {string} data
|
|
25
|
+
*
|
|
26
|
+
* @typedef {Object} ScLoanError
|
|
27
|
+
* @property {boolean} isSuccess
|
|
28
|
+
* @property {number} code
|
|
29
|
+
* @property {string} message
|
|
30
|
+
* @property {string} data
|
|
21
31
|
*/
|
|
22
32
|
|
|
23
33
|
/**
|
|
24
34
|
* Setup ScLoans
|
|
25
35
|
*
|
|
26
36
|
* @param {ScLoanConfig} config
|
|
27
|
-
* @returns {Promise<
|
|
37
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
38
|
+
* @throws {ScLoanError}
|
|
28
39
|
*/
|
|
29
40
|
const setup = async config => {
|
|
30
41
|
const safeConfig = (0, _util.safeObject)(config);
|
|
@@ -36,7 +47,8 @@ const setup = async config => {
|
|
|
36
47
|
* Triggers the LOS Journey
|
|
37
48
|
*
|
|
38
49
|
* @param {ScLoanInfo} loanInfo
|
|
39
|
-
* @returns {Promise<
|
|
50
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
51
|
+
* @throws {ScLoanError}
|
|
40
52
|
*/
|
|
41
53
|
const apply = async loanInfo => {
|
|
42
54
|
const safeLoanInfo = (0, _util.safeObject)(loanInfo);
|
|
@@ -47,7 +59,8 @@ const apply = async loanInfo => {
|
|
|
47
59
|
* Triggers the Repayment Journey
|
|
48
60
|
*
|
|
49
61
|
* @param {ScLoanInfo} loanInfo
|
|
50
|
-
* @returns {Promise<
|
|
62
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
63
|
+
* @throws {ScLoanError}
|
|
51
64
|
*/
|
|
52
65
|
const pay = async loanInfo => {
|
|
53
66
|
const safeLoanInfo = (0, _util.safeObject)(loanInfo);
|
|
@@ -58,7 +71,8 @@ const pay = async loanInfo => {
|
|
|
58
71
|
* Triggers the Withdraw Journey
|
|
59
72
|
*
|
|
60
73
|
* @param {ScLoanInfo} loanInfo
|
|
61
|
-
* @returns {Promise<
|
|
74
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
75
|
+
* @throws {ScLoanError}
|
|
62
76
|
*/
|
|
63
77
|
const withdraw = async loanInfo => {
|
|
64
78
|
const safeLoanInfo = (0, _util.safeObject)(loanInfo);
|
|
@@ -69,7 +83,8 @@ const withdraw = async loanInfo => {
|
|
|
69
83
|
* Triggers the Servicing Journey
|
|
70
84
|
*
|
|
71
85
|
* @param {ScLoanInfo} loanInfo
|
|
72
|
-
* @returns {Promise<
|
|
86
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
87
|
+
* @throws {ScLoanError}
|
|
73
88
|
*/
|
|
74
89
|
const service = async loanInfo => {
|
|
75
90
|
const safeLoanInfo = (0, _util.safeObject)(loanInfo);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_util","_constants","SmallcaseGateway","SmallcaseGatewayNative","NativeModules","setup","config","safeConfig","safeObject","environment","undefined","ENV","PROD","setupLoans","apply","loanInfo","safeLoanInfo","pay","withdraw","service","ScLoan","_default","exports","default"],"sources":["ScLoan.js"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport { safeObject } from './util';\nimport { ENV } from './constants';\n\nconst { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;\n\n/**\n * @typedef {Object} ScLoanConfig\n * @property {String} gatewayName\n * @property {'production' | 'staging' | 'development'} environment - environment\n *\n * @typedef {Object} ScLoanInfo\n * @property {String} interactionToken\n */\n\n/**\n * Setup ScLoans\n *\n * @param {ScLoanConfig} config\n * @returns {Promise<
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_util","_constants","SmallcaseGateway","SmallcaseGatewayNative","NativeModules","setup","config","safeConfig","safeObject","environment","undefined","ENV","PROD","setupLoans","apply","loanInfo","safeLoanInfo","pay","withdraw","service","ScLoan","_default","exports","default"],"sources":["ScLoan.js"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport { safeObject } from './util';\nimport { ENV } from './constants';\n\nconst { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;\n\n/**\n * @typedef {Object} ScLoanConfig\n * @property {String} gatewayName\n * @property {'production' | 'staging' | 'development'} environment - environment\n *\n * @typedef {Object} ScLoanInfo\n * @property {String} interactionToken\n *\n * @typedef {Object} ScLoanSuccess\n * @property {boolean} isSuccess\n * @property {string} data\n *\n * @typedef {Object} ScLoanError\n * @property {boolean} isSuccess\n * @property {number} code\n * @property {string} message\n * @property {string} data\n */\n\n/**\n * Setup ScLoans\n *\n * @param {ScLoanConfig} config\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst setup = async (config) => {\n const safeConfig = safeObject(config);\n if(safeConfig.environment === undefined || safeConfig.environment === null) safeConfig.environment = ENV.PROD\n\n return SmallcaseGatewayNative.setupLoans(safeConfig);\n };\n\n/**\n * Triggers the LOS Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst apply = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.apply(safeLoanInfo);\n };\n\n/**\n * Triggers the Repayment Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst pay = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.pay(safeLoanInfo);\n };\n\n/**\n * Triggers the Withdraw Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst withdraw = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.withdraw(safeLoanInfo);\n };\n\n/**\n * Triggers the Servicing Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst service = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.service(safeLoanInfo);\n };\n\nconst ScLoan = {\n setup,\n apply,\n pay,\n withdraw,\n service\n}\n\nexport default ScLoan;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,MAAM;EAAEG,gBAAgB,EAAEC;AAAuB,CAAC,GAAGC,0BAAa;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,GAAG,MAAOC,MAAM,IAAK;EAC5B,MAAMC,UAAU,GAAG,IAAAC,gBAAU,EAACF,MAAM,CAAC;EACrC,IAAGC,UAAU,CAACE,WAAW,KAAKC,SAAS,IAAIH,UAAU,CAACE,WAAW,KAAK,IAAI,EAAEF,UAAU,CAACE,WAAW,GAAGE,cAAG,CAACC,IAAI;EAE7G,OAAOT,sBAAsB,CAACU,UAAU,CAACN,UAAU,CAAC;AACtD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMO,KAAK,GAAG,MAAOC,QAAQ,IAAK;EAC9B,MAAMC,YAAY,GAAG,IAAAR,gBAAU,EAACO,QAAQ,CAAC;EAEzC,OAAOZ,sBAAsB,CAACW,KAAK,CAACE,YAAY,CAAC;AACnD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,GAAG,GAAG,MAAOF,QAAQ,IAAK;EAC5B,MAAMC,YAAY,GAAG,IAAAR,gBAAU,EAACO,QAAQ,CAAC;EAEzC,OAAOZ,sBAAsB,CAACc,GAAG,CAACD,YAAY,CAAC;AACjD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,QAAQ,GAAG,MAAOH,QAAQ,IAAK;EACjC,MAAMC,YAAY,GAAG,IAAAR,gBAAU,EAACO,QAAQ,CAAC;EAEzC,OAAOZ,sBAAsB,CAACe,QAAQ,CAACF,YAAY,CAAC;AACtD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAG,MAAOJ,QAAQ,IAAK;EAChC,MAAMC,YAAY,GAAG,IAAAR,gBAAU,EAACO,QAAQ,CAAC;EAEzC,OAAOZ,sBAAsB,CAACgB,OAAO,CAACH,YAAY,CAAC;AACrD,CAAC;AAEH,MAAMI,MAAM,GAAG;EACXf,KAAK;EACLS,KAAK;EACLG,GAAG;EACHC,QAAQ;EACRC;AACJ,CAAC;AAAA,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcH,MAAM"}
|
package/lib/module/ScLoan.js
CHANGED
|
@@ -12,13 +12,24 @@ const {
|
|
|
12
12
|
*
|
|
13
13
|
* @typedef {Object} ScLoanInfo
|
|
14
14
|
* @property {String} interactionToken
|
|
15
|
+
*
|
|
16
|
+
* @typedef {Object} ScLoanSuccess
|
|
17
|
+
* @property {boolean} isSuccess
|
|
18
|
+
* @property {string} data
|
|
19
|
+
*
|
|
20
|
+
* @typedef {Object} ScLoanError
|
|
21
|
+
* @property {boolean} isSuccess
|
|
22
|
+
* @property {number} code
|
|
23
|
+
* @property {string} message
|
|
24
|
+
* @property {string} data
|
|
15
25
|
*/
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
28
|
* Setup ScLoans
|
|
19
29
|
*
|
|
20
30
|
* @param {ScLoanConfig} config
|
|
21
|
-
* @returns {Promise<
|
|
31
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
32
|
+
* @throws {ScLoanError}
|
|
22
33
|
*/
|
|
23
34
|
const setup = async config => {
|
|
24
35
|
const safeConfig = safeObject(config);
|
|
@@ -30,7 +41,8 @@ const setup = async config => {
|
|
|
30
41
|
* Triggers the LOS Journey
|
|
31
42
|
*
|
|
32
43
|
* @param {ScLoanInfo} loanInfo
|
|
33
|
-
* @returns {Promise<
|
|
44
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
45
|
+
* @throws {ScLoanError}
|
|
34
46
|
*/
|
|
35
47
|
const apply = async loanInfo => {
|
|
36
48
|
const safeLoanInfo = safeObject(loanInfo);
|
|
@@ -41,7 +53,8 @@ const apply = async loanInfo => {
|
|
|
41
53
|
* Triggers the Repayment Journey
|
|
42
54
|
*
|
|
43
55
|
* @param {ScLoanInfo} loanInfo
|
|
44
|
-
* @returns {Promise<
|
|
56
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
57
|
+
* @throws {ScLoanError}
|
|
45
58
|
*/
|
|
46
59
|
const pay = async loanInfo => {
|
|
47
60
|
const safeLoanInfo = safeObject(loanInfo);
|
|
@@ -52,7 +65,8 @@ const pay = async loanInfo => {
|
|
|
52
65
|
* Triggers the Withdraw Journey
|
|
53
66
|
*
|
|
54
67
|
* @param {ScLoanInfo} loanInfo
|
|
55
|
-
* @returns {Promise<
|
|
68
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
69
|
+
* @throws {ScLoanError}
|
|
56
70
|
*/
|
|
57
71
|
const withdraw = async loanInfo => {
|
|
58
72
|
const safeLoanInfo = safeObject(loanInfo);
|
|
@@ -63,7 +77,8 @@ const withdraw = async loanInfo => {
|
|
|
63
77
|
* Triggers the Servicing Journey
|
|
64
78
|
*
|
|
65
79
|
* @param {ScLoanInfo} loanInfo
|
|
66
|
-
* @returns {Promise<
|
|
80
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
81
|
+
* @throws {ScLoanError}
|
|
67
82
|
*/
|
|
68
83
|
const service = async loanInfo => {
|
|
69
84
|
const safeLoanInfo = safeObject(loanInfo);
|
package/lib/module/ScLoan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","safeObject","ENV","SmallcaseGateway","SmallcaseGatewayNative","setup","config","safeConfig","environment","undefined","PROD","setupLoans","apply","loanInfo","safeLoanInfo","pay","withdraw","service","ScLoan"],"sources":["ScLoan.js"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport { safeObject } from './util';\nimport { ENV } from './constants';\n\nconst { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;\n\n/**\n * @typedef {Object} ScLoanConfig\n * @property {String} gatewayName\n * @property {'production' | 'staging' | 'development'} environment - environment\n *\n * @typedef {Object} ScLoanInfo\n * @property {String} interactionToken\n */\n\n/**\n * Setup ScLoans\n *\n * @param {ScLoanConfig} config\n * @returns {Promise<
|
|
1
|
+
{"version":3,"names":["NativeModules","safeObject","ENV","SmallcaseGateway","SmallcaseGatewayNative","setup","config","safeConfig","environment","undefined","PROD","setupLoans","apply","loanInfo","safeLoanInfo","pay","withdraw","service","ScLoan"],"sources":["ScLoan.js"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport { safeObject } from './util';\nimport { ENV } from './constants';\n\nconst { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;\n\n/**\n * @typedef {Object} ScLoanConfig\n * @property {String} gatewayName\n * @property {'production' | 'staging' | 'development'} environment - environment\n *\n * @typedef {Object} ScLoanInfo\n * @property {String} interactionToken\n *\n * @typedef {Object} ScLoanSuccess\n * @property {boolean} isSuccess\n * @property {string} data\n *\n * @typedef {Object} ScLoanError\n * @property {boolean} isSuccess\n * @property {number} code\n * @property {string} message\n * @property {string} data\n */\n\n/**\n * Setup ScLoans\n *\n * @param {ScLoanConfig} config\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst setup = async (config) => {\n const safeConfig = safeObject(config);\n if(safeConfig.environment === undefined || safeConfig.environment === null) safeConfig.environment = ENV.PROD\n\n return SmallcaseGatewayNative.setupLoans(safeConfig);\n };\n\n/**\n * Triggers the LOS Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst apply = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.apply(safeLoanInfo);\n };\n\n/**\n * Triggers the Repayment Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst pay = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.pay(safeLoanInfo);\n };\n\n/**\n * Triggers the Withdraw Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst withdraw = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.withdraw(safeLoanInfo);\n };\n\n/**\n * Triggers the Servicing Journey\n *\n * @param {ScLoanInfo} loanInfo\n * @returns {Promise<ScLoanSuccess>}\n * @throws {ScLoanError}\n */\nconst service = async (loanInfo) => {\n const safeLoanInfo = safeObject(loanInfo);\n\n return SmallcaseGatewayNative.service(safeLoanInfo);\n };\n\nconst ScLoan = {\n setup,\n apply,\n pay,\n withdraw,\n service\n}\n\nexport default ScLoan;\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAC5C,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,GAAG,QAAQ,aAAa;AAEjC,MAAM;EAAEC,gBAAgB,EAAEC;AAAuB,CAAC,GAAGJ,aAAa;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,KAAK,GAAG,MAAOC,MAAM,IAAK;EAC5B,MAAMC,UAAU,GAAGN,UAAU,CAACK,MAAM,CAAC;EACrC,IAAGC,UAAU,CAACC,WAAW,KAAKC,SAAS,IAAIF,UAAU,CAACC,WAAW,KAAK,IAAI,EAAED,UAAU,CAACC,WAAW,GAAGN,GAAG,CAACQ,IAAI;EAE7G,OAAON,sBAAsB,CAACO,UAAU,CAACJ,UAAU,CAAC;AACtD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,KAAK,GAAG,MAAOC,QAAQ,IAAK;EAC9B,MAAMC,YAAY,GAAGb,UAAU,CAACY,QAAQ,CAAC;EAEzC,OAAOT,sBAAsB,CAACQ,KAAK,CAACE,YAAY,CAAC;AACnD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,GAAG,GAAG,MAAOF,QAAQ,IAAK;EAC5B,MAAMC,YAAY,GAAGb,UAAU,CAACY,QAAQ,CAAC;EAEzC,OAAOT,sBAAsB,CAACW,GAAG,CAACD,YAAY,CAAC;AACjD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,QAAQ,GAAG,MAAOH,QAAQ,IAAK;EACjC,MAAMC,YAAY,GAAGb,UAAU,CAACY,QAAQ,CAAC;EAEzC,OAAOT,sBAAsB,CAACY,QAAQ,CAACF,YAAY,CAAC;AACtD,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAG,MAAOJ,QAAQ,IAAK;EAChC,MAAMC,YAAY,GAAGb,UAAU,CAACY,QAAQ,CAAC;EAEzC,OAAOT,sBAAsB,CAACa,OAAO,CAACH,YAAY,CAAC;AACrD,CAAC;AAEH,MAAMI,MAAM,GAAG;EACXb,KAAK;EACLO,KAAK;EACLG,GAAG;EACHC,QAAQ;EACRC;AACJ,CAAC;AAED,eAAeC,MAAM"}
|
package/package.json
CHANGED
package/src/ScLoan.js
CHANGED
|
@@ -11,13 +11,24 @@ const { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;
|
|
|
11
11
|
*
|
|
12
12
|
* @typedef {Object} ScLoanInfo
|
|
13
13
|
* @property {String} interactionToken
|
|
14
|
+
*
|
|
15
|
+
* @typedef {Object} ScLoanSuccess
|
|
16
|
+
* @property {boolean} isSuccess
|
|
17
|
+
* @property {string} data
|
|
18
|
+
*
|
|
19
|
+
* @typedef {Object} ScLoanError
|
|
20
|
+
* @property {boolean} isSuccess
|
|
21
|
+
* @property {number} code
|
|
22
|
+
* @property {string} message
|
|
23
|
+
* @property {string} data
|
|
14
24
|
*/
|
|
15
25
|
|
|
16
26
|
/**
|
|
17
27
|
* Setup ScLoans
|
|
18
28
|
*
|
|
19
29
|
* @param {ScLoanConfig} config
|
|
20
|
-
* @returns {Promise<
|
|
30
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
31
|
+
* @throws {ScLoanError}
|
|
21
32
|
*/
|
|
22
33
|
const setup = async (config) => {
|
|
23
34
|
const safeConfig = safeObject(config);
|
|
@@ -30,7 +41,8 @@ const setup = async (config) => {
|
|
|
30
41
|
* Triggers the LOS Journey
|
|
31
42
|
*
|
|
32
43
|
* @param {ScLoanInfo} loanInfo
|
|
33
|
-
* @returns {Promise<
|
|
44
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
45
|
+
* @throws {ScLoanError}
|
|
34
46
|
*/
|
|
35
47
|
const apply = async (loanInfo) => {
|
|
36
48
|
const safeLoanInfo = safeObject(loanInfo);
|
|
@@ -42,7 +54,8 @@ const apply = async (loanInfo) => {
|
|
|
42
54
|
* Triggers the Repayment Journey
|
|
43
55
|
*
|
|
44
56
|
* @param {ScLoanInfo} loanInfo
|
|
45
|
-
* @returns {Promise<
|
|
57
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
58
|
+
* @throws {ScLoanError}
|
|
46
59
|
*/
|
|
47
60
|
const pay = async (loanInfo) => {
|
|
48
61
|
const safeLoanInfo = safeObject(loanInfo);
|
|
@@ -54,7 +67,8 @@ const pay = async (loanInfo) => {
|
|
|
54
67
|
* Triggers the Withdraw Journey
|
|
55
68
|
*
|
|
56
69
|
* @param {ScLoanInfo} loanInfo
|
|
57
|
-
* @returns {Promise<
|
|
70
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
71
|
+
* @throws {ScLoanError}
|
|
58
72
|
*/
|
|
59
73
|
const withdraw = async (loanInfo) => {
|
|
60
74
|
const safeLoanInfo = safeObject(loanInfo);
|
|
@@ -66,7 +80,8 @@ const withdraw = async (loanInfo) => {
|
|
|
66
80
|
* Triggers the Servicing Journey
|
|
67
81
|
*
|
|
68
82
|
* @param {ScLoanInfo} loanInfo
|
|
69
|
-
* @returns {Promise<
|
|
83
|
+
* @returns {Promise<ScLoanSuccess>}
|
|
84
|
+
* @throws {ScLoanError}
|
|
70
85
|
*/
|
|
71
86
|
const service = async (loanInfo) => {
|
|
72
87
|
const safeLoanInfo = safeObject(loanInfo);
|