@qore-id/react-native-qoreid-sdk 1.2.2 → 1.2.4

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.
@@ -21,7 +21,9 @@ import com.qoreid.sdk.core.QoreIDSdk.QORE_ID_RESULT_EXTRA_KEY
21
21
  import com.qoreid.sdk.core.models.AddressData
22
22
  import com.qoreid.sdk.core.models.ApplicantData
23
23
  import com.qoreid.sdk.core.models.ErrorResult
24
+ import com.qoreid.sdk.core.models.IdentityData
24
25
  import com.qoreid.sdk.core.models.QoreIDResult
26
+ import com.qoreid.sdk.core.models.ResultData
25
27
  import com.qoreid.sdk.core.models.SuccessResult
26
28
  import com.qoreid.sdk.core.models.VerificationExtraData
27
29
 
@@ -110,6 +112,18 @@ class QoreidSdkModule(context: ReactApplicationContext) :
110
112
  )
111
113
  val flowId = config?.get("flowId") as? Double
112
114
 
115
+ val _identityData = data?.get("identityData") as? HashMap<*, *>
116
+
117
+ var identityData: IdentityData? = null
118
+
119
+ if(!_identityData.isNullOrEmpty()){
120
+ identityData = IdentityData(
121
+ _identityData?.get("idType") as String,
122
+ _identityData?.get("idNumber") as String
123
+ )
124
+ }
125
+
126
+
113
127
  val _extraData = data?.get("extraData") as? HashMap<*, *>?
114
128
  var extraData: VerificationExtraData? = null
115
129
 
@@ -122,13 +136,19 @@ class QoreidSdkModule(context: ReactApplicationContext) :
122
136
  )
123
137
  }
124
138
 
139
+ var acceptedDocuments: List<String>? = data?.get("acceptedDocuments") as? List<String>
140
+
141
+ if(acceptedDocuments.isNullOrEmpty()){
142
+ acceptedDocuments = emptyList()
143
+ }
144
+
125
145
  val qoreIDParams =
126
146
  if (flowId?.toLong() != 0L) {
127
147
  QoreIDParams()
128
148
  .clientId(config?.get("clientId") as String)
129
149
  .customerReference(config?.get("customerReference") as String)
130
- .inputData(applicantData, addressData, null, extraData)
131
- .ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
150
+ .inputData(applicantData, addressData, identityData, extraData)
151
+ .ocrAcceptedDocuments(acceptedDocuments)
132
152
  .workflow(flowId!!.toLong())
133
153
  .workflowDefaultIdentity(
134
154
  config?.get("defaultIdType") as
@@ -138,8 +158,8 @@ class QoreidSdkModule(context: ReactApplicationContext) :
138
158
  QoreIDParams()
139
159
  .clientId(config?.get("clientId") as String)
140
160
  .customerReference(config?.get("customerReference") as String)
141
- .inputData(applicantData, addressData, null, extraData)
142
- .ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
161
+ .inputData(applicantData, addressData, identityData, extraData)
162
+ .ocrAcceptedDocuments(acceptedDocuments)
143
163
  .collection(config?.get("productCode") as String)
144
164
  }
145
165
 
@@ -155,7 +175,7 @@ class QoreidSdkModule(context: ReactApplicationContext) :
155
175
  val event =
156
176
  Arguments.createMap().apply {
157
177
  putString("code", qoreIdResult.code.toString())
158
- putString("data", qoreIdResult.data.toString())
178
+ putMap("data", parseData(qoreIdResult.data))
159
179
  putString("message", qoreIdResult.message)
160
180
  putString("event", "ERROR_RESULT")
161
181
  }
@@ -167,7 +187,7 @@ class QoreidSdkModule(context: ReactApplicationContext) :
167
187
  // Handle success.
168
188
  val event =
169
189
  Arguments.createMap().apply {
170
- putString("data", qoreIdResult.data.toString())
190
+ putMap("data", parseData(qoreIdResult.data))
171
191
  putString("message", qoreIdResult.message)
172
192
  putString("event", "SUCCESS_RESULT")
173
193
  }
@@ -177,6 +197,28 @@ class QoreidSdkModule(context: ReactApplicationContext) :
177
197
  }
178
198
  }
179
199
 
200
+ private fun parseData(data: ResultData?): ReadableMap {
201
+ val dataMap = Arguments.createMap()
202
+
203
+ // Adding verification object
204
+ val verificationMap = Arguments.createMap().apply {
205
+ putString("id", data?.verification?.id.toString())
206
+ putString("status", data?.verification?.status?.state)
207
+ putString("state", data?.verification?.status?.state)
208
+ }
209
+
210
+ // Populating the main map
211
+ dataMap.apply {
212
+ putString("customerReference", data?.customerReference)
213
+ putString("productCode", data?.productCode)
214
+ putString("flowId", data?.flowId.toString())
215
+ putMap("verification", verificationMap) // Nested map
216
+ }
217
+
218
+ return dataMap
219
+ }
220
+
221
+
180
222
  private fun sendEvent(
181
223
  reactContext: ReactApplicationContext,
182
224
  eventName: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qore-id/react-native-qoreid-sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "QoreId React Native SDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",