react-native-hyperkyc-sdk 0.1.3-alpha → 0.1.6-alpha2
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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativehyperkycsdk/HyperkycConstants.java +8 -0
- package/android/src/main/java/com/reactnativehyperkycsdk/HyperkycSdkModule.java +84 -72
- package/ios/.DS_Store +0 -0
- package/ios/HyperkycSdk.m +1 -1
- package/ios/HyperkycSdk.swift +186 -137
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -57,7 +57,7 @@ dependencies {
|
|
|
57
57
|
//noinspection GradleDynamicVersion
|
|
58
58
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
59
59
|
|
|
60
|
-
implementation('co.hyperverge:hyperkyc:0.0.1-
|
|
60
|
+
implementation('co.hyperverge:hyperkyc:0.0.1-alpha02@aar', {
|
|
61
61
|
transitive = true
|
|
62
62
|
})
|
|
63
63
|
}
|
|
@@ -25,7 +25,8 @@ import java.util.ArrayList;
|
|
|
25
25
|
import java.util.List;
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
import co.hyperverge.hyperkyc.
|
|
28
|
+
import co.hyperverge.hyperkyc.HyperKyc;
|
|
29
|
+
import co.hyperverge.hyperkyc.data.models.DocFlowConfig;
|
|
29
30
|
import co.hyperverge.hyperkyc.data.models.HyperKycConfig;
|
|
30
31
|
import co.hyperverge.hyperkyc.data.models.HyperKycData;
|
|
31
32
|
import co.hyperverge.hyperkyc.data.models.HyperKycFlow;
|
|
@@ -34,7 +35,7 @@ import co.hyperverge.hyperkyc.data.models.HyperKycResult;
|
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
public class HyperkycSdkModule extends ReactContextBaseJavaModule implements ActivityEventListener {
|
|
37
|
-
public static final String NAME = "
|
|
38
|
+
public static final String NAME = "Hyperkyc";
|
|
38
39
|
|
|
39
40
|
private final ReactApplicationContext reactContext;
|
|
40
41
|
|
|
@@ -58,95 +59,106 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
ReadableArray array = kycConfig.getArray("workflow");
|
|
62
|
+
@ReactMethod
|
|
63
|
+
public void launch(ReadableMap kycConfig, Callback resultCallback ){
|
|
64
|
+
callback = resultCallback;
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
ReactActivity currentActivity = (ReactActivity)getCurrentActivity();
|
|
67
|
+
List<HyperKycFlow> workflow = processWorkFlow(kycConfig.getString("workflow"));
|
|
68
|
+
String appId = kycConfig.hasKey("appId") ? kycConfig.getString("appId") : null;
|
|
69
|
+
String appKey = kycConfig.hasKey("appKey") ? kycConfig.getString("appKey") : null;
|
|
70
|
+
String transactionId = kycConfig.hasKey("transactionId") ? kycConfig.getString("transactionId") : null;
|
|
71
|
+
String defaultCountryId = kycConfig.hasKey("defaultCountryId") ? kycConfig.getString("defaultCountryId"): null;
|
|
72
|
+
String accessToken = kycConfig.hasKey("accessToken")? kycConfig.getString("accessToken") : null;
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
HyperKycConfig config = null;
|
|
75
|
+
if(accessToken != null){
|
|
76
|
+
config = new HyperKycConfig(accessToken, workflow, transactionId, defaultCountryId );
|
|
77
|
+
}else if(appId != null && appKey != null) {
|
|
70
78
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
config = new HyperKycConfig(appId, appKey, workflow, transactionId, defaultCountryId);
|
|
80
|
+
}
|
|
81
|
+
contract = new HyperKyc.Contract();
|
|
82
|
+
Intent newIntent = contract.createIntent(currentActivity, config);
|
|
83
|
+
if(currentActivity != null)
|
|
84
|
+
currentActivity.startActivityIfNeeded(newIntent, HYPERKYC_REQUEST_CODE);
|
|
75
85
|
|
|
76
|
-
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Override
|
|
89
|
+
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
90
|
+
if(requestCode == HYPERKYC_REQUEST_CODE){
|
|
91
|
+
|
|
92
|
+
HyperKycResult hyperKycResult = contract.parseResult(resultCode, data);
|
|
93
|
+
result = new WritableNativeMap();
|
|
94
|
+
parseKYCResult(hyperKycResult);
|
|
95
|
+
}
|
|
77
96
|
|
|
78
|
-
@Override
|
|
79
|
-
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
80
|
-
if (requestCode == HYPERKYC_REQUEST_CODE) {
|
|
81
97
|
|
|
82
|
-
HyperKycResult hyperKycResult = contract.parseResult(resultCode, data);
|
|
83
|
-
result = new WritableNativeMap();
|
|
84
|
-
parseKYCResult(hyperKycResult);
|
|
85
98
|
}
|
|
86
99
|
|
|
100
|
+
private void parseKYCResult(HyperKycResult hyperKycResult){
|
|
87
101
|
|
|
88
|
-
|
|
102
|
+
String errorMessage="";
|
|
103
|
+
HyperKycData hyperKycData = hyperKycResult.getData();
|
|
104
|
+
WritableMap resultMap = new WritableNativeMap();
|
|
105
|
+
resultMap.putString("result", hyperKycResult.getStatus().toString());
|
|
106
|
+
resultMap.putString("errorMessage", errorMessage);
|
|
107
|
+
try {
|
|
108
|
+
if (hyperKycData != null) {
|
|
89
109
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
gson = new Gson();
|
|
98
|
-
String resultJSON = gson.toJson(hyperKycData);
|
|
99
|
-
JSONObject result = new JSONObject(resultJSON);
|
|
100
|
-
result.remove("config");
|
|
101
|
-
resultMap = HyperkycSdkUtils.convertJsonToMap(result);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
String type = "";
|
|
105
|
-
String errorMessage = "";
|
|
106
|
-
if (hyperKycResult instanceof HyperKycResult.Success) {
|
|
107
|
-
type = "success";
|
|
108
|
-
}
|
|
109
|
-
if (hyperKycResult instanceof HyperKycResult.Failure) {
|
|
110
|
-
type = "failure";
|
|
111
|
-
errorMessage = ((HyperKycResult.Failure) hyperKycResult).getReason();
|
|
112
|
-
}
|
|
113
|
-
if (hyperKycResult instanceof HyperKycResult.Cancelled) {
|
|
114
|
-
type = "cancelled";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
resultMap.putString("result", type);
|
|
118
|
-
resultMap.putString("errorMessage", errorMessage);
|
|
119
|
-
callback.invoke(resultMap);
|
|
120
|
-
} catch (Exception e) {
|
|
110
|
+
gson = new Gson();
|
|
111
|
+
String resultJSON = gson.toJson(hyperKycData);
|
|
112
|
+
JSONObject result = new JSONObject(resultJSON);
|
|
113
|
+
result.remove("config");
|
|
114
|
+
WritableMap hyperKycDataMap = RNHyperKYCUtils.convertJsonToMap(result);
|
|
115
|
+
resultMap.putMap("hyperKycData", hyperKycDataMap);
|
|
116
|
+
}
|
|
121
117
|
|
|
122
|
-
}
|
|
123
118
|
|
|
124
|
-
}
|
|
125
119
|
|
|
126
120
|
|
|
127
|
-
private List<HyperKycFlow> processWorkFlow(ArrayList<Object> kycFlows) {
|
|
128
|
-
List<HyperKycFlow> workflows = new ArrayList<HyperKycFlow>();
|
|
129
121
|
|
|
130
|
-
for (Object flow : kycFlows) {
|
|
131
|
-
if (flow instanceof String) {
|
|
132
|
-
String flowStr = (String) flow;
|
|
133
|
-
switch (flowStr) {
|
|
134
|
-
case "document":
|
|
135
|
-
workflows.add(HyperKycFlow.DOCUMENT);
|
|
136
122
|
|
|
137
|
-
|
|
138
|
-
|
|
123
|
+
callback.invoke(resultMap);
|
|
124
|
+
}catch (Exception e){
|
|
139
125
|
|
|
140
126
|
}
|
|
141
|
-
|
|
127
|
+
|
|
142
128
|
}
|
|
143
|
-
return workflows;
|
|
144
|
-
}
|
|
145
129
|
|
|
146
|
-
@Override
|
|
147
|
-
public void onNewIntent(Intent intent) {
|
|
148
|
-
|
|
149
|
-
}
|
|
150
130
|
|
|
131
|
+
private List<HyperKycFlow> processWorkFlow(String workflowArray){
|
|
132
|
+
List<HyperKycFlow> workflows = new ArrayList<>();
|
|
133
|
+
try {
|
|
134
|
+
JSONArray kycFlows = null;
|
|
135
|
+
|
|
136
|
+
kycFlows = new JSONArray(workflowArray);
|
|
137
|
+
|
|
138
|
+
for(int i = 0; i < kycFlows.length(); i++){
|
|
139
|
+
JSONObject kycFlow = kycFlows.getJSONObject(i);
|
|
140
|
+
if(kycFlow.has("type")){
|
|
141
|
+
String flowStr = kycFlow.getString("type");
|
|
142
|
+
switch (flowStr) {
|
|
143
|
+
case "document":
|
|
144
|
+
String countryId = kycFlow.has(RNHyperKYCConstants.COUNTRY_ID) ? kycFlow.getString(RNHyperKYCConstants.COUNTRY_ID): null;
|
|
145
|
+
String documentId = kycFlow.has(RNHyperKYCConstants.DOCUMENT_ID) ? kycFlow.getString(RNHyperKYCConstants.DOCUMENT_ID): null;
|
|
146
|
+
boolean useForFaceMatch = kycFlow.has(RNHyperKYCConstants.USE_FOR_FACE_MATCH)? kycFlow.getBoolean(RNHyperKYCConstants.USE_FOR_FACE_MATCH): false;
|
|
147
|
+
|
|
148
|
+
workflows.add(new HyperKycFlow.Document(new DocFlowConfig(useForFaceMatch, countryId, documentId )));
|
|
149
|
+
case "face":
|
|
150
|
+
workflows.add(new HyperKycFlow.Face());
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (Exception e) {
|
|
156
|
+
e.printStackTrace();
|
|
157
|
+
}
|
|
158
|
+
return workflows;
|
|
159
|
+
}
|
|
160
|
+
@Override
|
|
161
|
+
public void onNewIntent(Intent intent) {
|
|
151
162
|
|
|
152
|
-
}
|
|
163
|
+
}
|
|
164
|
+
}
|
package/ios/.DS_Store
CHANGED
|
Binary file
|
package/ios/HyperkycSdk.m
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
3
|
#import <React/RCTUtils.h>
|
|
4
4
|
|
|
5
|
-
@interface RCT_EXTERN_MODULE(
|
|
5
|
+
@interface RCT_EXTERN_MODULE(Hyperkyc, NSObject)
|
|
6
6
|
RCT_EXTERN_METHOD(launch: (NSDictionary*)config callback:(RCTResponseSenderBlock)callback)
|
|
7
7
|
|
|
8
8
|
+ (BOOL) requiresMainQueueSetup {
|
package/ios/HyperkycSdk.swift
CHANGED
|
@@ -3,171 +3,220 @@
|
|
|
3
3
|
import Foundation
|
|
4
4
|
import HyperKYC
|
|
5
5
|
|
|
6
|
-
@objc(
|
|
7
|
-
class
|
|
8
|
-
|
|
6
|
+
@objc(Hyperkyc)
|
|
7
|
+
class Hyperkyc: NSObject {
|
|
8
|
+
@objc static func requiresMainQueueSetup() -> Bool {return true}
|
|
9
9
|
|
|
10
|
-
@objc
|
|
11
|
-
func
|
|
10
|
+
@objc(launch:callback:)
|
|
11
|
+
func launch(_config: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
|
|
12
12
|
let appId = _config["appId"] as? String
|
|
13
13
|
let transactionId = _config["transactionId"] as? String
|
|
14
|
+
let appKey = _config["appKey"] as? String
|
|
14
15
|
let accessToken = _config["accessToken"] as? String
|
|
15
|
-
let kycFlow = _config["workflow"] as?
|
|
16
|
+
let kycFlow = _config["workflow"] as? String
|
|
17
|
+
let defaultCountryId = _config["defaultCountryId"] as? String ?? nil
|
|
16
18
|
|
|
17
|
-
let
|
|
19
|
+
let hyperKycWorkflows = processKYCFlowStates(flows: kycFlow!)
|
|
18
20
|
DispatchQueue.main.async {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let hyperKYCConfig = HyperKycConfig(appId: appId!, accessToken: accessToken!, workFlow: workFlow,transactionId: transactionId!)
|
|
22
|
-
HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
|
|
23
|
-
// process the result hereDand send it back to JS
|
|
21
|
+
let controller = RCTPresentedViewController()
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if let accessTokenConfig = accessToken{
|
|
24
|
+
let hyperKYCConfig = HyperKycConfig(accessToken: accessTokenConfig, workFlow: hyperKycWorkflows, transactionId: transactionId!, defaultCountryId: defaultCountryId)
|
|
25
|
+
HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if(appKey != nil && appId != nil){
|
|
31
|
+
let hyperKYCConfig = HyperKycConfig(appId: appId!, appKey: appKey!, workFlow: hyperKycWorkflows, transactionId: transactionId!, defaultCountryId: defaultCountryId)
|
|
32
|
+
|
|
33
|
+
HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
|
|
34
|
+
|
|
35
|
+
let result = self.processHyperKycResult(hyperKycResult: hyperKycResult)
|
|
36
|
+
callback( [result])
|
|
37
|
+
}
|
|
38
|
+
}
|
|
27
39
|
|
|
28
40
|
}
|
|
29
|
-
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
func processHyperKycResult(hyperKycResult: HyperKycResult) -> [String : Any] {
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if let document = hyperKycData.selectedDocument {
|
|
51
|
-
kycData["selectedDocument"] = document
|
|
52
|
-
}
|
|
53
|
-
// MARK: Add docData to kycData
|
|
48
|
+
let resultEnum = hyperKycResult.result! as KYCResult
|
|
49
|
+
var resultEnumString = ""
|
|
50
|
+
var kycData = [
|
|
51
|
+
"selectedCountryId" : "",
|
|
52
|
+
|
|
53
|
+
] as [String: Any]
|
|
54
|
+
var errorMessage = ""
|
|
55
|
+
|
|
56
|
+
resultEnumString = String(describing: resultEnum)
|
|
57
|
+
|
|
58
|
+
if let hyperKycData = hyperKycResult.hyperKYCData {
|
|
59
|
+
if let country = hyperKycData.selectedCountry {
|
|
60
|
+
kycData["selectedCountryId"] = country
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var docResultList : [[String: Any]] = []
|
|
65
|
+
for docResult in hyperKycData.docResultList{
|
|
66
|
+
|
|
54
67
|
var docDataList: [[String: Any]] = []
|
|
55
|
-
|
|
68
|
+
|
|
69
|
+
for docData in docResult.docDataList {
|
|
56
70
|
var docDataDictionary = [
|
|
57
71
|
"side" : docData.side,
|
|
58
72
|
"docImagePath" : docData.docImagePath,
|
|
59
73
|
"action" : docData.action,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
docDataDictionary["responseHeaders"] = String(data: headersData, encoding: String.Encoding.utf8)
|
|
65
|
-
}catch let parseError{
|
|
66
|
-
print("JSON Error DocData ResponseHeaders : \(parseError.localizedDescription)")
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
docDataDictionary["responseHeaders"] = "{}"
|
|
74
|
+
|
|
75
|
+
] as [String: Any]
|
|
76
|
+
if let responseHeaders = docData.responseHeaders {
|
|
77
|
+
docDataDictionary["responseHeaders"] = responseHeaders
|
|
70
78
|
}
|
|
71
79
|
if let responseResult = docData.responseResult {
|
|
72
|
-
|
|
73
|
-
let docDataResponseResult = try encoder.encode(responseResult)
|
|
74
|
-
docDataDictionary["responseResult"] = String(data: docDataResponseResult, encoding: .utf8)!
|
|
75
|
-
} catch let parseError {
|
|
76
|
-
print("JSON Error DocData ResponseResult : \(parseError.localizedDescription)")
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
docDataDictionary["responseResult"] = "{}"
|
|
80
|
+
docDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: responseResult, faceDataResponseResult: nil, faceMatchDataResponseResult: nil )
|
|
80
81
|
}
|
|
81
82
|
docDataList.append(docDataDictionary as [String : Any])
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
print("JSON Error FaceData ResponseResult : \(parseError.localizedDescription)")
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
faceDataDictionary["responseResult"] = "{}"
|
|
111
|
-
}
|
|
112
|
-
kycData["faceData"] = faceDataDictionary
|
|
84
|
+
var docResultDictionary = [
|
|
85
|
+
"tag" : docResult.tag,
|
|
86
|
+
"documentId": docResult.documentId,
|
|
87
|
+
"docDataList": docDataList
|
|
88
|
+
] as [String : Any]
|
|
89
|
+
|
|
90
|
+
docResultList.append(docResultDictionary as [String: Any])
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
kycData["docResultList"] = docResultList
|
|
94
|
+
|
|
95
|
+
// Process face data
|
|
96
|
+
if let faceData = hyperKycData.faceData {
|
|
97
|
+
var faceDataDictionary = [
|
|
98
|
+
"croppedFaceImagePath" : faceData.croppedFaceImagePath,
|
|
99
|
+
"fullFaceImagePath" : faceData.fullFaceImagePath,
|
|
100
|
+
"videoPath" : faceData.videoPath,
|
|
101
|
+
"action" : faceData.action,
|
|
102
|
+
] as [String:Any]
|
|
103
|
+
if let responseHeaders = faceData.responseHeaders {
|
|
104
|
+
faceDataDictionary["responseHeaders"] = responseHeaders
|
|
105
|
+
}
|
|
106
|
+
if let responseResult = faceData.responseResult {
|
|
107
|
+
faceDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: nil, faceDataResponseResult: responseResult, faceMatchDataResponseResult: nil )
|
|
113
108
|
}
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
kycData["faceData"] = faceDataDictionary
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//Process face match data
|
|
116
|
+
var faceMatchDataResultList : [[String: Any]] = []
|
|
117
|
+
for faceMatchDataResult in hyperKycData.faceMatchDataResultList{
|
|
118
|
+
|
|
116
119
|
var faceMatchDataDictionary = [
|
|
117
|
-
"action" :
|
|
118
|
-
]
|
|
119
|
-
if let responseHeaders =
|
|
120
|
-
|
|
121
|
-
let headersData = try JSONSerialization.data(withJSONObject: responseHeaders , options: JSONSerialization.WritingOptions.prettyPrinted)
|
|
122
|
-
faceMatchDataDictionary["responseHeaders"] = String(data: headersData, encoding: String.Encoding.utf8)
|
|
123
|
-
}catch let parseError{
|
|
124
|
-
print("JSON Error FaceMatchData ResponseHeaders : \(parseError.localizedDescription)")
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
faceMatchDataDictionary["responseHeaders"] = "{}"
|
|
120
|
+
"action" : faceMatchDataResult.facematchData.action,
|
|
121
|
+
] as [String:Any]
|
|
122
|
+
if let responseHeaders = faceMatchDataResult.facematchData.responseHeaders {
|
|
123
|
+
faceMatchDataDictionary["responseHeaders"] = responseHeaders
|
|
128
124
|
}
|
|
129
|
-
if let responseResult =
|
|
130
|
-
|
|
131
|
-
let faceMatchDataResponseResult = try encoder.encode(responseResult)
|
|
132
|
-
faceMatchDataDictionary["responseResult"] = String(data: faceMatchDataResponseResult, encoding: .utf8)!
|
|
133
|
-
} catch let parseError {
|
|
134
|
-
print("JSON Error FaceMatchData ResponseResult : \(parseError.localizedDescription)")
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
faceMatchDataDictionary["responseResult"] = "{}"
|
|
125
|
+
if let responseResult = faceMatchDataResult.facematchData.responseResult {
|
|
126
|
+
faceMatchDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: nil, faceDataResponseResult: nil, faceMatchDataResponseResult: responseResult)
|
|
138
127
|
}
|
|
139
|
-
|
|
128
|
+
var faceMatchResultDictionary = [
|
|
129
|
+
"tag": faceMatchDataResult.tag,
|
|
130
|
+
"documentId":faceMatchDataResult.documentId,
|
|
131
|
+
"faceMatchData":faceMatchDataDictionary
|
|
132
|
+
] as [String: Any]
|
|
133
|
+
faceMatchDataResultList.append(faceMatchResultDictionary)
|
|
140
134
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
135
|
+
|
|
136
|
+
kycData["faceMatchDataResultList"] = faceMatchDataResultList
|
|
137
|
+
|
|
138
|
+
if let errorMsg = hyperKycResult.errorMessage {
|
|
139
|
+
errorMessage = errorMsg
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let resultMap = [
|
|
143
|
+
"result" : resultEnumString,
|
|
144
|
+
"hyperKycData" : kycData,
|
|
145
|
+
"errorMessage" : errorMessage,
|
|
146
|
+
] as [String : Any]
|
|
147
|
+
return resultMap
|
|
148
|
+
|
|
149
|
+
|
|
154
150
|
|
|
155
|
-
func processKYCFlowStates(flows : [String]) -> [HyperKycFlow]{
|
|
156
|
-
var workflows = [HyperKycFlow]()
|
|
157
|
-
flows.forEach { flow in
|
|
158
|
-
switch (flow){
|
|
159
|
-
case "document":
|
|
160
|
-
workflows.append(.document)
|
|
161
|
-
case "face":
|
|
162
|
-
workflows.append(.face)
|
|
163
|
-
default:
|
|
164
|
-
break
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
151
|
}
|
|
169
|
-
return
|
|
152
|
+
return [:]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
//
|
|
157
|
+
func getResponseResultJsonString(docDataResponseResult: DocCaptureApiDetail?, faceDataResponseResult: FaceCaptureApiDetail?, faceMatchDataResponseResult: FaceMatchApiDetail?) -> [String:Any] {
|
|
158
|
+
let encoder = JSONEncoder()
|
|
159
|
+
|
|
160
|
+
do {
|
|
161
|
+
if let responseResult = docDataResponseResult {
|
|
162
|
+
let responseResultData = try encoder.encode(responseResult)
|
|
163
|
+
return try JSONSerialization.jsonObject(with: responseResultData, options: []) as? [String:Any] ?? [:]
|
|
164
|
+
} else if let responseResult = faceDataResponseResult {
|
|
165
|
+
let responseResultData = try encoder.encode(responseResult)
|
|
166
|
+
return try JSONSerialization.jsonObject(with: responseResultData, options: []) as? [String:Any] ?? [:]
|
|
167
|
+
} else if let responseResult = faceMatchDataResponseResult {
|
|
168
|
+
let responseResultData = try encoder.encode(responseResult)
|
|
169
|
+
return try JSONSerialization.jsonObject(with: responseResultData, options: []) as? [String:Any] ?? [:]
|
|
170
|
+
} else {
|
|
171
|
+
return [:]
|
|
170
172
|
}
|
|
173
|
+
} catch let parseError {
|
|
174
|
+
print("JSON Error DocData ResponseResult : \(parseError.localizedDescription)")
|
|
175
|
+
return [:]
|
|
171
176
|
}
|
|
177
|
+
return [:]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
func processKYCFlowStates(flows : String) -> [HyperKycFlow] {
|
|
183
|
+
var hyperKycFlows = [HyperKycFlow]()
|
|
184
|
+
let workflows = convertToDictionary(json: flows)
|
|
172
185
|
|
|
186
|
+
workflows?.forEach({ (value: Any) in
|
|
187
|
+
let valueObj = (value as! [String:Any])
|
|
188
|
+
switch(valueObj["type"] as! String){
|
|
189
|
+
case "document":
|
|
190
|
+
let useForFaceMatch = valueObj["useForFaceMatch"] as? Bool ?? false
|
|
191
|
+
let countryId = valueObj["countryId"] as? String ?? nil
|
|
192
|
+
let documentId = valueObj["documentId"] as? String ?? nil
|
|
193
|
+
hyperKycFlows.append(HyperKycFlow.document(config: DocFlowConfig(useForFaceMatch: useForFaceMatch, countryId: countryId, documentId: documentId)))
|
|
194
|
+
case "face":
|
|
195
|
+
hyperKycFlows.append(HyperKycFlow.face())
|
|
196
|
+
default:
|
|
197
|
+
print("Case not handled")
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
return hyperKycFlows
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
func convertToDictionary(json: String) -> [Any]? {
|
|
206
|
+
if let data = json.data(using: .utf8) {
|
|
207
|
+
do {
|
|
208
|
+
return try JSONSerialization.jsonObject(with: data, options: []) as? [Any]
|
|
209
|
+
} catch {
|
|
210
|
+
print(error.localizedDescription)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return nil
|
|
173
214
|
}
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|