idwise-cordova-sdk 5.0.1 → 5.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/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="idwise-cordova-sdk" version="
|
|
2
|
+
<plugin id="idwise-cordova-sdk" version="5.0.2" xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
4
|
<name>IDWiseCordovaSDK</name>
|
|
5
5
|
<js-module name="IDWiseCordovaSDK" src="www/IDWiseCordovaSDK.js">
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
<source url="https://github.com/idwise/ios-sdk.git" />
|
|
25
25
|
</config>
|
|
26
26
|
<pods use-frameworks="true">
|
|
27
|
-
<pod name="IDWise" spec="5.0.
|
|
27
|
+
<pod name="IDWise" spec="5.0.1" />
|
|
28
28
|
</pods>
|
|
29
29
|
</podspec>
|
|
30
30
|
</platform>
|
|
@@ -5,8 +5,8 @@ import com.google.gson.Gson
|
|
|
5
5
|
import com.google.gson.reflect.TypeToken
|
|
6
6
|
import com.idwise.sdk.IDWise
|
|
7
7
|
import com.idwise.sdk.IDWiseDynamic
|
|
8
|
-
import com.idwise.sdk.
|
|
9
|
-
import com.idwise.sdk.
|
|
8
|
+
import com.idwise.sdk.IDWiseJourneyCallbacks
|
|
9
|
+
import com.idwise.sdk.IDWiseStepCallbacks
|
|
10
10
|
import com.idwise.sdk.data.models.*
|
|
11
11
|
import org.apache.cordova.CallbackContext
|
|
12
12
|
import org.apache.cordova.CordovaPlugin
|
|
@@ -38,10 +38,10 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
38
38
|
val clientKey = args.getString(0)
|
|
39
39
|
val theme = args.getString(1)
|
|
40
40
|
|
|
41
|
-
val idwiseTheme:
|
|
42
|
-
|
|
41
|
+
val idwiseTheme: IDWiseTheme = try {
|
|
42
|
+
IDWiseTheme.valueOf(theme!!)
|
|
43
43
|
} catch (e: Exception) {
|
|
44
|
-
|
|
44
|
+
IDWiseTheme.SYSTEM_DEFAULT
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
clientKey?.let {
|
|
@@ -113,20 +113,17 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
113
113
|
finishJourney()
|
|
114
114
|
return true
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
116
|
}
|
|
120
117
|
return false
|
|
121
118
|
}
|
|
122
119
|
|
|
123
120
|
private fun initialize(
|
|
124
121
|
clientKey: String,
|
|
125
|
-
theme:
|
|
122
|
+
theme: IDWiseTheme,
|
|
126
123
|
callbackContext: CallbackContext
|
|
127
124
|
) {
|
|
128
125
|
|
|
129
|
-
IDWise.initialize(clientKey, theme) { error:
|
|
126
|
+
IDWise.initialize(clientKey, theme) { error: IDWiseError? ->
|
|
130
127
|
val params = JSONObject()
|
|
131
128
|
params.put("event", "onError")
|
|
132
129
|
|
|
@@ -239,13 +236,13 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
239
236
|
IDWiseDynamic.getJourneySummary { journeySummary, error ->
|
|
240
237
|
if (journeySummary != null) {
|
|
241
238
|
val params = JSONObject()
|
|
242
|
-
params.put("
|
|
239
|
+
params.put("data", gson.toJson(journeySummary))
|
|
243
240
|
val result = PluginResult(PluginResult.Status.OK, params)
|
|
244
241
|
result.keepCallback = false
|
|
245
242
|
callbackContext.sendPluginResult(result)
|
|
246
243
|
} else if(error != null){
|
|
247
244
|
val params = JSONObject()
|
|
248
|
-
params.put("
|
|
245
|
+
params.put("data", gson.toJson(error!!))
|
|
249
246
|
val result = PluginResult(PluginResult.Status.ERROR, params)
|
|
250
247
|
result.keepCallback = false
|
|
251
248
|
callbackContext.sendPluginResult(result)
|
|
@@ -253,7 +250,7 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
253
250
|
}
|
|
254
251
|
}
|
|
255
252
|
|
|
256
|
-
private val journeyCallbacks = object :
|
|
253
|
+
private val journeyCallbacks = object : IDWiseJourneyCallbacks {
|
|
257
254
|
override fun onJourneyStarted(journeyInfo: JourneyStartedInfo) {
|
|
258
255
|
val params = JSONObject()
|
|
259
256
|
params.put("event", "onJourneyStarted")
|
|
@@ -304,7 +301,7 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
304
301
|
|
|
305
302
|
}
|
|
306
303
|
|
|
307
|
-
override fun onError(error:
|
|
304
|
+
override fun onError(error: IDWiseError) {
|
|
308
305
|
val params = JSONObject()
|
|
309
306
|
params.put("event", "onError")
|
|
310
307
|
params.put("data", gson.toJson(error))
|
|
@@ -315,7 +312,7 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
315
312
|
}
|
|
316
313
|
}
|
|
317
314
|
|
|
318
|
-
private val stepCallbacks = object :
|
|
315
|
+
private val stepCallbacks = object : IDWiseStepCallbacks {
|
|
319
316
|
override fun onStepCaptured(stepCapturedInfo: StepCapturedInfo) {
|
|
320
317
|
Log.d("stepCallbacks", "onStepCaptured ${stepCapturedInfo.stepId}")
|
|
321
318
|
val params = JSONObject()
|
|
@@ -324,12 +321,9 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
324
321
|
val originalImage = convertImageToBase64String(stepCapturedInfo.originalImage)
|
|
325
322
|
val croppedImage = convertImageToBase64String(stepCapturedInfo.croppedImage)
|
|
326
323
|
|
|
327
|
-
val
|
|
328
|
-
resp.put("stepId", stepCapturedInfo.stepId)
|
|
329
|
-
resp.put("croppedImage",croppedImage)
|
|
330
|
-
resp.put("originalImage", originalImage)
|
|
324
|
+
val capturedResponse = OnStepCapturedInfoExposed(stepCapturedInfo.stepId,originalImage,croppedImage)
|
|
331
325
|
|
|
332
|
-
params.put("data", gson.toJson(
|
|
326
|
+
params.put("data", gson.toJson(capturedResponse))
|
|
333
327
|
|
|
334
328
|
Log.d("stepCallbacks", "onStepCaptured ${params}")
|
|
335
329
|
val result = PluginResult(PluginResult.Status.OK, params)
|
|
@@ -385,4 +379,9 @@ class IDWiseCordovaSDK : CordovaPlugin() {
|
|
|
385
379
|
return Base64.encodeToString(b, Base64.DEFAULT)
|
|
386
380
|
}
|
|
387
381
|
|
|
382
|
+
internal data class OnStepCapturedInfoExposed(
|
|
383
|
+
val stepId:String,
|
|
384
|
+
val originalImage:String?,
|
|
385
|
+
val croppedImage:String?
|
|
386
|
+
)
|
|
388
387
|
}
|
|
@@ -12,7 +12,7 @@ import Foundation
|
|
|
12
12
|
let clientKey = command.arguments[0] as? String ?? ""
|
|
13
13
|
let theme = command.arguments[1] as? String ?? ""
|
|
14
14
|
|
|
15
|
-
var sdkTheme:
|
|
15
|
+
var sdkTheme: IDWiseTheme = .systemDefault
|
|
16
16
|
if theme == "LIGHT" {
|
|
17
17
|
sdkTheme = .light
|
|
18
18
|
} else if theme == "DARK" {
|
|
@@ -52,7 +52,7 @@ import Foundation
|
|
|
52
52
|
|
|
53
53
|
IDWise.startJourney(
|
|
54
54
|
flowId: flowId, referenceNumber: referenceNumber,
|
|
55
|
-
locale: locale, applicantDetails: nil,
|
|
55
|
+
locale: locale, applicantDetails: nil, journeyCallbacks: self)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
@objc(startDynamicJourney:)
|
|
@@ -66,7 +66,7 @@ import Foundation
|
|
|
66
66
|
|
|
67
67
|
IDWiseDynamic.startJourney(
|
|
68
68
|
flowId: flowId, referenceNumber: referenceNumber,
|
|
69
|
-
locale: locale, applicantDetails: nil,
|
|
69
|
+
locale: locale, applicantDetails: nil, journeyCallbacks: self, stepCallbacks: self)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
@objc(resumeJourney:)
|
|
@@ -79,7 +79,7 @@ import Foundation
|
|
|
79
79
|
|
|
80
80
|
IDWise.resumeJourney(
|
|
81
81
|
flowId: flowId, journeyId: journeyId,
|
|
82
|
-
locale: locale,
|
|
82
|
+
locale: locale, journeyCallbacks: self)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
@objc(resumeDynamicJourney:)
|
|
@@ -92,21 +92,22 @@ import Foundation
|
|
|
92
92
|
|
|
93
93
|
IDWiseDynamic.resumeJourney(
|
|
94
94
|
flowId: flowId, journeyId: journeyId,
|
|
95
|
-
locale: locale,
|
|
95
|
+
locale: locale, journeyCallbacks: self, stepCallbacks: self)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
@objc(getJourneySummary:)
|
|
99
99
|
func getJourneySummary(_ command: CDVInvokedUrlCommand) {
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
IDWiseDynamic.getJourneySummary(
|
|
102
|
-
callback: { journeySummary,
|
|
102
|
+
callback: { journeySummary, summaryError in
|
|
103
103
|
if let summary = journeySummary {
|
|
104
104
|
print("swift getjourneysummary success")
|
|
105
105
|
do {
|
|
106
|
-
let
|
|
107
|
-
let jsonData = try
|
|
108
|
-
let
|
|
109
|
-
let arguments = ["
|
|
106
|
+
let responseSummary = JourneySummaryExposed(summary: summary,error: summaryError)
|
|
107
|
+
let jsonData = try JSONEncoder().encode(responseSummary)
|
|
108
|
+
let jsonString = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
109
|
+
let arguments = ["data": jsonString] as [String: Any]
|
|
110
|
+
|
|
110
111
|
var pluginResult = CDVPluginResult(
|
|
111
112
|
status: CDVCommandStatus_OK,
|
|
112
113
|
messageAs: arguments
|
|
@@ -120,10 +121,10 @@ import Foundation
|
|
|
120
121
|
} else {
|
|
121
122
|
if let err = error {
|
|
122
123
|
do {
|
|
123
|
-
let
|
|
124
|
-
let jsonData = try
|
|
125
|
-
let
|
|
126
|
-
let arguments = ["
|
|
124
|
+
let responseSummary = JourneySummaryExposed(summary: summary,error: summaryError)
|
|
125
|
+
let jsonData = try JSONEncoder().encode(responseSummary)
|
|
126
|
+
let jsonString = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
127
|
+
let arguments = ["data": jsonString] as [String: Any]
|
|
127
128
|
var pluginResult = CDVPluginResult(
|
|
128
129
|
status: CDVCommandStatus_ERROR,
|
|
129
130
|
messageAs: arguments
|
|
@@ -160,8 +161,8 @@ import Foundation
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
extension IDWiseCordovaSDK:
|
|
164
|
-
func onError(error:
|
|
164
|
+
extension IDWiseCordovaSDK: IDWiseJourneyCallbacks {
|
|
165
|
+
func onError(error: IDWiseError) {
|
|
165
166
|
do {
|
|
166
167
|
let jsonEncoder = JSONEncoder()
|
|
167
168
|
let jsonData = try jsonEncoder.encode(error)
|
|
@@ -250,7 +251,7 @@ extension IDWiseCordovaSDK: IDWiseSDKJourneyDelegate {
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
extension IDWiseCordovaSDK:
|
|
254
|
+
extension IDWiseCordovaSDK: IDWiseStepCallbacks {
|
|
254
255
|
func onStepSkipped(stepSkippedInfo: StepSkippedInfo) {
|
|
255
256
|
|
|
256
257
|
let jsonEncoder = JSONEncoder()
|
|
@@ -309,10 +310,16 @@ extension IDWiseCordovaSDK: IDWiseSDKStepDelegate {
|
|
|
309
310
|
func onStepCaptured(stepCapturedInfo: StepCapturedInfo) {
|
|
310
311
|
|
|
311
312
|
do {
|
|
313
|
+
|
|
312
314
|
let originalImage = convertImageToBase64String(img: stepCapturedInfo.originalImage)
|
|
313
315
|
let croppedImage = convertImageToBase64String(img: stepCapturedInfo.croppedImage)
|
|
314
316
|
|
|
315
|
-
let
|
|
317
|
+
let captureResponse = OnStepCapturedExposed(stepId: stepCapturedInfo.stepId, originalImage: originalImage, croppedImage: croppedImage)
|
|
318
|
+
|
|
319
|
+
let jsonData = try JSONEncoder().encode(captureResponse)
|
|
320
|
+
let json = String(data: jsonData, encoding: String.Encoding.utf8)
|
|
321
|
+
|
|
322
|
+
let arguments = ["event": "onStepCaptured", "data":json ] as [String: Any]
|
|
316
323
|
|
|
317
324
|
var pluginResult = CDVPluginResult(
|
|
318
325
|
status: CDVCommandStatus_OK,
|
|
@@ -330,3 +337,16 @@ extension IDWiseCordovaSDK: IDWiseSDKStepDelegate {
|
|
|
330
337
|
return img?.jpegData(compressionQuality: 1)?.base64EncodedString() ?? ""
|
|
331
338
|
}
|
|
332
339
|
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
private struct JourneySummaryExposed: Codable {
|
|
343
|
+
var summary: IDWiseSDK.JourneySummary?
|
|
344
|
+
var error: IDWiseError?
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private struct OnStepCapturedExposed: Codable {
|
|
348
|
+
var stepId: String
|
|
349
|
+
var originalImage: String?
|
|
350
|
+
var croppedImage: String?
|
|
351
|
+
}
|
|
352
|
+
|
|
@@ -85,12 +85,12 @@ exports.getJourneySummary = function (success, error) {
|
|
|
85
85
|
console.log("IDWISE-Dynamic.JS -> getJourneySummary");
|
|
86
86
|
|
|
87
87
|
function onSuccess(response) {
|
|
88
|
-
success(JSON.parse(response.
|
|
88
|
+
success(JSON.parse(response.data));
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function onError(errorResponse) {
|
|
92
92
|
console.log(`getjourneysummary error ${JSON.stringify(errorResponse)}`);
|
|
93
|
-
error(JSON.parse(errorResponse.
|
|
93
|
+
error(JSON.parse(errorResponse.data));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
exec(onSuccess, onError, "IDWiseCordovaSDK", "getJourneySummary", []);
|