react-native-smallcase-gateway 0.10.0 → 1.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 +7 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/smallcase/gateway/reactnative/SmallcaseGatewayModule.kt +30 -4
- package/ios/SmallcaseGateway.m +50 -0
- package/package.json +3 -3
- package/react-native-smallcase-gateway.podspec +1 -1
- package/src/SmallcaseGateway.js +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.0](https://github.com/smallcase/react-native-smallcase-gateway/compare/v0.10.0...v1.0.0) (2022-01-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* integrated smallcase module ([f17cd4c](https://github.com/smallcase/react-native-smallcase-gateway/commit/f17cd4caed3881f51393b544ce376e91baec8b2f))
|
|
11
|
+
|
|
5
12
|
## [0.10.0](https://gitlab.com/scGatewayOS/react-native-smallcase-gateway/compare/v0.9.0...v0.10.0) (2022-01-07)
|
|
6
13
|
|
|
7
14
|
## [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
|
|
@@ -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
|
|
|
@@ -135,6 +133,25 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext?) : ReactCont
|
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
|
|
136
|
+
@ReactMethod
|
|
137
|
+
fun launchSmallplug(targetEndpoint: String, params: String, promise: Promise) {
|
|
138
|
+
Log.d(TAG, "launchSmallplug: start")
|
|
139
|
+
|
|
140
|
+
SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
|
|
141
|
+
override fun onFailure(errorCode: Int, errorMessage: String) {
|
|
142
|
+
val err = createErrorJSON(errorCode, errorMessage)
|
|
143
|
+
|
|
144
|
+
promise.reject("error", err)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
override fun onSuccess(smallPlugResult: SmallPlugResult) {
|
|
148
|
+
val res = resultToWritableMap(smallPlugResult)
|
|
149
|
+
promise.resolve(res)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
138
155
|
@ReactMethod
|
|
139
156
|
fun archiveSmallcase(iscid: String, promise: Promise) {
|
|
140
157
|
Log.d(TAG, "markSmallcaseArchive: start")
|
|
@@ -249,6 +266,15 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext?) : ReactCont
|
|
|
249
266
|
return writableMap
|
|
250
267
|
}
|
|
251
268
|
|
|
269
|
+
private fun resultToWritableMap(result: SmallPlugResult): WritableMap {
|
|
270
|
+
val writableMap: WritableMap = Arguments.createMap()
|
|
271
|
+
|
|
272
|
+
writableMap.putBoolean("success", result.success)
|
|
273
|
+
writableMap.putString("smallcaseAuthToken", result.smallcaseAuthToken)
|
|
274
|
+
|
|
275
|
+
return writableMap
|
|
276
|
+
}
|
|
277
|
+
|
|
252
278
|
private fun createErrorJSON(errorCode: Int?, errorMessage: String?): WritableMap {
|
|
253
279
|
val errObj = Arguments.createMap()
|
|
254
280
|
|
package/ios/SmallcaseGateway.m
CHANGED
|
@@ -238,6 +238,56 @@ RCT_REMAP_METHOD(triggerTransaction,
|
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
RCT_REMAP_METHOD(launchSmallplug,
|
|
242
|
+
targetEndpoint:(NSString *)targetEndpoint
|
|
243
|
+
params:(NSString *)params
|
|
244
|
+
launchSmallplugWithResolver:(RCTPromiseResolveBlock)resolve
|
|
245
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
246
|
+
{
|
|
247
|
+
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
|
248
|
+
|
|
249
|
+
SmallplugData *smallplugData = [[SmallplugData alloc] init:targetEndpoint :params];
|
|
250
|
+
|
|
251
|
+
[SCGateway.shared launchSmallPlugWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] smallplugData:smallplugData completion:^(id smallplugResponse, NSError * error) {
|
|
252
|
+
|
|
253
|
+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
|
|
254
|
+
|
|
255
|
+
if (error != nil) {
|
|
256
|
+
NSLog(@"%@", error.domain);
|
|
257
|
+
double delayInSeconds = 0.5;
|
|
258
|
+
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
|
259
|
+
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
|
260
|
+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
|
|
261
|
+
[responseDict setValue:[NSNumber numberWithBool:false] forKey:@"success"];
|
|
262
|
+
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
|
|
263
|
+
[responseDict setValue:error.domain forKey:@"error"];
|
|
264
|
+
|
|
265
|
+
resolve(responseDict);
|
|
266
|
+
return;
|
|
267
|
+
});
|
|
268
|
+
} else {
|
|
269
|
+
|
|
270
|
+
if ([smallplugResponse isKindOfClass: [NSString class]]) {
|
|
271
|
+
NSLog(@"%@", smallplugResponse);
|
|
272
|
+
|
|
273
|
+
[responseDict setValue:[NSNumber numberWithBool: true] forKey:@"success"];
|
|
274
|
+
[responseDict setValue:smallplugResponse forKey:@"smallcaseAuthToken"];
|
|
275
|
+
|
|
276
|
+
double delayInSeconds = 0.5;
|
|
277
|
+
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
|
278
|
+
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
|
279
|
+
|
|
280
|
+
resolve(responseDict);
|
|
281
|
+
return;
|
|
282
|
+
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
}];
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
241
291
|
RCT_REMAP_METHOD(logoutUser,
|
|
242
292
|
logoutUserWithResolver:(RCTPromiseResolveBlock)resolve
|
|
243
293
|
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.0",
|
|
5
5
|
"description": "smallcase gateway bindings for react native",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://
|
|
26
|
-
"baseUrl": "https://
|
|
25
|
+
"url": "git+https://github.com/smallcase/react-native-smallcase-gateway.git",
|
|
26
|
+
"baseUrl": "https://github.com/smallcase/react-native-smallcase-gateway.git"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [
|
|
29
29
|
"react-native"
|
package/src/SmallcaseGateway.js
CHANGED
|
@@ -95,6 +95,23 @@ const triggerTransaction = async (transactionId, utmParams, brokerList) => {
|
|
|
95
95
|
);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* launches smallcases module
|
|
100
|
+
*
|
|
101
|
+
* @param {string} targetEndpoint
|
|
102
|
+
* @param {string} params
|
|
103
|
+
*/
|
|
104
|
+
const launchSmallplug = async (targetEndpoint, params) => {
|
|
105
|
+
const safeEndpoint = safeObject(targetEndpoint);
|
|
106
|
+
const safeParams = safeObject(params);
|
|
107
|
+
|
|
108
|
+
return SmallcaseGatewayNative.launchSmallplug(
|
|
109
|
+
targetEndpoint,
|
|
110
|
+
params
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
98
115
|
/**
|
|
99
116
|
* Logs the user out and removes the web session.
|
|
100
117
|
*
|
|
@@ -164,6 +181,7 @@ const SmallcaseGateway = {
|
|
|
164
181
|
archiveSmallcase,
|
|
165
182
|
triggerTransaction,
|
|
166
183
|
setConfigEnvironment,
|
|
184
|
+
launchSmallplug
|
|
167
185
|
};
|
|
168
186
|
|
|
169
187
|
export default SmallcaseGateway;
|