react-native-smallcase-gateway 0.10.0 → 1.0.2
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 +16 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/smallcase/gateway/reactnative/SmallcaseGatewayModule.kt +36 -4
- package/ios/SmallcaseGateway.m +55 -2
- package/package.json +3 -4
- package/react-native-smallcase-gateway.podspec +1 -1
- package/src/SmallcaseGateway.js +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
### [1.0.2](https://github.com/smallcase/react-native-smallcase-gateway/compare/v1.0.0...v1.0.2) (2022-04-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* log SDK version with transactionId ([8b833b3](https://github.com/smallcase/react-native-smallcase-gateway/commit/8b833b366c0b8f9a030f920134d82c0f84fa6c7f))
|
|
11
|
+
|
|
12
|
+
### [1.0.1](https://github.com/smallcase/react-native-smallcase-gateway/compare/v1.0.0...v1.0.1) (2022-03-15)
|
|
13
|
+
|
|
14
|
+
## [1.0.0](https://github.com/smallcase/react-native-smallcase-gateway/compare/v0.10.0...v1.0.0) (2022-01-21)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* integrated smallcase module ([f17cd4c](https://github.com/smallcase/react-native-smallcase-gateway/commit/f17cd4caed3881f51393b544ce376e91baec8b2f))
|
|
20
|
+
|
|
5
21
|
## [0.10.0](https://gitlab.com/scGatewayOS/react-native-smallcase-gateway/compare/v0.9.0...v0.10.0) (2022-01-07)
|
|
6
22
|
|
|
7
23
|
## [0.9.0](https://gitlab.com/scGatewayOS/react-native-smallcase-gateway/compare/v0.8.0...v0.9.0) (2022-01-03)
|
package/android/build.gradle
CHANGED
|
@@ -49,8 +49,8 @@ android {
|
|
|
49
49
|
defaultConfig {
|
|
50
50
|
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
51
51
|
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
52
|
-
versionCode
|
|
53
|
-
versionName "
|
|
52
|
+
versionCode 01
|
|
53
|
+
versionName "0.0.1"
|
|
54
54
|
}
|
|
55
55
|
lintOptions {
|
|
56
56
|
abortOnError false
|
|
@@ -82,7 +82,7 @@ repositories {
|
|
|
82
82
|
dependencies {
|
|
83
83
|
//noinspection GradleDynamicVersion
|
|
84
84
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
85
|
-
implementation 'com.smallcase.gateway:sdk:3.1.
|
|
85
|
+
implementation 'com.smallcase.gateway:sdk:3.1.21'
|
|
86
86
|
implementation "androidx.core:core-ktx:1.3.1"
|
|
87
87
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
88
88
|
}
|
|
@@ -8,11 +8,9 @@ import com.facebook.react.bridge.*
|
|
|
8
8
|
import com.smallcase.gateway.data.SmallcaseGatewayListeners
|
|
9
9
|
import com.smallcase.gateway.data.SmallcaseLogoutListener
|
|
10
10
|
import com.smallcase.gateway.data.listeners.DataListener
|
|
11
|
+
import com.smallcase.gateway.data.listeners.SmallPlugResponseListener
|
|
11
12
|
import com.smallcase.gateway.data.listeners.TransactionResponseListener
|
|
12
|
-
import com.smallcase.gateway.data.models
|
|
13
|
-
import com.smallcase.gateway.data.models.InitialisationResponse
|
|
14
|
-
import com.smallcase.gateway.data.models.SmallcaseGatewayDataResponse
|
|
15
|
-
import com.smallcase.gateway.data.models.TransactionResult
|
|
13
|
+
import com.smallcase.gateway.data.models.*
|
|
16
14
|
import com.smallcase.gateway.data.requests.InitRequest
|
|
17
15
|
import com.smallcase.gateway.portal.SmallcaseGatewaySdk
|
|
18
16
|
|
|
@@ -71,6 +69,12 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext?) : ReactCont
|
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
|
|
72
|
+
@ReactMethod
|
|
73
|
+
fun setHybridSdkVersion(sdkVersion: String) {
|
|
74
|
+
SmallcaseGatewaySdk.setSDKType("react-native")
|
|
75
|
+
SmallcaseGatewaySdk.setHybridSDKVersion(sdkVersion)
|
|
76
|
+
}
|
|
77
|
+
|
|
74
78
|
@ReactMethod
|
|
75
79
|
fun init(sdkToken: String, promise: Promise) {
|
|
76
80
|
Log.d(TAG, "init: start")
|
|
@@ -135,6 +139,25 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext?) : ReactCont
|
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
|
|
142
|
+
@ReactMethod
|
|
143
|
+
fun launchSmallplug(targetEndpoint: String, params: String, promise: Promise) {
|
|
144
|
+
Log.d(TAG, "launchSmallplug: start")
|
|
145
|
+
|
|
146
|
+
SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
|
|
147
|
+
override fun onFailure(errorCode: Int, errorMessage: String) {
|
|
148
|
+
val err = createErrorJSON(errorCode, errorMessage)
|
|
149
|
+
|
|
150
|
+
promise.reject("error", err)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
override fun onSuccess(smallPlugResult: SmallPlugResult) {
|
|
154
|
+
val res = resultToWritableMap(smallPlugResult)
|
|
155
|
+
promise.resolve(res)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
138
161
|
@ReactMethod
|
|
139
162
|
fun archiveSmallcase(iscid: String, promise: Promise) {
|
|
140
163
|
Log.d(TAG, "markSmallcaseArchive: start")
|
|
@@ -249,6 +272,15 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext?) : ReactCont
|
|
|
249
272
|
return writableMap
|
|
250
273
|
}
|
|
251
274
|
|
|
275
|
+
private fun resultToWritableMap(result: SmallPlugResult): WritableMap {
|
|
276
|
+
val writableMap: WritableMap = Arguments.createMap()
|
|
277
|
+
|
|
278
|
+
writableMap.putBoolean("success", result.success)
|
|
279
|
+
writableMap.putString("smallcaseAuthToken", result.smallcaseAuthToken)
|
|
280
|
+
|
|
281
|
+
return writableMap
|
|
282
|
+
}
|
|
283
|
+
|
|
252
284
|
private fun createErrorJSON(errorCode: Int?, errorMessage: String?): WritableMap {
|
|
253
285
|
val errObj = Arguments.createMap()
|
|
254
286
|
|
package/ios/SmallcaseGateway.m
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
RCT_EXPORT_MODULE()
|
|
10
10
|
|
|
11
|
+
RCT_REMAP_METHOD(setHybridSdkVersion, sdkVersion: (NSString *)sdkVersion) {
|
|
12
|
+
[SCGateway.shared setSDKTypeWithType:@"react-native"];
|
|
13
|
+
[SCGateway.shared setHybridSDKVersionWithVersion:sdkVersion];
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
RCT_REMAP_METHOD(setConfigEnvironment,
|
|
12
17
|
envName:(NSString *)envName
|
|
13
18
|
gateway:(NSString *)gateway
|
|
@@ -75,8 +80,6 @@ RCT_REMAP_METHOD(init,
|
|
|
75
80
|
reject(@"init", @"Error during init", error);
|
|
76
81
|
}
|
|
77
82
|
}];
|
|
78
|
-
|
|
79
|
-
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
RCT_REMAP_METHOD(archiveSmallcase,
|
|
@@ -238,6 +241,56 @@ RCT_REMAP_METHOD(triggerTransaction,
|
|
|
238
241
|
});
|
|
239
242
|
}
|
|
240
243
|
|
|
244
|
+
RCT_REMAP_METHOD(launchSmallplug,
|
|
245
|
+
targetEndpoint:(NSString *)targetEndpoint
|
|
246
|
+
params:(NSString *)params
|
|
247
|
+
launchSmallplugWithResolver:(RCTPromiseResolveBlock)resolve
|
|
248
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
249
|
+
{
|
|
250
|
+
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
|
251
|
+
|
|
252
|
+
SmallplugData *smallplugData = [[SmallplugData alloc] init:targetEndpoint :params];
|
|
253
|
+
|
|
254
|
+
[SCGateway.shared launchSmallPlugWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] smallplugData:smallplugData completion:^(id smallplugResponse, NSError * error) {
|
|
255
|
+
|
|
256
|
+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
|
|
257
|
+
|
|
258
|
+
if (error != nil) {
|
|
259
|
+
NSLog(@"%@", error.domain);
|
|
260
|
+
double delayInSeconds = 0.5;
|
|
261
|
+
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
|
262
|
+
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
|
263
|
+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
|
|
264
|
+
[responseDict setValue:[NSNumber numberWithBool:false] forKey:@"success"];
|
|
265
|
+
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
266
|
+
[responseDict setValue:error.domain forKey:@"error"];
|
|
267
|
+
|
|
268
|
+
resolve(responseDict);
|
|
269
|
+
return;
|
|
270
|
+
});
|
|
271
|
+
} else {
|
|
272
|
+
|
|
273
|
+
if ([smallplugResponse isKindOfClass: [NSString class]]) {
|
|
274
|
+
NSLog(@"%@", smallplugResponse);
|
|
275
|
+
|
|
276
|
+
[responseDict setValue:[NSNumber numberWithBool: true] forKey:@"success"];
|
|
277
|
+
[responseDict setValue:smallplugResponse forKey:@"smallcaseAuthToken"];
|
|
278
|
+
|
|
279
|
+
double delayInSeconds = 0.5;
|
|
280
|
+
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
|
281
|
+
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
|
282
|
+
|
|
283
|
+
resolve(responseDict);
|
|
284
|
+
return;
|
|
285
|
+
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
}];
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
241
294
|
RCT_REMAP_METHOD(logoutUser,
|
|
242
295
|
logoutUserWithResolver:(RCTPromiseResolveBlock)resolve
|
|
243
296
|
rejecter:(RCTPromiseRejectBlock)reject)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-smallcase-gateway",
|
|
3
3
|
"title": "React Native Smallcase Gateway",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "smallcase gateway bindings for react native",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -15,15 +15,14 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"commit": "yarn cz",
|
|
17
17
|
"test": "jest --coverage",
|
|
18
|
-
"postinstall": "sh init-githooks.sh 2>/dev/null || :",
|
|
19
18
|
"release:minor": "standard-version --release-as minor",
|
|
20
19
|
"release:patch": "standard-version --release-as patch",
|
|
21
20
|
"release:major": "standard-version --release-as major"
|
|
22
21
|
},
|
|
23
22
|
"repository": {
|
|
24
23
|
"type": "git",
|
|
25
|
-
"url": "git+https://
|
|
26
|
-
"baseUrl": "https://
|
|
24
|
+
"url": "git+https://github.com/smallcase/react-native-smallcase-gateway.git",
|
|
25
|
+
"baseUrl": "https://github.com/smallcase/react-native-smallcase-gateway.git"
|
|
27
26
|
},
|
|
28
27
|
"keywords": [
|
|
29
28
|
"react-native"
|
package/src/SmallcaseGateway.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NativeModules } from "react-native";
|
|
2
2
|
import { ENV } from "./constants";
|
|
3
3
|
import { safeObject } from "./util";
|
|
4
|
+
import { version } from "../package.json";
|
|
4
5
|
const { SmallcaseGateway: SmallcaseGatewayNative } = NativeModules;
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -34,6 +35,8 @@ let defaultBrokerList = [];
|
|
|
34
35
|
const setConfigEnvironment = async (envConfig) => {
|
|
35
36
|
const safeConfig = safeObject(envConfig);
|
|
36
37
|
|
|
38
|
+
await SmallcaseGatewayNative.setHybridSdkVersion(version);
|
|
39
|
+
|
|
37
40
|
const {
|
|
38
41
|
brokerList,
|
|
39
42
|
gatewayName,
|
|
@@ -95,6 +98,23 @@ const triggerTransaction = async (transactionId, utmParams, brokerList) => {
|
|
|
95
98
|
);
|
|
96
99
|
};
|
|
97
100
|
|
|
101
|
+
/**
|
|
102
|
+
* launches smallcases module
|
|
103
|
+
*
|
|
104
|
+
* @param {string} targetEndpoint
|
|
105
|
+
* @param {string} params
|
|
106
|
+
*/
|
|
107
|
+
const launchSmallplug = async (targetEndpoint, params) => {
|
|
108
|
+
const safeEndpoint = safeObject(targetEndpoint);
|
|
109
|
+
const safeParams = safeObject(params);
|
|
110
|
+
|
|
111
|
+
return SmallcaseGatewayNative.launchSmallplug(
|
|
112
|
+
targetEndpoint,
|
|
113
|
+
params
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
98
118
|
/**
|
|
99
119
|
* Logs the user out and removes the web session.
|
|
100
120
|
*
|
|
@@ -164,6 +184,7 @@ const SmallcaseGateway = {
|
|
|
164
184
|
archiveSmallcase,
|
|
165
185
|
triggerTransaction,
|
|
166
186
|
setConfigEnvironment,
|
|
187
|
+
launchSmallplug
|
|
167
188
|
};
|
|
168
189
|
|
|
169
190
|
export default SmallcaseGateway;
|