@regulaforensics/cordova-plugin-document-reader-api 9.11.951-nightly → 9.11.953-rc

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.
@@ -0,0 +1,1866 @@
1
+ import DocumentReader
2
+
3
+ // MARK: - Config
4
+
5
+ public extension DocReader.BaseReaderConfig {
6
+ @discardableResult
7
+ func update(_ it: [String: Any]) -> Self {
8
+ if let prop = it["databasePath"] as? String { self.databasePath = prop }
9
+ if let prop = it["licenseUpdateTimeout"] as? NSNumber { self.licenseUpdateTimeout = prop }
10
+ if let prop = it["licenseUpdate"] as? Bool { self.licenseUpdateCheck = prop }
11
+ if let prop = it["delayedNNLoad"] as? Bool { self.isDelayedNNLoadEnabled = prop }
12
+ return self
13
+ }
14
+ }
15
+
16
+ public extension DocReader.Config {
17
+ static func decode(_ it: Any?) -> Self? {
18
+ guard let it = it as? [String: Any] else { return nil }
19
+ // If licence decoding failed, pass an empty data to get a 'license corrupted'
20
+ // error message from the sdk, instead of handling it manually.
21
+ return Self(license: Data.decode(it["license"]) ?? Data([0])).update(it)
22
+ }
23
+ func encode() -> [String: Any?] {
24
+ return [
25
+ "license": self.licenseData.encode(),
26
+ "databasePath": self.databasePath,
27
+ "licenseUpdateTimeout": self.licenseUpdateTimeout,
28
+ "licenseUpdate": self.licenseUpdateCheck,
29
+ "delayedNNLoad": self.isDelayedNNLoadEnabled,
30
+ ]
31
+ }
32
+ }
33
+
34
+ extension DocReader.BleConfig {
35
+ static func decode(_ it: [String: Any], _ bluetooth: Bluetooth) -> DocReader.BleConfig {
36
+ return DocReader.BleConfig(bluetooth: bluetooth).update(it)
37
+ }
38
+ }
39
+
40
+ public extension DocReader.FinalizeConfig {
41
+ static func decode(_ it: Any?) -> Self? {
42
+ guard let it = it as? [String: Any] else { return nil }
43
+ let result = Self.defaultParams()
44
+ if let prop = it["rawImages"] as? Bool { result.rawImages = prop }
45
+ if let prop = it["video"] as? Bool { result.video = prop }
46
+ if let prop = it["rfidSession"] as? Bool { result.rfidSession = prop }
47
+ if let prop = it["mdlSession"] as? Bool { result.mdlSession = prop }
48
+ return result
49
+ }
50
+ func encode() -> [String: Any?] {
51
+ return [
52
+ "rawImages": self.rawImages,
53
+ "video": self.video,
54
+ "rfidSession": self.rfidSession,
55
+ "mdlSession": self.mdlSession,
56
+ ]
57
+ }
58
+ }
59
+
60
+ public extension DocReader.OnlineProcessingConfig {
61
+ static func decode(_ it: Any?) -> Self? {
62
+ guard let it = it as? [String: Any] else { return nil }
63
+ let result = Self(mode: DocReader.OnlineProcessingMode(rawValue: it["mode"] as! Int)!)
64
+ if let prop = it["url"] as? String { result.serviceURL = prop }
65
+ if let prop = it["processParams"] { result.processParams = ProcessParams.decode(prop) }
66
+ if let prop = it["imageFormat"] { result.imageFormat = DocReader.OnlineProcessingImageFormat(rawValue: prop as! Int)! }
67
+ if let prop = it["imageCompressionQuality"] { result.imageCompressionQuality = prop as! CGFloat }
68
+ if let prop = it["requestHeaders"] as? [String: String] {
69
+ let delegate = IURLRequestInterceptingDelegate(prop)
70
+ result.requestInterceptingDelegate = delegate
71
+ objc_setAssociatedObject(result, &headersDelegateKey, delegate, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
72
+ }
73
+ return result
74
+ }
75
+ func encode() -> [String: Any?] {
76
+ return [
77
+ "mode": self.mode.rawValue,
78
+ "url": self.serviceURL,
79
+ "processParams": self.processParams?.encode(),
80
+ "imageFormat": self.imageFormat.rawValue,
81
+ "imageCompressionQuality": self.imageCompressionQuality,
82
+ ]
83
+ }
84
+ }
85
+
86
+ public extension DocReader.RecognizeConfig {
87
+ static func decode(_ it: Any?) -> Self? {
88
+ guard let it = it as? [String: Any] else { return nil }
89
+ // Multiple init variants: scenario/onlineProcessingConfig/scenario+onlineProcessingConfig
90
+ let result: Self
91
+ if let scenario = it["scenario"] as? String {
92
+ result = Self(scenario: scenario)
93
+ if let prop = it["onlineProcessingConfig"] { result.onlineProcessingConfig = DocReader.OnlineProcessingConfig.decode(prop) }
94
+ } else {
95
+ result = Self(onlineProcessingConfig: DocReader.OnlineProcessingConfig.decode(it["onlineProcessingConfig"])!)
96
+ }
97
+ if let prop = it["livePortrait"] { result.livePortrait = UIImage.decode(prop) }
98
+ if let prop = it["extPortrait"] { result.extPortrait = UIImage.decode(prop) }
99
+ if let prop = it["oneShotIdentification"] as? Bool { result.oneShotIdentification = prop }
100
+ if let prop = it["dtc"] { result.dtc = Data.decode(prop) }
101
+ if let prop = it["image"] { result.image = UIImage.decode(prop) }
102
+ if let prop = it["data"] { result.imageData = Data.decode(prop) }
103
+ if let prop = it["images"] { result.images = (prop as? [Any])?.compactMap(UIImage.decode) }
104
+ if let prop = it["dataList"] { result.imageDataArray = (prop as? [Any])?.compactMap(Data.decode) }
105
+ if let prop = it["imageInputData"] { result.imageInputs = (prop as? [Any])?.compactMap(DocReader.ImageInput.decode) }
106
+ return result
107
+ }
108
+ func encode() -> [String: Any?] {
109
+ return [
110
+ "scenario": self.scenario,
111
+ "onlineProcessingConfig": self.onlineProcessingConfig?.encode(),
112
+ "livePortrait": self.livePortrait?.encode(),
113
+ "extPortrait": self.extPortrait?.encode(),
114
+ "oneShotIdentification": self.oneShotIdentification,
115
+ "dtc": self.dtc?.encode(),
116
+ "image": self.image?.encode(),
117
+ "data": self.imageData?.encode(),
118
+ "images": self.images?.map { $0.encode() },
119
+ "dataList": self.imageDataArray?.map { $0.encode() },
120
+ "imageInputData": self.imageInputs?.map { $0.encode() },
121
+ ]
122
+ }
123
+ }
124
+
125
+ public extension DocReader.ImageInput {
126
+ static func decode(_ it: Any?) -> Self? {
127
+ guard let it = it as? [String: Any] else { return nil }
128
+ guard let image = UIImage.decode(it["image"]) else { return nil }
129
+ return Self(image: image,
130
+ light: GraphicFieldLight(rawValue: it["light"] as? Int ?? 6)!,
131
+ pageIndex: it["pageIndex"] as? Int ?? 0)
132
+ }
133
+ func encode() -> [String: Any?] {
134
+ return [
135
+ "pageIndex": self.pageIndex,
136
+ "light": self.lightType.rawValue,
137
+ "image": self.image.encode(),
138
+ ]
139
+ }
140
+ }
141
+
142
+ public extension DocReader.ScannerConfig {
143
+ static func decode(_ it: Any?) -> Self? {
144
+ guard let it = it as? [String: Any] else { return nil }
145
+ // Multiple init variants: scenario/onlineProcessingConfig/scenario+onlineProcessingConfig
146
+ let result: Self
147
+ if let scenario = it["scenario"] as? String {
148
+ result = Self(scenario: scenario)
149
+ if let prop = it["onlineProcessingConfig"] { result.onlineProcessingConfig = DocReader.OnlineProcessingConfig.decode(prop) }
150
+ } else {
151
+ result = Self(onlineProcessingConfig: DocReader.OnlineProcessingConfig.decode(it["onlineProcessingConfig"])!)
152
+ }
153
+ if let prop = it["livePortrait"] { result.livePortrait = UIImage.decode(prop) }
154
+ if let prop = it["extPortrait"] { result.extPortrait = UIImage.decode(prop) }
155
+ return result
156
+ }
157
+ func encode() -> [String: Any?] {
158
+ return [
159
+ "scenario": self.scenario,
160
+ "onlineProcessingConfig": self.onlineProcessingConfig?.encode(),
161
+ "livePortrait": self.livePortrait?.encode(),
162
+ "extPortrait": self.extPortrait?.encode(),
163
+ ]
164
+ }
165
+ }
166
+
167
+ // MARK: - Info
168
+
169
+ public extension NSError {
170
+ static func decode(_ it: Any?) -> NSError? {
171
+ guard let it = it as? [String: Any] else { return nil }
172
+ return NSError(domain: RGLDocumentReaderDomain, code: it["code"] as! Int,
173
+ userInfo: [NSLocalizedDescriptionKey: it["message"] as! String])
174
+ }
175
+ }
176
+
177
+ public extension Scenario {
178
+ static func decode(_ it: Any?) -> Self? {
179
+ guard let it = it as? [String: Any] else { return nil }
180
+ let result = Self()
181
+ result.setValue(it["name"] as? String, forKey: "identifier")
182
+ result.setValue(it["frameKWHLandscape"] as? Double, forKey: "frameKWHLandscape")
183
+ result.setValue(it["frameKWHPortrait"] as? Double, forKey: "frameKWHPortrait")
184
+ result.setValue(it["frameKWHDoublePageSpreadPortrait"] as? Double, forKey: "frameKWHDoublePageSpreadPortrait")
185
+ result.setValue(it["frameKWHDoublePageSpreadLandscape"] as? Double, forKey: "frameKWHDoublePageSpreadLandscape")
186
+ result.setValue(it["description"] as? String, forKey: "scenarioDescription")
187
+ result.setValue(it["faceExt"] as? Bool, forKey: "faceExt")
188
+ result.setValue(it["multiPageOff"] as? Bool, forKey: "multiPageOff")
189
+ result.setValue(it["seriesProcessMode"] as? Bool, forKey: "seriesProcessMode")
190
+ result.setValue(it["caption"] as? String, forKey: "caption")
191
+ result.setValue(it["uvTorch"] as? Bool, forKey: "uvTorch")
192
+ result.setValue(it["frameOrientation"] as Any?, forKey: "frameOrientation")
193
+ result.setValue(it["manualCrop"] as? Bool, forKey: "manualCrop")
194
+ return result
195
+ }
196
+ func encode() -> [String: Any?] {
197
+ return [
198
+ "name": self.identifier,
199
+ "frameKWHLandscape": self.frameKWHLandscape,
200
+ "frameKWHPortrait": self.frameKWHPortrait,
201
+ "frameKWHDoublePageSpreadPortrait": self.frameKWHDoublePageSpreadPortrait,
202
+ "frameKWHDoublePageSpreadLandscape": self.frameKWHDoublePageSpreadLandscape,
203
+ "description": self.scenarioDescription,
204
+ "faceExt": self.faceExt,
205
+ "multiPageOff": self.multiPageOff,
206
+ "seriesProcessMode": self.seriesProcessMode,
207
+ "caption": self.caption,
208
+ "uvTorch": self.uvTorch,
209
+ "frameOrientation": self.frameOrientation.rawValue,
210
+ "manualCrop": self.manualCrop,
211
+ ]
212
+ }
213
+ }
214
+
215
+ public extension DocReaderVersion {
216
+ func encode() -> [String: Any?] {
217
+ return [
218
+ "api": self.api,
219
+ "core": self.core,
220
+ "coreMode": self.coreMode,
221
+ "database": self.database.encode(),
222
+ ]
223
+ }
224
+ }
225
+
226
+ public extension DocReaderDocumentsDatabase {
227
+ static func decode(_ it: Any?) -> Self? {
228
+ guard let it = it as? [String: Any] else { return nil }
229
+ let result = Self.emptyInit() as Self
230
+ result.setValue(it["databaseID"] as? String, forKey: "databaseID")
231
+ result.setValue(it["version"] as? String, forKey: "version")
232
+ result.setValue(it["date"] as? String, forKey: "date")
233
+ result.setValue(it["databaseDescription"] as? String, forKey: "databaseDescription")
234
+ result.setValue(it["countriesNumber"] as? Int, forKey: "countriesNumber")
235
+ result.setValue(it["documentsNumber"] as? Int, forKey: "documentsNumber")
236
+ result.setValue(it["size"] as? NSNumber, forKey: "size")
237
+ return result
238
+ }
239
+ func encode() -> [String: Any?] {
240
+ return [
241
+ "databaseID": self.databaseID,
242
+ "version": self.version,
243
+ "date": self.date,
244
+ "databaseDescription": self.databaseDescription,
245
+ "countriesNumber": self.countriesNumber,
246
+ "documentsNumber": self.documentsNumber,
247
+ "size": self.size,
248
+ ]
249
+ }
250
+ }
251
+
252
+ public extension License {
253
+ func encode() -> [String: Any?] {
254
+ let formatter = DateFormatter()
255
+ formatter.dateStyle = .short
256
+ formatter.timeStyle = .none
257
+ return [
258
+ "expiryDate": self.expiryDate.map { formatter.string(from: $0) },
259
+ "countryFilter": self.countryFilter,
260
+ "isRfidAvailable": self.isRfidAvailable,
261
+ ]
262
+ }
263
+ }
264
+
265
+ // MARK: - MDL
266
+
267
+ public extension DocReader.DataRetrieval {
268
+ static func decode(_ it: Any?) -> Self? {
269
+ guard let it = it as? [String: Any] else { return nil }
270
+ let result = Self(deviceRetrieval: eMDLDeviceRetrieval(rawValue: it["deviceRetrieval"] as! Int)!)
271
+ if let prop = it["docRequestPreset"] as? Int {
272
+ result.setDocRequestPreset(eMDLDocRequestPreset(rawValue: prop)!, intentToRetain: eMDLIntentToRetain(rawValue: it["intentToRetain"] as! Int)!)
273
+ }
274
+ result.requests = (it["requests"] as? [Any])?.compactMap(DocReader.DocumentRequestMDL.decode) ?? []
275
+ return result
276
+ }
277
+ func encode() -> [String: Any?] {
278
+ return [
279
+ "deviceRetrieval": self.value(forKey: "deviceRetrieval"),
280
+ "docRequestPreset": self.value(forKey: "docRequestPreset"),
281
+ "intentToRetain": self.value(forKey: "intentToRetain"),
282
+ "requests": self.requests.map { $0.encode() },
283
+ ]
284
+ }
285
+ }
286
+
287
+ public extension DocReader.DeviceEngagement {
288
+ static func decode(_ it: Any?) -> Self? {
289
+ guard let it = it as? [String: Any] else { return nil }
290
+ let result = Self()
291
+ if let prop = it["deviceRetrievalMethods"] { result.deviceRetrievalMethods = (prop as? [Any])?.compactMap(DocReader.DeviceRetrievalMethod.decode) }
292
+ return result
293
+ }
294
+ func encode() -> [String: Any?] {
295
+ return [
296
+ "deviceRetrievalMethods": self.deviceRetrievalMethods?.map { $0.encode() },
297
+ ]
298
+ }
299
+ }
300
+
301
+ public extension DocReader.DeviceRetrievalMethod {
302
+ static func decode(_ it: Any?) -> Self? {
303
+ guard let it = it as? [String: Any] else { return nil }
304
+ let result = Self.emptyInit() as Self
305
+ if let prop = it["type"] { result.type = eMDLDeviceRetrieval(rawValue: prop as! Int)! }
306
+ if let prop = it["version"] as? NSNumber { result.version = prop }
307
+ if let prop = it["cmdMaxLength"] as? NSNumber { result.cmdMaxLength = prop }
308
+ if let prop = it["respMaxLength"] as? NSNumber { result.respMaxLength = prop }
309
+ if let prop = it["clientModeSupport"] as? NSNumber { result.clientModeSupport = prop }
310
+ if let prop = it["clientModeUUID"] as? String { result.clientModeUUID = prop }
311
+ if let prop = it["serverModeSupport"] as? NSNumber { result.serverModeSupport = prop }
312
+ if let prop = it["serverModeUUID"] as? String { result.serverModeUUID = prop }
313
+ return result
314
+ }
315
+ func encode() -> [String: Any?] {
316
+ return [
317
+ "type": self.type.rawValue,
318
+ "version": self.version,
319
+ "cmdMaxLength": self.cmdMaxLength,
320
+ "respMaxLength": self.respMaxLength,
321
+ "clientModeSupport": self.clientModeSupport,
322
+ "clientModeUUID": self.clientModeUUID,
323
+ "serverModeSupport": self.serverModeSupport,
324
+ "serverModeUUID": self.serverModeUUID,
325
+ ]
326
+ }
327
+ }
328
+
329
+ public extension DocReader.DocumentRequestMDL {
330
+ static func decode(_ it: Any?) -> DocReader.DocumentRequestMDL? {
331
+ guard let it = it as? [String: Any] else { return nil }
332
+ // Multiple init variants: mDL/generic document
333
+ let docType = it["docType"] as! String
334
+ if docType == "org.iso.18013.5.1.mDL" { return DocReader.DocumentRequest18013MDL.decode2(it) }
335
+ let result = DocReader.DocumentRequestMDL(docType: docType)
336
+ result.setValue((it["namespaces"] as? [Any])?.compactMap(DocReader.NameSpaceMDL.decode) ?? [], forKey: "nameSpaces")
337
+ return result
338
+ }
339
+ func encode() -> [String: Any?] {
340
+ if let it = self as? DocReader.DocumentRequest18013MDL { return it.encode2() }
341
+ return [
342
+ "docType": self.value(forKey: "docType"),
343
+ "namespaces": (self.value(forKey: "nameSpaces") as? [DocReader.NameSpaceMDL])?.map { $0.encode() },
344
+ ]
345
+ }
346
+ }
347
+
348
+ public extension DocReader.DocumentRequest18013MDL {
349
+ static func decode2(_ it: Any?) -> Self? {
350
+ guard let it = it as? [String: Any] else { return nil }
351
+ let result = Self()
352
+ if let prop = it["docType"] { result.setValue(prop, forKey: "docType") }
353
+ if let prop = it["namespaces"] as? [Any] {
354
+ result.setValue(prop.compactMap(DocReader.NameSpaceMDL.decode), forKey: "nameSpaces")
355
+ }
356
+ if let prop = it["familyName"] { result.familyName = eMDLIntentToRetain(rawValue: prop as! Int)! }
357
+ if let prop = it["givenName"] { result.givenName = eMDLIntentToRetain(rawValue: prop as! Int)! }
358
+ if let prop = it["birthDate"] { result.birthDate = eMDLIntentToRetain(rawValue: prop as! Int)! }
359
+ if let prop = it["issueDate"] { result.issueDate = eMDLIntentToRetain(rawValue: prop as! Int)! }
360
+ if let prop = it["expiryDate"] { result.expiryDate = eMDLIntentToRetain(rawValue: prop as! Int)! }
361
+ if let prop = it["issuingCountry"] { result.issuingCountry = eMDLIntentToRetain(rawValue: prop as! Int)! }
362
+ if let prop = it["issuingAuthority"] { result.issuingAuthority = eMDLIntentToRetain(rawValue: prop as! Int)! }
363
+ if let prop = it["documentNumber"] { result.documentNumber = eMDLIntentToRetain(rawValue: prop as! Int)! }
364
+ if let prop = it["portrait"] { result.portrait = eMDLIntentToRetain(rawValue: prop as! Int)! }
365
+ if let prop = it["drivingPrivileges"] { result.drivingPrivileges = eMDLIntentToRetain(rawValue: prop as! Int)! }
366
+ if let prop = it["unDistinguishingSign"] { result.unDistinguishingSign = eMDLIntentToRetain(rawValue: prop as! Int)! }
367
+ if let prop = it["administrativeNumber"] { result.administrativeNumber = eMDLIntentToRetain(rawValue: prop as! Int)! }
368
+ if let prop = it["sex"] { result.sex = eMDLIntentToRetain(rawValue: prop as! Int)! }
369
+ if let prop = it["height"] { result.height = eMDLIntentToRetain(rawValue: prop as! Int)! }
370
+ if let prop = it["weight"] { result.weight = eMDLIntentToRetain(rawValue: prop as! Int)! }
371
+ if let prop = it["eyeColour"] { result.eyeColour = eMDLIntentToRetain(rawValue: prop as! Int)! }
372
+ if let prop = it["hairColour"] { result.hairColour = eMDLIntentToRetain(rawValue: prop as! Int)! }
373
+ if let prop = it["birthPlace"] { result.birthPlace = eMDLIntentToRetain(rawValue: prop as! Int)! }
374
+ if let prop = it["residentAddress"] { result.residentAddress = eMDLIntentToRetain(rawValue: prop as! Int)! }
375
+ if let prop = it["portraitCaptureDate"] { result.portraitCaptureDate = eMDLIntentToRetain(rawValue: prop as! Int)! }
376
+ if let prop = it["ageInYears"] { result.ageInYears = eMDLIntentToRetain(rawValue: prop as! Int)! }
377
+ if let prop = it["ageBirthYear"] { result.ageBirthYear = eMDLIntentToRetain(rawValue: prop as! Int)! }
378
+ if let prop = it["ageOver18"] { result.ageOver18 = eMDLIntentToRetain(rawValue: prop as! Int)! }
379
+ if let prop = it["issuingJurisdiction"] { result.issuingJurisdiction = eMDLIntentToRetain(rawValue: prop as! Int)! }
380
+ if let prop = it["nationality"] { result.nationality = eMDLIntentToRetain(rawValue: prop as! Int)! }
381
+ if let prop = it["residentCity"] { result.residentCity = eMDLIntentToRetain(rawValue: prop as! Int)! }
382
+ if let prop = it["residentState"] { result.residentState = eMDLIntentToRetain(rawValue: prop as! Int)! }
383
+ if let prop = it["residentPostalCode"] { result.residentPostalCode = eMDLIntentToRetain(rawValue: prop as! Int)! }
384
+ if let prop = it["residentCountry"] { result.residentCountry = eMDLIntentToRetain(rawValue: prop as! Int)! }
385
+ if let prop = it["biometricTemplateFace"] { result.biometricTemplateFace = eMDLIntentToRetain(rawValue: prop as! Int)! }
386
+ if let prop = it["biometricTemplateIris"] { result.biometricTemplateIris = eMDLIntentToRetain(rawValue: prop as! Int)! }
387
+ if let prop = it["biometricTemplateFinger"] { result.biometricTemplateFinger = eMDLIntentToRetain(rawValue: prop as! Int)! }
388
+ if let prop = it["biometricTemplateSignatureSign"] { result.biometricTemplateSignatureSign = eMDLIntentToRetain(rawValue: prop as! Int)! }
389
+ if let prop = it["familyNameNationalCharacter"] { result.familyNameNationalCharacter = eMDLIntentToRetain(rawValue: prop as! Int)! }
390
+ if let prop = it["givenNameNationalCharacter"] { result.givenNameNationalCharacter = eMDLIntentToRetain(rawValue: prop as! Int)! }
391
+ if let prop = it["signatureUsualMark"] { result.signatureUsualMark = eMDLIntentToRetain(rawValue: prop as! Int)! }
392
+ return result
393
+ }
394
+ func encode2() -> [String: Any?] {
395
+ return [
396
+ "docType": self.value(forKey: "docType"),
397
+ "namespaces": (self.value(forKey: "nameSpaces") as? [DocReader.NameSpaceMDL])?.map { $0.encode() },
398
+ "familyName": self.familyName.encode(),
399
+ "givenName": self.givenName.encode(),
400
+ "birthDate": self.birthDate.encode(),
401
+ "issueDate": self.issueDate.encode(),
402
+ "expiryDate": self.expiryDate.encode(),
403
+ "issuingCountry": self.issuingCountry.encode(),
404
+ "issuingAuthority": self.issuingAuthority.encode(),
405
+ "documentNumber": self.documentNumber.encode(),
406
+ "portrait": self.portrait.encode(),
407
+ "drivingPrivileges": self.drivingPrivileges.encode(),
408
+ "unDistinguishingSign": self.unDistinguishingSign.encode(),
409
+ "administrativeNumber": self.administrativeNumber.encode(),
410
+ "sex": self.sex.encode(),
411
+ "height": self.height.encode(),
412
+ "weight": self.weight.encode(),
413
+ "eyeColour": self.eyeColour.encode(),
414
+ "hairColour": self.hairColour.encode(),
415
+ "birthPlace": self.birthPlace.encode(),
416
+ "residentAddress": self.residentAddress.encode(),
417
+ "portraitCaptureDate": self.portraitCaptureDate.encode(),
418
+ "ageInYears": self.ageInYears.encode(),
419
+ "ageBirthYear": self.ageBirthYear.encode(),
420
+ "ageOver18": self.ageOver18.encode(),
421
+ "issuingJurisdiction": self.issuingJurisdiction.encode(),
422
+ "nationality": self.nationality.encode(),
423
+ "residentCity": self.residentCity.encode(),
424
+ "residentState": self.residentState.encode(),
425
+ "residentPostalCode": self.residentPostalCode.encode(),
426
+ "residentCountry": self.residentCountry.encode(),
427
+ "biometricTemplateFace": self.biometricTemplateFace.encode(),
428
+ "biometricTemplateIris": self.biometricTemplateIris.encode(),
429
+ "biometricTemplateFinger": self.biometricTemplateFinger.encode(),
430
+ "biometricTemplateSignatureSign": self.biometricTemplateSignatureSign.encode(),
431
+ "familyNameNationalCharacter": self.familyNameNationalCharacter.encode(),
432
+ "givenNameNationalCharacter": self.givenNameNationalCharacter.encode(),
433
+ "signatureUsualMark": self.signatureUsualMark.encode(),
434
+ ]
435
+ }
436
+ }
437
+
438
+ public extension DocReader.NameSpaceMDL {
439
+ static func decode(_ it: Any?) -> Self? {
440
+ guard let it = it as? [String: Any] else { return nil }
441
+ let result = Self(name: it["name"] as! String)
442
+ for (key, value) in it["map"] as! [String: Int] {
443
+ result.addField(key, intentToRetain: eMDLIntentToRetain(rawValue: value)!)
444
+ }
445
+ return result
446
+ }
447
+ func encode() -> [String: Any?] {
448
+ return [
449
+ "name": self.name,
450
+ "map": self.value(forKey: "jsonDict"),
451
+ ]
452
+ }
453
+ }
454
+
455
+ // MARK: - Params
456
+
457
+ public extension RGLBackendProcessingConfig {
458
+ static func decode(_ it: Any?) -> Self? {
459
+ guard let it = it as? [String: Any] else { return nil }
460
+ let result = Self()
461
+ if let prop = it["url"] as? String { result.url = prop }
462
+ if let prop = it["httpHeaders"] { result.httpHeaders = prop as? [AnyHashable: Any] }
463
+ if let prop = it["rfidServerSideChipVerification"] as? NSNumber { result.rfidServerSideChipVerification = prop }
464
+ if let prop = it["mdlVerification"] as? NSNumber { result.mDLVerification = prop }
465
+ if let prop = it["timeoutConnection"] as? NSNumber { result.timeoutConnection = prop }
466
+ return result
467
+ }
468
+ func encode() -> [String: Any?] {
469
+ return [
470
+ "url": self.url,
471
+ "httpHeaders": self.httpHeaders,
472
+ "rfidServerSideChipVerification": self.rfidServerSideChipVerification,
473
+ "mdlVerification": self.mDLVerification,
474
+ "timeoutConnection": self.timeoutConnection,
475
+ ]
476
+ }
477
+ }
478
+
479
+ public extension DocReader.Bsi {
480
+ static func decode(_ it: Any?) -> Self? {
481
+ guard let it = it as? [String: Any] else { return nil }
482
+ let result = Self()
483
+ if let prop = it["generateResult"] as? NSNumber { result.generateResult = prop }
484
+ return result
485
+ }
486
+ func encode() -> [String: Any?] {
487
+ return [
488
+ "generateResult": self.generateResult,
489
+ ]
490
+ }
491
+ }
492
+
493
+ public extension FaceAPIParams {
494
+ static func decode(_ it: Any?) -> Self? {
495
+ guard let it = it as? [String: Any] else { return nil }
496
+ let result = Self.default()
497
+ if let prop = it["url"] as? String { result.url = prop }
498
+ if let prop = it["mode"] as? String { result.mode = prop }
499
+ if let prop = it["searchParams"] { result.searchParams = RGLFaceAPISearchParams.decode(prop) }
500
+ if let prop = it["threshold"] as? NSNumber { result.threshold = prop }
501
+ if let prop = it["serviceTimeout"] as? NSNumber { result.serviceTimeout = prop }
502
+ if let prop = it["proxy"] as? String { result.proxy = prop }
503
+ if let prop = it["proxyPassword"] as? String { result.proxyPassword = prop }
504
+ if let prop = it["proxyType"] as? NSNumber { result.proxyType = prop }
505
+ if let prop = it["livenessTransactionId"] as? String { result.livenessTransactionId = prop }
506
+ return result
507
+ }
508
+ func encode() -> [String: Any?] {
509
+ return [
510
+ "url": self.url,
511
+ "mode": self.mode,
512
+ "searchParams": self.searchParams?.encode(),
513
+ "threshold": self.threshold,
514
+ "serviceTimeout": self.serviceTimeout,
515
+ "proxy": self.proxy,
516
+ "proxyPassword": self.proxyPassword,
517
+ "proxyType": self.proxyType,
518
+ "livenessTransactionId": self.livenessTransactionId,
519
+ ]
520
+ }
521
+ }
522
+
523
+ public extension RGLFaceAPISearchParams {
524
+ static func decode(_ it: Any?) -> Self? {
525
+ guard let it = it as? [String: Any] else { return nil }
526
+ let result = Self()
527
+ if let prop = it["limit"] as? NSNumber { result.limit = prop }
528
+ if let prop = it["threshold"] as? NSNumber { result.threshold = prop }
529
+ if let prop = it["groupIds"] as? [String] { result.groupIDs = prop }
530
+ return result
531
+ }
532
+ func encode() -> [String: Any?] {
533
+ return [
534
+ "limit": self.limit,
535
+ "threshold": self.threshold,
536
+ "groupIds": self.groupIDs,
537
+ ]
538
+ }
539
+ }
540
+
541
+ public extension ImageQA.GlaresCheckParams {
542
+ static func decode(_ it: Any?) -> Self? {
543
+ guard let it = it as? [String: Any] else { return nil }
544
+ let result = Self()
545
+ if let prop = it["imgMarginPart"] as? NSNumber { result.imgMarginPart = prop }
546
+ if let prop = it["maxGlaringPart"] as? NSNumber { result.maxGlaringPart = prop }
547
+ return result
548
+ }
549
+ func encode() -> [String: Any?] {
550
+ return [
551
+ "imgMarginPart": self.imgMarginPart,
552
+ "maxGlaringPart": self.maxGlaringPart,
553
+ ]
554
+ }
555
+ }
556
+
557
+ public extension ImageQA.OcclusionCheckParams {
558
+ static func decode(_ it: Any?) -> Self? {
559
+ guard let it = it as? [String: Any] else { return nil }
560
+ let result = Self()
561
+ if let prop = it["maxOcclusionPart"] as? NSNumber { result.maxOcclusionPart = prop }
562
+ return result
563
+ }
564
+ func encode() -> [String: Any?] {
565
+ return [
566
+ "maxOcclusionPart": self.maxOcclusionPart,
567
+ ]
568
+ }
569
+ }
570
+
571
+ public extension RFIDParams {
572
+ static func decode(_ it: Any?) -> Self? {
573
+ guard let it = it as? [String: Any] else { return nil }
574
+ let result = Self()
575
+ if let prop = it["paIgnoreNotificationCodes"] as? [NSNumber] { result.paIgnoreNotificationCodes = prop }
576
+ return result
577
+ }
578
+ func encode() -> [String: Any?] {
579
+ return [
580
+ "paIgnoreNotificationCodes": self.paIgnoreNotificationCodes,
581
+ ]
582
+ }
583
+ }
584
+
585
+ // MARK: - Results
586
+
587
+ public extension DocumentReaderDocumentType {
588
+ static func decode(_ it: Any?) -> Self? {
589
+ guard let it = it as? [String: Any] else { return nil }
590
+ let result = Self.emptyInit() as Self
591
+ result.setValue(it["name"] as? String, forKey: "name")
592
+ result.setValue(it["documentID"] as? Int, forKey: "documentID")
593
+ result.setValue(it["ICAOCode"] as? String, forKey: "ICAOCode")
594
+ result.setValue(it["FDSID"] as? [NSNumber], forKey: "FDSID")
595
+ result.setValue(it["dType"] as Any?, forKey: "dType")
596
+ result.setValue(it["dFormat"] as Any?, forKey: "dFormat")
597
+ result.setValue(it["dMRZ"] as? Bool, forKey: "dMRZ")
598
+ result.setValue(it["isDeprecated"] as? Bool, forKey: "isDeprecated")
599
+ result.setValue(it["dDescription"] as? String, forKey: "dDescription")
600
+ result.setValue(it["dYear"] as? String, forKey: "dYear")
601
+ result.setValue(it["dCountryName"] as? String, forKey: "dCountryName")
602
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
603
+ return result
604
+ }
605
+ func encode() -> [String: Any?] {
606
+ return [
607
+ "name": self.name,
608
+ "documentID": self.documentID,
609
+ "ICAOCode": self.icaoCode,
610
+ "FDSID": self.fdsid,
611
+ "dType": self.dType.rawValue,
612
+ "dFormat": self.dFormat.rawValue,
613
+ "dMRZ": self.dMRZ,
614
+ "isDeprecated": self.isDeprecated,
615
+ "dDescription": self.dDescription,
616
+ "dYear": self.dYear,
617
+ "dCountryName": self.dCountryName,
618
+ "pageIndex": self.pageIndex,
619
+ ]
620
+ }
621
+ }
622
+
623
+ public extension Position {
624
+ static func decode(_ it: Any?) -> Self? {
625
+ guard let it = it as? [String: Any] else { return nil }
626
+ let result = Self.emptyInit() as Self
627
+ result.setValue(NSValue(cgSize: CGSize(width: it["width"] as! CGFloat, height: it["height"] as! CGFloat)), forKey: "size")
628
+ result.setValue(it["angle"] as? Double, forKey: "angle")
629
+ result.setValue(CGPoint.decode(it["center"]), forKey: "center")
630
+ result.setValue(CGPoint.decode(it["leftTop"]), forKey: "leftTop")
631
+ result.setValue(CGPoint.decode(it["leftBottom"]), forKey: "leftBottom")
632
+ result.setValue(CGPoint.decode(it["rightTop"]), forKey: "rightTop")
633
+ result.setValue(CGPoint.decode(it["rightBottom"]), forKey: "rightBottom")
634
+ result.setValue(it["perspectiveTr"] as? Double, forKey: "perspectiveTr")
635
+ result.setValue(it["objArea"] as? Double, forKey: "objArea")
636
+ result.setValue(it["objIntAngleDev"] as? Double, forKey: "objIntAngleDev")
637
+ result.setValue(it["resultStatus"] as Any?, forKey: "resultStatus")
638
+ result.setValue(it["docFormat"] as Any?, forKey: "docFormat")
639
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
640
+ result.setValue(it["dpi"] as? Int, forKey: "dpi")
641
+ result.setValue(it["inverse"] as? Int, forKey: "inverse")
642
+ return result
643
+ }
644
+ func encode() -> [String: Any?] {
645
+ return [
646
+ "width": self.size.width,
647
+ "height": self.size.height,
648
+ "angle": self.angle,
649
+ "center": self.center.encode(),
650
+ "leftTop": self.leftTop.encode(),
651
+ "leftBottom": self.leftBottom.encode(),
652
+ "rightTop": self.rightTop.encode(),
653
+ "rightBottom": self.rightBottom.encode(),
654
+ "perspectiveTr": self.perspectiveTr,
655
+ "objArea": self.objArea,
656
+ "objIntAngleDev": self.objIntAngleDev,
657
+ "resultStatus": self.resultStatus.rawValue,
658
+ "docFormat": self.docFormat.rawValue,
659
+ "pageIndex": self.pageIndex,
660
+ "dpi": self.dpi,
661
+ "inverse": self.inverse,
662
+ ]
663
+ }
664
+ }
665
+
666
+ public extension DocumentReaderResults {
667
+ static func decode(_ it: Any?) -> Self? {
668
+ guard let it = it as? [String: Any] else { return nil }
669
+ let result = Self.emptyInit() as Self
670
+ result.setValue((it["documentType"] as? [Any])?.compactMap(DocumentReaderDocumentType.decode), forKey: "documentType")
671
+ result.setValue(DocumentReaderTextResult.decode(it["textResult"]), forKey: "textResult")
672
+ result.setValue(DocumentReaderGraphicResult.decode(it["graphicResult"]), forKey: "graphicResult")
673
+ result.setValue((it["documentPosition"] as? [Any])?.compactMap(DocumentPosition.decode), forKey: "documentPosition")
674
+ result.setValue((it["barcodePosition"] as? [Any])?.compactMap(BarcodePosition.decode), forKey: "barcodePosition")
675
+ result.setValue((it["mrzPosition"] as? [Any])?.compactMap(MrzPosition.decode), forKey: "mrzPosition")
676
+ result.setValue((it["imageQuality"] as? [Any])?.compactMap(ImageQualityGroup.decode), forKey: "imageQualityGroup")
677
+ result.setValue(DocumentReaderAuthenticityResult.decode(it["authenticityResult"]), forKey: "authenticityResults")
678
+ result.setValue(RFIDSessionData.decode(it["rfidSessionData"]), forKey: "rfidSessionData")
679
+ result.setValue(it["chipPage"] as? Int, forKey: "chipPage")
680
+ result.setValue(DocumentReaderBarcodeResult.decode(it["barcodeResult"]), forKey: "barcodeResult")
681
+ result.setValue(it["processingFinishedStatus"] as Any?, forKey: "processingFinishedStatus")
682
+ result.setValue(it["morePagesAvailable"] as? Int, forKey: "morePagesAvailable")
683
+ result.setValue(it["elapsedTime"] as? Int, forKey: "elapsedTime")
684
+ result.setValue(it["elapsedTimeRFID"] as? Int, forKey: "elapsedTimeRFID")
685
+ result.setValue(it["rawResult"] as? String, forKey: "rawResult")
686
+ result.setValue(it["bsiTr03135Results"] as? String, forKey: "bsiTr03135Results")
687
+ result.setValue(DocumentReaderResults.Status.decode(it["status"]), forKey: "status")
688
+ result.setValue(VDSNCData.decode(it["vdsncData"]), forKey: "vdsncData")
689
+ result.setValue(VDSData.decode(it["vdsData"]), forKey: "vdsData")
690
+ result.setValue(Data.decode(it["dtcData"]), forKey: "dtcData")
691
+ result.setValue(RGLTransactionInfo.decode(it["transactionInfo"]), forKey: "transactionInfo")
692
+ return result
693
+ }
694
+ func encode() -> [String: Any?] {
695
+ return [
696
+ "documentType": self.documentType?.map { $0.encode() },
697
+ "textResult": self.textResult.encode(),
698
+ "graphicResult": self.graphicResult.encode(),
699
+ "documentPosition": self.documentPosition?.map { $0.encode() },
700
+ "barcodePosition": self.barcodePosition?.map { $0.encode() },
701
+ "mrzPosition": self.mrzPosition?.map { $0.encode() },
702
+ "imageQuality": self.imageQualityGroup?.map { $0.encode() },
703
+ "authenticityResult": self.authenticityResults?.encode(),
704
+ "rfidSessionData": self.rfidSessionData?.encode(),
705
+ "chipPage": self.chipPage,
706
+ "barcodeResult": self.barcodeResult.encode(),
707
+ "processingFinishedStatus": self.processingFinishedStatus.rawValue,
708
+ "morePagesAvailable": self.morePagesAvailable,
709
+ "elapsedTime": self.elapsedTime,
710
+ "elapsedTimeRFID": self.elapsedTimeRFID,
711
+ "rawResult": self.rawResult,
712
+ "bsiTr03135Results": self.bsiTr03135Results,
713
+ "status": self.status.encode(),
714
+ "vdsncData": self.vdsncData?.encode(),
715
+ "vdsData": self.vdsData?.encode(),
716
+ "dtcData": self.dtcData?.encode(),
717
+ "transactionInfo": self.transactionInfo?.encode(),
718
+ ]
719
+ }
720
+ }
721
+
722
+ public extension RGLTransactionInfo {
723
+ static func decode(_ it: Any?) -> Self? {
724
+ guard let it = it as? [String: Any] else { return nil }
725
+ let result = Self.emptyInit() as Self
726
+ result.setValue(it["transactionId"] as? String, forKey: "transactionId")
727
+ result.setValue(it["tag"] as? String, forKey: "tag")
728
+ result.setValue(it["sessionLogFolder"] as? String, forKey: "sessionLogFolder")
729
+ return result
730
+ }
731
+ func encode() -> [String: Any?] {
732
+ return [
733
+ "transactionId": self.transactionId,
734
+ "tag": self.tag,
735
+ "sessionLogFolder": self.sessionLogFolder,
736
+ ]
737
+ }
738
+ }
739
+
740
+ // MARK: - Results / Authenticity
741
+
742
+ public extension AuthenticityCheck {
743
+ static func decode(_ it: Any?) -> Self? {
744
+ guard let it = it as? [String: Any] else { return nil }
745
+ let result = Self.emptyInit() as Self
746
+ result.setValue(it["type"] as Any?, forKey: "type")
747
+ result.setValue(it["status"] as Any?, forKey: "status")
748
+ result.setValue((it["elements"] as? [Any])?.compactMap(AuthenticityElement.decode), forKey: "elements")
749
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
750
+ return result
751
+ }
752
+ func encode() -> [String: Any?] {
753
+ return [
754
+ "type": self.type.rawValue,
755
+ "typeName": self.typeName,
756
+ "status": self.status.rawValue,
757
+ "elements": self.elements?.map { $0.encode() },
758
+ "pageIndex": self.pageIndex,
759
+ ]
760
+ }
761
+ }
762
+
763
+ public extension AuthenticityElement {
764
+ static func decode(_ it: Any?) -> Self? {
765
+ guard let it = it as? [String: Any] else { return nil }
766
+ let result = Self.emptyInit() as Self
767
+ result.setValue(it["status"] as Any?, forKey: "status")
768
+ result.setValue(it["elementType"] as Any?, forKey: "elementType")
769
+ result.setValue(it["elementDiagnose"] as Any?, forKey: "elementDiagnose")
770
+ return result
771
+ }
772
+ func encode() -> [String: Any?] {
773
+ return [
774
+ "status": self.status.rawValue,
775
+ "elementType": self.elementType.rawValue,
776
+ "elementTypeName": self.elementTypeName,
777
+ "elementDiagnose": self.elementDiagnose.rawValue,
778
+ "elementDiagnoseName": self.elementDiagnoseName,
779
+ ]
780
+ }
781
+ }
782
+
783
+ public extension DocumentReaderAuthenticityResult {
784
+ static func decode(_ it: Any?) -> Self? {
785
+ guard let it = it as? [String: Any] else { return nil }
786
+ let result = Self.emptyInit() as Self
787
+ result.setValue(it["status"] as Any?, forKey: "security")
788
+ result.setValue((it["checks"] as? [Any])?.compactMap(AuthenticityCheck.decode), forKey: "checks")
789
+ return result
790
+ }
791
+ func encode() -> [String: Any?] {
792
+ return [
793
+ "status": self.status.rawValue,
794
+ "checks": self.checks?.map { $0.encode() },
795
+ ]
796
+ }
797
+ }
798
+
799
+ // MARK: - Results / Barcode
800
+
801
+ public extension DocumentReaderBarcodeField {
802
+ static func decode(_ it: Any?) -> Self? {
803
+ guard let it = it as? [String: Any] else { return nil }
804
+ let result = Self.emptyInit() as Self
805
+ result.setValue(it["barcodeType"] as Any?, forKey: "barcodeType")
806
+ result.setValue(it["status"] as Any?, forKey: "status")
807
+ result.setValue(PDF417Info.decode(it["pdf417Info"]), forKey: "pdf417Info")
808
+ result.setValue(Data.decode(it["data"]), forKey: "data")
809
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
810
+ return result
811
+ }
812
+ func encode() -> [String: Any?] {
813
+ return [
814
+ "barcodeType": self.barcodeType.rawValue,
815
+ "status": self.status.rawValue,
816
+ "pdf417Info": self.pdf417Info?.encode(),
817
+ "data": self.data.encode(),
818
+ "pageIndex": self.pageIndex,
819
+ ]
820
+ }
821
+ }
822
+
823
+ public extension DocumentReaderBarcodeResult {
824
+ static func decode(_ it: Any?) -> Self? {
825
+ guard let it = it as? [String: Any] else { return nil }
826
+ let result = Self.emptyInit() as Self
827
+ result.setValue((it["fields"] as? [Any])?.compactMap(DocumentReaderBarcodeField.decode), forKey: "fields")
828
+ return result
829
+ }
830
+ func encode() -> [String: Any?] {
831
+ return [
832
+ "fields": self.fields?.map { $0.encode() },
833
+ ]
834
+ }
835
+ }
836
+
837
+ public extension PDF417Info {
838
+ static func decode(_ it: Any?) -> Self? {
839
+ guard let it = it as? [String: Any] else { return nil }
840
+ let result = Self.emptyInit() as Self
841
+ result.setValue(it["errorLevel"] as? Int, forKey: "errorLevel")
842
+ result.setValue(it["columns"] as? Int, forKey: "columns")
843
+ result.setValue(it["rows"] as? Int, forKey: "rows")
844
+ return result
845
+ }
846
+ func encode() -> [String: Any?] {
847
+ return [
848
+ "errorLevel": self.errorLevel,
849
+ "columns": self.columns,
850
+ "rows": self.rows,
851
+ ]
852
+ }
853
+ }
854
+
855
+ // MARK: - Results / Image Quality
856
+
857
+ public extension ImageQuality {
858
+ static func decode(_ it: Any?) -> Self? {
859
+ guard let it = it as? [String: Any] else { return nil }
860
+ let result = Self.emptyInit() as Self
861
+ result.setValue(ImageQualityCheckType.decode(it["type"]).rawValue, forKey: "type")
862
+ result.setValue(it["result"] as Any?, forKey: "result")
863
+ result.setValue(it["featureType"] as Any?, forKey: "featureType")
864
+ result.setValue((it["boundRects"] as? [Any])?.map { NSValue(cgRect: CGRect.decode($0)) }, forKey: "boundRects")
865
+ return result
866
+ }
867
+ func encode() -> [String: Any?] {
868
+ return [
869
+ "type": ImageQualityCheckType(rawValue: self.type as String).encode(),
870
+ "result": self.result.rawValue,
871
+ "featureType": self.featureType.rawValue,
872
+ "boundRects": self.boundRects.compactMap { $0.cgRectValue.encode() },
873
+ ]
874
+ }
875
+ }
876
+
877
+ public extension ImageQualityGroup {
878
+ static func decode(_ it: Any?) -> Self? {
879
+ guard let it = it as? [String: Any] else { return nil }
880
+ let result = Self.emptyInit() as Self
881
+ result.setValue(it["count"] as? Int, forKey: "count")
882
+ result.setValue(it["result"] as Any?, forKey: "result")
883
+ result.setValue((it["imageQualityList"] as? [Any])?.compactMap(ImageQuality.decode), forKey: "imageQualityList")
884
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
885
+ return result
886
+ }
887
+ func encode() -> [String: Any?] {
888
+ return [
889
+ "count": self.count,
890
+ "result": self.result.rawValue,
891
+ "imageQualityList": self.imageQualityList.map { $0.encode() },
892
+ "pageIndex": self.pageIndex,
893
+ ]
894
+ }
895
+ }
896
+
897
+ // MARK: - Results / RFID
898
+
899
+ public extension AccessControlProcedureType {
900
+ static func decode(_ it: Any?) -> Self? {
901
+ guard let it = it as? [String: Any] else { return nil }
902
+ let result = Self.emptyInit() as Self
903
+ result.setValue(it["activeOptionIdx"] as? Int, forKey: "activeOptionIdx")
904
+ result.setValue(it["notifications"] as? [NSNumber], forKey: "notifications")
905
+ result.setValue(it["status"] as Any?, forKey: "status")
906
+ result.setValue(it["type"] as Any?, forKey: "type")
907
+ return result
908
+ }
909
+ func encode() -> [String: Any?] {
910
+ return [
911
+ "activeOptionIdx": self.activeOptionIdx,
912
+ "notifications": self.notifications,
913
+ "status": self.status.rawValue,
914
+ "type": self.type.rawValue,
915
+ ]
916
+ }
917
+ }
918
+
919
+ public extension Application {
920
+ static func decode(_ it: Any?) -> Self? {
921
+ guard let it = it as? [String: Any] else { return nil }
922
+ let result = Self.emptyInit() as Self
923
+ result.setValue(it["applicationID"] as? String, forKey: "applicationID")
924
+ result.setValue(it["dataHashAlgorithm"] as? String, forKey: "dataHashAlgorithm")
925
+ result.setValue((it["files"] as? [Any])?.compactMap(File.decode), forKey: "files")
926
+ result.setValue(it["type"] as Any?, forKey: "type")
927
+ result.setValue(it["status"] as Any?, forKey: "status")
928
+ result.setValue(it["unicodeVersion"] as? String, forKey: "unicodeVersion")
929
+ result.setValue(it["version"] as? String, forKey: "version")
930
+ return result
931
+ }
932
+ func encode() -> [String: Any?] {
933
+ return [
934
+ "applicationID": self.applicationID,
935
+ "dataHashAlgorithm": self.dataHashAlgorithm,
936
+ "files": self.files.map { $0.encode() },
937
+ "type": self.type.rawValue,
938
+ "status": self.status.rawValue,
939
+ "unicodeVersion": self.unicodeVersion,
940
+ "version": self.version,
941
+ ]
942
+ }
943
+ }
944
+
945
+ public extension Attribute {
946
+ static func decode(_ it: Any?) -> Self? {
947
+ guard let it = it as? [String: Any] else { return nil }
948
+ let result = Self.emptyInit() as Self
949
+ result.setValue(it["type"] as? String, forKey: "type")
950
+ result.setValue(RFIDValue.decode(it["value"]), forKey: "value")
951
+ return result
952
+ }
953
+ func encode() -> [String: Any?] {
954
+ return [
955
+ "type": self.type,
956
+ "value": self.value.encode(),
957
+ ]
958
+ }
959
+ }
960
+
961
+ public extension Authority {
962
+ static func decode(_ it: Any?) -> Self? {
963
+ guard let it = it as? [String: Any] else { return nil }
964
+ let result = Self.emptyInit() as Self
965
+ result.setValue((it["attributes"] as? [Any])?.compactMap(Attribute.decode), forKey: "attributes")
966
+ result.setValue(it["data"] as? String, forKey: "data")
967
+ result.setValue(RFIDValue.decode(it["friendlyName"]), forKey: "friendlyName")
968
+ return result
969
+ }
970
+ func encode() -> [String: Any?] {
971
+ return [
972
+ "attributes": self.attributes.map { $0.encode() },
973
+ "data": self.data,
974
+ "friendlyName": self.friendlyName.encode(),
975
+ ]
976
+ }
977
+ }
978
+
979
+ public extension CardProperties {
980
+ static func decode(_ it: Any?) -> Self? {
981
+ guard let it = it as? [String: Any] else { return nil }
982
+ let result = Self.emptyInit() as Self
983
+ result.setValue(it["aTQA"] as? Int, forKey: "aTQA")
984
+ result.setValue(it["aTQB"] as? String, forKey: "aTQB")
985
+ result.setValue(it["aTR"] as? String, forKey: "aTR")
986
+ result.setValue(it["baudrate1"] as? String, forKey: "baudrate1")
987
+ result.setValue(it["baudrate2"] as? String, forKey: "baudrate2")
988
+ result.setValue(it["bitRateR"] as? Int, forKey: "bitRateR")
989
+ result.setValue(it["bitRateS"] as? Int, forKey: "bitRateS")
990
+ result.setValue(it["chipTypeA"] as? Int, forKey: "chipTypeA")
991
+ result.setValue(it["mifareMemory"] as? Int, forKey: "mifareMemory")
992
+ result.setValue(it["rfidType"] as? Int, forKey: "rfidType")
993
+ result.setValue(it["sAK"] as? Int, forKey: "sAK")
994
+ result.setValue(it["support4"] as? Bool, forKey: "support4")
995
+ result.setValue(it["supportMifare"] as? Bool, forKey: "supportMifare")
996
+ result.setValue(it["uID"] as? String, forKey: "uID")
997
+ return result
998
+ }
999
+ func encode() -> [String: Any?] {
1000
+ return [
1001
+ "aTQA": self.aTQA,
1002
+ "aTQB": self.aTQB,
1003
+ "aTR": self.aTR,
1004
+ "baudrate1": self.baudrate1,
1005
+ "baudrate2": self.baudrate2,
1006
+ "bitRateR": self.bitRateR,
1007
+ "bitRateS": self.bitRateS,
1008
+ "chipTypeA": self.chipTypeA,
1009
+ "mifareMemory": self.mifareMemory,
1010
+ "rfidType": self.rfidType,
1011
+ "sAK": self.sAK,
1012
+ "support4": self.support4,
1013
+ "supportMifare": self.supportMifare,
1014
+ "uID": self.uID,
1015
+ ]
1016
+ }
1017
+ }
1018
+
1019
+ public extension CertificateChain {
1020
+ static func decode(_ it: Any?) -> Self? {
1021
+ guard let it = it as? [String: Any] else { return nil }
1022
+ let result = Self.emptyInit() as Self
1023
+ result.setValue((it["extensions"] as? [Any])?.compactMap(Extension.decode), forKey: "extensions")
1024
+ result.setValue(RFIDValue.decode(it["fileName"]), forKey: "fileName")
1025
+ result.setValue(Authority.decode(it["issuer"]), forKey: "issuer")
1026
+ result.setValue(it["notifications"] as? [NSNumber], forKey: "notifications")
1027
+ result.setValue(it["origin"] as? Int, forKey: "origin")
1028
+ result.setValue(it["paStatus"] as? Double, forKey: "paStatus")
1029
+ result.setValue(it["serialNumber"] as? String, forKey: "serialNumber")
1030
+ result.setValue(it["signatureAlgorithm"] as? String, forKey: "signatureAlgorithm")
1031
+ result.setValue(Authority.decode(it["subject"]), forKey: "subject")
1032
+ result.setValue(it["subjectPKAlgorithm"] as? String, forKey: "subjectPKAlgorithm")
1033
+ result.setValue(it["type"] as Any?, forKey: "type")
1034
+ result.setValue(Validity.decode(it["validity"]), forKey: "validity")
1035
+ result.setValue(it["version"] as? Int, forKey: "version")
1036
+ return result
1037
+ }
1038
+ func encode() -> [String: Any?] {
1039
+ return [
1040
+ "extensions": self.extensions.map { $0.encode() },
1041
+ "fileName": self.fileName.encode(),
1042
+ "issuer": self.issuer.encode(),
1043
+ "notifications": self.notifications,
1044
+ "origin": self.origin,
1045
+ "paStatus": self.paStatus,
1046
+ "serialNumber": self.serialNumber,
1047
+ "signatureAlgorithm": self.signatureAlgorithm,
1048
+ "subject": self.subject.encode(),
1049
+ "subjectPKAlgorithm": self.subjectPKAlgorithm,
1050
+ "type": self.type.rawValue,
1051
+ "validity": self.validity.encode(),
1052
+ "version": self.version,
1053
+ ]
1054
+ }
1055
+ }
1056
+
1057
+ public extension CertificateData {
1058
+ static func decode(_ it: Any?) -> Self? {
1059
+ guard let it = it as? [String: Any] else { return nil }
1060
+ let result = Self.emptyInit() as Self
1061
+ result.setValue(it["data"] as? String, forKey: "data")
1062
+ result.setValue(it["length"] as? Int, forKey: "length")
1063
+ return result
1064
+ }
1065
+ func encode() -> [String: Any?] {
1066
+ return [
1067
+ "data": self.data,
1068
+ "length": self.length,
1069
+ ]
1070
+ }
1071
+ }
1072
+
1073
+ public extension DataField {
1074
+ static func decode(_ it: Any?) -> Self? {
1075
+ guard let it = it as? [String: Any] else { return nil }
1076
+ let result = Self.emptyInit() as Self
1077
+ result.setValue(it["data"] as? String, forKey: "data")
1078
+ result.setValue(it["fieldType"] as? Int, forKey: "fieldType")
1079
+ return result
1080
+ }
1081
+ func encode() -> [String: Any?] {
1082
+ return [
1083
+ "data": self.data,
1084
+ "fieldType": self.fieldType,
1085
+ ]
1086
+ }
1087
+ }
1088
+
1089
+ public extension Extension {
1090
+ static func decode(_ it: Any?) -> Self? {
1091
+ guard let it = it as? [String: Any] else { return nil }
1092
+ let result = Self.emptyInit() as Self
1093
+ result.setValue(it["data"] as? String, forKey: "data")
1094
+ result.setValue(it["type"] as? String, forKey: "type")
1095
+ return result
1096
+ }
1097
+ func encode() -> [String: Any?] {
1098
+ return [
1099
+ "data": self.data,
1100
+ "type": self.type,
1101
+ ]
1102
+ }
1103
+ }
1104
+
1105
+ public extension File {
1106
+ static func decode(_ it: Any?) -> Self? {
1107
+ guard let it = it as? [String: Any] else { return nil }
1108
+ let result = Self.emptyInit() as Self
1109
+ result.setValue(FileData.decode(it["fileData"]), forKey: "fileData")
1110
+ result.setValue(it["fileID"] as? String, forKey: "fileID")
1111
+ result.setValue(it["notifications"] as? [NSNumber], forKey: "notifications")
1112
+ result.setValue(it["pAStatus"] as Any?, forKey: "pAStatus")
1113
+ result.setValue(it["readingStatus"] as Any?, forKey: "readingStatus")
1114
+ result.setValue(it["readingTime"] as? Int, forKey: "readingTime")
1115
+ result.setValue(it["type"] as Any?, forKey: "type")
1116
+ result.setValue(it["typeName"] as? String, forKey: "typeName")
1117
+ result.setValue(it["docFieldsText"] as? [NSNumber], forKey: "docFieldsText")
1118
+ result.setValue(it["docFieldsGraphics"] as? [NSNumber], forKey: "docFieldsGraphics")
1119
+ result.setValue(it["docFieldsOriginals"] as? [NSNumber], forKey: "docFieldsOriginals")
1120
+ result.setValue(SecurityObjectCertificates.decode(it["certificates"]), forKey: "certificates")
1121
+ return result
1122
+ }
1123
+ func encode() -> [String: Any?] {
1124
+ return [
1125
+ "fileData": self.fileData.encode(),
1126
+ "fileID": self.fileID,
1127
+ "notifications": self.notifications,
1128
+ "pAStatus": self.pAStatus.rawValue,
1129
+ "readingStatus": self.readingStatus.rawValue,
1130
+ "readingTime": self.readingTime,
1131
+ "type": self.type.rawValue,
1132
+ "typeName": self.typeName,
1133
+ "docFieldsText": self.docFieldsText,
1134
+ "docFieldsGraphics": self.docFieldsGraphics,
1135
+ "docFieldsOriginals": self.docFieldsOriginals,
1136
+ "certificates": self.certificates.encode(),
1137
+ ]
1138
+ }
1139
+ }
1140
+
1141
+ public extension FileData {
1142
+ static func decode(_ it: Any?) -> Self? {
1143
+ guard let it = it as? [String: Any] else { return nil }
1144
+ let result = Self.emptyInit() as Self
1145
+ result.setValue(it["data"] as? String, forKey: "data")
1146
+ result.setValue(it["length"] as? Int, forKey: "length")
1147
+ result.setValue(it["status"] as? Double, forKey: "status")
1148
+ result.setValue(it["type"] as? Int, forKey: "type")
1149
+ return result
1150
+ }
1151
+ func encode() -> [String: Any?] {
1152
+ return [
1153
+ "data": self.data,
1154
+ "length": self.length,
1155
+ "status": self.status,
1156
+ "type": self.type,
1157
+ ]
1158
+ }
1159
+ }
1160
+
1161
+ public extension RFIDSessionData {
1162
+ static func decode(_ it: Any?) -> Self? {
1163
+ guard let it = it as? [String: Any] else { return nil }
1164
+ let result = Self.emptyInit() as Self
1165
+ result.setValue((it["accessControls"] as? [Any])?.compactMap(AccessControlProcedureType.decode), forKey: "accessControls")
1166
+ result.setValue((it["applications"] as? [Any])?.compactMap(Application.decode), forKey: "applications")
1167
+ result.setValue((it["securityObjects"] as? [Any])?.compactMap(SecurityObject.decode), forKey: "securityObjects")
1168
+ result.setValue(CardProperties.decode(it["cardProperties"]), forKey: "cardProperties")
1169
+ result.setValue(it["totalBytesReceived"] as? Int, forKey: "totalBytesReceived")
1170
+ result.setValue(it["totalBytesSent"] as? Int, forKey: "totalBytesSent")
1171
+ result.setValue(it["status"] as Any?, forKey: "status")
1172
+ result.setValue(it["extLeSupport"] as Any?, forKey: "extLeSupport")
1173
+ result.setValue(it["processTime"] as? Double, forKey: "processTime")
1174
+ result.setValue(it["dataGroups"] as? [NSNumber], forKey: "dataGroups")
1175
+ result.setValue((it["dataFields"] as? [Any])?.compactMap(DataField.decode), forKey: "dataFields")
1176
+ return result
1177
+ }
1178
+ func encode() -> [String: Any?] {
1179
+ return [
1180
+ "accessControls": self.accessControls.map { $0.encode() },
1181
+ "applications": self.applications.map { $0.encode() },
1182
+ "securityObjects": self.securityObjects.map { $0.encode() },
1183
+ "cardProperties": self.cardProperties.encode(),
1184
+ "totalBytesReceived": self.totalBytesReceived,
1185
+ "totalBytesSent": self.totalBytesSent,
1186
+ "status": self.status.rawValue,
1187
+ "extLeSupport": self.extLeSupport.rawValue,
1188
+ "processTime": self.processTime,
1189
+ "dataGroups": self.dataGroups,
1190
+ "dataFields": self.dataFields.map { $0.encode() },
1191
+ ]
1192
+ }
1193
+ }
1194
+
1195
+ public extension Validity {
1196
+ static func decode(_ it: Any?) -> Self? {
1197
+ guard let it = it as? [String: Any] else { return nil }
1198
+ let result = Self.emptyInit() as Self
1199
+ result.setValue(RFIDValue.decode(it["notAfter"]), forKey: "notAfter")
1200
+ result.setValue(RFIDValue.decode(it["notBefore"]), forKey: "notBefore")
1201
+ return result
1202
+ }
1203
+ func encode() -> [String: Any?] {
1204
+ return [
1205
+ "notAfter": self.notAfter.encode(),
1206
+ "notBefore": self.notBefore.encode(),
1207
+ ]
1208
+ }
1209
+ }
1210
+
1211
+ public extension RFIDValue {
1212
+ static func decode(_ it: Any?) -> Self? {
1213
+ guard let it = it as? [String: Any] else { return nil }
1214
+ let result = Self.emptyInit() as Self
1215
+ result.setValue(it["data"] as? String, forKey: "data")
1216
+ result.setValue(it["length"] as? Int, forKey: "length")
1217
+ result.setValue(it["status"] as? Double, forKey: "status")
1218
+ result.setValue(it["type"] as? Int, forKey: "type")
1219
+ result.setValue(it["format"] as? String, forKey: "format")
1220
+ return result
1221
+ }
1222
+ func encode() -> [String: Any?] {
1223
+ return [
1224
+ "data": self.data,
1225
+ "length": self.length,
1226
+ "status": self.status,
1227
+ "type": self.type,
1228
+ "format": self.format,
1229
+ ]
1230
+ }
1231
+ }
1232
+
1233
+ public extension SecurityObject {
1234
+ static func decode(_ it: Any?) -> Self? {
1235
+ guard let it = it as? [String: Any] else { return nil }
1236
+ let result = Self.emptyInit() as Self
1237
+ result.setValue(it["fileReference"] as? Int, forKey: "fileReference")
1238
+ result.setValue(it["objectType"] as? String, forKey: "objectType")
1239
+ result.setValue(it["version"] as? Int, forKey: "version")
1240
+ result.setValue((it["signerInfos"] as? [Any])?.compactMap(SignerInfo.decode), forKey: "signerInfos")
1241
+ result.setValue(it["notifications"] as? [NSNumber], forKey: "notifications")
1242
+ return result
1243
+ }
1244
+ func encode() -> [String: Any?] {
1245
+ return [
1246
+ "fileReference": self.fileReference,
1247
+ "objectType": self.objectType,
1248
+ "version": self.version,
1249
+ "signerInfos": self.signerInfos.map { $0.encode() },
1250
+ "notifications": self.notifications,
1251
+ ]
1252
+ }
1253
+ }
1254
+
1255
+ public extension SecurityObjectCertificates {
1256
+ static func decode(_ it: Any?) -> Self? {
1257
+ guard let it = it as? [String: Any] else { return nil }
1258
+ let result = Self.emptyInit() as Self
1259
+ result.setValue(CertificateData.decode(it["securityObject"]), forKey: "securityObject")
1260
+ return result
1261
+ }
1262
+ func encode() -> [String: Any?] {
1263
+ return [
1264
+ "securityObject": self.securityObject.encode(),
1265
+ ]
1266
+ }
1267
+ }
1268
+
1269
+ public extension SignerInfo {
1270
+ static func decode(_ it: Any?) -> Self? {
1271
+ guard let it = it as? [String: Any] else { return nil }
1272
+ let result = Self.emptyInit() as Self
1273
+ result.setValue(it["dataToHash"] as? String, forKey: "dataToHash")
1274
+ result.setValue(it["digestAlgorithm"] as? String, forKey: "digestAlgorithm")
1275
+ result.setValue(it["paStatus"] as? Double, forKey: "paStatus")
1276
+ result.setValue(it["signatureAlgorithm"] as? String, forKey: "signatureAlgorithm")
1277
+ result.setValue(it["version"] as? Int, forKey: "version")
1278
+ result.setValue(Authority.decode(it["issuer"]), forKey: "issuer")
1279
+ result.setValue(RFIDValue.decode(it["serialNumber"]), forKey: "serialNumber")
1280
+ result.setValue(RFIDValue.decode(it["signature"]), forKey: "signature")
1281
+ result.setValue((it["signedAttributes"] as? [Any])?.compactMap(Extension.decode), forKey: "signedAttributes")
1282
+ result.setValue(RFIDValue.decode(it["subjectKeyIdentifier"]), forKey: "subjectKeyIdentifier")
1283
+ result.setValue((it["certificateChain"] as? [Any])?.compactMap(CertificateChain.decode), forKey: "certificateChain")
1284
+ result.setValue(it["notifications"] as? [NSNumber], forKey: "notifications")
1285
+ return result
1286
+ }
1287
+ func encode() -> [String: Any?] {
1288
+ return [
1289
+ "dataToHash": self.dataToHash,
1290
+ "digestAlgorithm": self.digestAlgorithm,
1291
+ "paStatus": self.paStatus,
1292
+ "signatureAlgorithm": self.signatureAlgorithm,
1293
+ "version": self.version,
1294
+ "issuer": self.issuer.encode(),
1295
+ "serialNumber": self.serialNumber.encode(),
1296
+ "signature": self.signature.encode(),
1297
+ "signedAttributes": self.signedAttributes.map { $0.encode() },
1298
+ "subjectKeyIdentifier": self.subjectKeyIdentifier.encode(),
1299
+ "certificateChain": self.certificateChain.map { $0.encode() },
1300
+ "notifications": self.notifications,
1301
+ ]
1302
+ }
1303
+ }
1304
+
1305
+ // MARK: - Results / Status
1306
+
1307
+ public extension DetailsAge {
1308
+ static func decode(_ it: Any?) -> Self? {
1309
+ guard let it = it as? [String: Any] else { return nil }
1310
+ return perform("detailsAgeWithJSON:".selector(), with: it).takeUnretainedValue() as? Self
1311
+ }
1312
+ func encode() -> [String: Any?] {
1313
+ return [
1314
+ "threshold": self.threshold,
1315
+ "overThreshold": self.overThreshold.rawValue,
1316
+ "over18": self.over18.rawValue,
1317
+ "over21": self.over21.rawValue,
1318
+ "over25": self.over25.rawValue,
1319
+ "over65": self.over65.rawValue,
1320
+ ]
1321
+ }
1322
+ }
1323
+
1324
+ public extension OpticalStatus {
1325
+ static func decode(_ it: Any?) -> Self? {
1326
+ guard let it = it as? [String: Any] else { return nil }
1327
+ return perform("opticalStatusWithJSON:".selector(), with: it).takeUnretainedValue() as? Self
1328
+ }
1329
+ func encode() -> [String: Any?] {
1330
+ return [
1331
+ "overallStatus": self.overallStatus.rawValue,
1332
+ "mrz": self.mrz.rawValue,
1333
+ "text": self.text.rawValue,
1334
+ "docType": self.docType.rawValue,
1335
+ "security": self.security.rawValue,
1336
+ "imageQA": self.imageQA.rawValue,
1337
+ "expiry": self.expiry.rawValue,
1338
+ "vds": self.vds.rawValue,
1339
+ "pagesCount": self.pagesCount,
1340
+ ]
1341
+ }
1342
+ }
1343
+
1344
+ public extension DocumentReaderResults.Status {
1345
+ static func decode(_ it: Any?) -> Self? {
1346
+ guard let it = it as? [String: Any] else { return nil }
1347
+ var json = it
1348
+ if var rfid = it["detailsRFID"] as? [String: Any] {
1349
+ rfid["AA"] = rfid["aa"]
1350
+ rfid["BAC"] = rfid["bac"]
1351
+ rfid["CA"] = rfid["ca"]
1352
+ rfid["PA"] = rfid["pa"]
1353
+ rfid["PACE"] = rfid["pace"]
1354
+ rfid["TA"] = rfid["ta"]
1355
+ json["detailsRFID"] = rfid
1356
+ }
1357
+ return perform("resultsStatusWithJSON:".selector(), with: json).takeUnretainedValue() as? Self
1358
+ }
1359
+ func encode() -> [String: Any?] {
1360
+ return [
1361
+ "overallStatus": self.overallStatus.rawValue,
1362
+ "optical": self.optical.rawValue,
1363
+ "detailsOptical": self.detailsOptical.encode(),
1364
+ "rfid": self.rfid.rawValue,
1365
+ "detailsRFID": self.detailsRFID.encode(),
1366
+ "portrait": self.portrait.rawValue,
1367
+ "stopList": self.stopList.rawValue,
1368
+ "mDL": self.mDL.rawValue,
1369
+ "age": self.age.rawValue,
1370
+ "captureProcessIntegrity": self.captureProcessIntegrity.rawValue,
1371
+ "detailsAge": self.detailsAge.encode(),
1372
+ ]
1373
+ }
1374
+ }
1375
+
1376
+ public extension RFIDSessionDataStatus {
1377
+ static func decode(_ it: Any?) -> Self? {
1378
+ guard let it = it as? [String: Any] else { return nil }
1379
+ var json = it
1380
+ json["AA"] = it["aa"]
1381
+ json["BAC"] = it["bac"]
1382
+ json["CA"] = it["ca"]
1383
+ json["PA"] = it["pa"]
1384
+ json["PACE"] = it["pace"]
1385
+ json["TA"] = it["ta"]
1386
+ return perform("rfidStatusWithJSON:".selector(), with: json).takeUnretainedValue() as? Self
1387
+ }
1388
+ func encode() -> [String: Any?] {
1389
+ return [
1390
+ "aa": self.aa.rawValue,
1391
+ "bac": self.bac.rawValue,
1392
+ "ca": self.ca.rawValue,
1393
+ "pa": self.pa.rawValue,
1394
+ "pace": self.pace.rawValue,
1395
+ "ta": self.ta.rawValue,
1396
+ "overallStatus": self.overallStatus.rawValue,
1397
+ ]
1398
+ }
1399
+ }
1400
+
1401
+ // MARK: - Results / Visible Digital Seals
1402
+
1403
+ public extension BytesData {
1404
+ static func decode(_ it: Any?) -> Self? {
1405
+ guard let it = it as? [String: Any] else { return nil }
1406
+ var json = it
1407
+ json["Data"] = it["data"]
1408
+ json["Length"] = it["length"]
1409
+ json["Status"] = it["status"]
1410
+ json["Type"] = it["type"]
1411
+ return perform("bytesDataWithJSON:".selector(), with: json).takeUnretainedValue() as? Self
1412
+ }
1413
+ func encode() -> [String: Any?] {
1414
+ return [
1415
+ "data": self.data,
1416
+ "length": self.length,
1417
+ "status": self.status,
1418
+ "type": self.type,
1419
+ ]
1420
+ }
1421
+ }
1422
+
1423
+ public extension RGLDocFeature {
1424
+ static func decode(_ it: Any?) -> Self? {
1425
+ guard let it = it as? [String: Any] else { return nil }
1426
+ let result = Self.emptyInit() as Self
1427
+ result.setValue(it["type"] as? NSNumber, forKey: "type")
1428
+ result.setValue(BytesData.decode(it["data"]), forKey: "data")
1429
+ return result
1430
+ }
1431
+ func encode() -> [String: Any?] {
1432
+ return [
1433
+ "type": self.type,
1434
+ "data": self.data?.encode(),
1435
+ ]
1436
+ }
1437
+ }
1438
+
1439
+ public extension VDSData {
1440
+ static func decode(_ it: Any?) -> Self? {
1441
+ guard let it = it as? [String: Any] else { return nil }
1442
+ let alloc = Self.allocate()
1443
+ let sel = "initWithType:docType:featureRef:version:certificate:issuingCountry:docIssueDate:signature:signatureDate:signer:certificateChain:docFeatures:notifications:".selector()
1444
+ return privateInit(alloc, sel, (@convention(c)(
1445
+ Any, Selector,
1446
+ Int, Int, Int, Int, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?, Any?) -> Unmanaged<AnyObject>?).self, { f in f(
1447
+ alloc, sel,
1448
+ it["type"] as! Int, it["docType"] as! Int, it["featureRef"] as! Int, it["version"] as! Int,
1449
+ it["certificate"], it["issuingCountry"], it["docIssueDate"], BytesData.decode(it["signature"]),
1450
+ it["signatureDate"], it["signer"],
1451
+ (it["certificateChain"] as? [Any])?.compactMap(CertificateChain.decode) ?? [],
1452
+ (it["docFeatures"] as? [Any])?.compactMap(RGLDocFeature.decode) ?? [],
1453
+ it["notifications"]
1454
+ )})
1455
+ }
1456
+ func encode() -> [String: Any?] {
1457
+ return [
1458
+ "type": self.type,
1459
+ "docType": self.docType,
1460
+ "featureRef": self.featureRef,
1461
+ "version": self.version,
1462
+ "certificate": self.certificate,
1463
+ "issuingCountry": self.issuingCountry,
1464
+ "docIssueDate": self.docIssueDate,
1465
+ "signature": self.signature?.encode(),
1466
+ "signatureDate": self.signatureDate,
1467
+ "signer": self.signer,
1468
+ "certificateChain": self.certificateChain.map { $0.encode() },
1469
+ "docFeatures": self.docFeatures.map { $0.encode() },
1470
+ "notifications": self.notifications,
1471
+ ]
1472
+ }
1473
+ }
1474
+
1475
+ public extension VDSNCData {
1476
+ static func decode(_ it: Any?) -> Self? {
1477
+ guard let it = it as? [String: Any] else { return nil }
1478
+ let alloc = Self.allocate()
1479
+ let sel = "initWithType:version:issuingCountry:message:signatureAlgorithm:signature:certificate:certificateChain:notifications:".selector()
1480
+ return privateInit(alloc, sel, (@convention(c)(
1481
+ Any, Selector,
1482
+ Any?, Int, Any?, Any?, Any?, Any?, Any?, Any?, Any?) -> Unmanaged<AnyObject>?).self, { f in f(
1483
+ alloc, sel,
1484
+ it["type"], it["version"] as! Int, it["issuingCountry"], it["message"], it["signatureAlgorithm"],
1485
+ BytesData.decode(it["signature"]), BytesData.decode(it["certificate"]),
1486
+ (it["certificateChain"] as? [Any])?.compactMap(CertificateChain.decode) ?? [],
1487
+ it["notifications"]
1488
+ )})
1489
+ }
1490
+ func encode() -> [String: Any?] {
1491
+ return [
1492
+ "type": self.type,
1493
+ "version": self.version,
1494
+ "issuingCountry": self.issuingCountry,
1495
+ "message": self.message,
1496
+ "signatureAlgorithm": self.signatureAlgorithm,
1497
+ "signature": self.signature?.encode(),
1498
+ "certificate": self.certificate?.encode(),
1499
+ "certificateChain": self.certificateChain.map { $0.encode() },
1500
+ "notifications": self.notifications,
1501
+ ]
1502
+ }
1503
+ }
1504
+
1505
+ // MARK: - Results / Visual Results
1506
+
1507
+ public extension DocumentReaderComparison {
1508
+ static func decode(_ it: Any?) -> Self? {
1509
+ guard let it = it as? [String: Any] else { return nil }
1510
+ let result = Self.emptyInit() as Self
1511
+ result.setValue(it["sourceTypeLeft"] as Any?, forKey: "sourceTypeLeft")
1512
+ result.setValue(it["sourceTypeRight"] as Any?, forKey: "sourceTypeRight")
1513
+ result.setValue(it["status"] as Any?, forKey: "status")
1514
+ return result
1515
+ }
1516
+ func encode() -> [String: Any?] {
1517
+ return [
1518
+ "sourceTypeLeft": self.sourceTypeLeft.rawValue,
1519
+ "sourceTypeRight": self.sourceTypeRight.rawValue,
1520
+ "status": self.status.rawValue,
1521
+ ]
1522
+ }
1523
+ }
1524
+
1525
+ public extension DocumentReaderGraphicField {
1526
+ static func decode(_ it: Any?) -> Self? {
1527
+ guard let it = it as? [String: Any] else { return nil }
1528
+ let result = Self.emptyInit() as Self
1529
+ result.setValue(it["sourceType"] as Any?, forKey: "sourceType")
1530
+ result.setValue(it["fieldType"] as Any?, forKey: "fieldType")
1531
+ result.setValue(it["fieldName"] as? String, forKey: "fieldName")
1532
+ result.setValue(CGRect.decode(it["fieldRect"]), forKey: "boundRect")
1533
+ result.setValue(UIImage.decode(it["value"]), forKey: "value")
1534
+ result.setValue(it["light"] as Any?, forKey: "lightType")
1535
+ result.setValue(it["lightName"] as? String, forKey: "lightName")
1536
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
1537
+ result.setValue(it["originalPageIndex"] as? Int, forKey: "originalPageIndex")
1538
+ return result
1539
+ }
1540
+ func encode() -> [String: Any?] {
1541
+ return [
1542
+ "sourceType": self.sourceType.rawValue,
1543
+ "fieldType": self.fieldType.rawValue,
1544
+ "fieldName": self.fieldName,
1545
+ "fieldRect": self.boundRect.encode(),
1546
+ "value": self.value.encode(),
1547
+ "light": self.lightType.rawValue,
1548
+ "lightName": self.lightName,
1549
+ "pageIndex": self.pageIndex,
1550
+ "originalPageIndex": self.originalPageIndex,
1551
+ ]
1552
+ }
1553
+ }
1554
+
1555
+ public extension DocumentReaderGraphicResult {
1556
+ static func decode(_ it: Any?) -> Self? {
1557
+ guard let it = it as? [String: Any] else { return nil }
1558
+ let result = Self.emptyInit() as Self
1559
+ result.setValue((it["fields"] as? [Any])?.compactMap(DocumentReaderGraphicField.decode), forKey: "fields")
1560
+ return result
1561
+ }
1562
+ func encode() -> [String: Any?] {
1563
+ return [
1564
+ "fields": self.fields.map { $0.encode() },
1565
+ ]
1566
+ }
1567
+ }
1568
+
1569
+ public extension DocumentReaderRfidOrigin {
1570
+ static func decode(_ it: Any?) -> Self? {
1571
+ guard let it = it as? [String: Any] else { return nil }
1572
+ let result = Self.emptyInit() as Self
1573
+ result.setValue(it["dg"] as? Int, forKey: "dg")
1574
+ result.setValue(it["dgTag"] as? Int, forKey: "dgTag")
1575
+ result.setValue(it["entryView"] as? Int, forKey: "entryView")
1576
+ result.setValue(it["tagEntry"] as? Int, forKey: "tagEntry")
1577
+ return result
1578
+ }
1579
+ func encode() -> [String: Any?] {
1580
+ return [
1581
+ "dg": self.dg,
1582
+ "dgTag": self.dgTag,
1583
+ "entryView": self.entryView,
1584
+ "tagEntry": self.tagEntry,
1585
+ ]
1586
+ }
1587
+ }
1588
+
1589
+ public extension DocumentReaderSymbol {
1590
+ static func decode(_ it: Any?) -> Self? {
1591
+ guard let it = it as? [String: Any] else { return nil }
1592
+ let result = Self.emptyInit() as Self
1593
+ result.setValue(it["code"] as? Int, forKey: "code")
1594
+ result.setValue(CGRect.decode(it["rect"]), forKey: "rect")
1595
+ result.setValue(it["probability"] as? Int, forKey: "probability")
1596
+ return result
1597
+ }
1598
+ func encode() -> [String: Any?] {
1599
+ return [
1600
+ "code": self.code,
1601
+ "rect": self.rect.encode(),
1602
+ "probability": self.probability,
1603
+ ]
1604
+ }
1605
+ }
1606
+
1607
+ public extension DocumentReaderTextField {
1608
+ static func decode(_ it: Any?) -> Self? {
1609
+ guard let it = it as? [String: Any] else { return nil }
1610
+ let result = Self.emptyInit() as Self
1611
+ result.setValue(it["fieldType"] as Any?, forKey: "fieldType")
1612
+ result.setValue(it["fieldName"] as? String, forKey: "fieldName")
1613
+ result.setValue(it["lcid"] as Any?, forKey: "lcid")
1614
+ result.setValue((it["values"] as? [Any])?.compactMap(DocumentReaderValue.decode), forKey: "values")
1615
+ result.setValue(it["status"] as Any?, forKey: "status")
1616
+ result.setValue(it["comparisonStatus"] as Any?, forKey: "comparisonStatus")
1617
+ result.setValue(it["validityStatus"] as Any?, forKey: "validityStatus")
1618
+ result.setValue(it["value"] as? String, forKey: "value")
1619
+ result.setValue((it["comparisonList"] as? [Any])?.compactMap(DocumentReaderComparison.decode), forKey: "comparisonList")
1620
+ result.setValue((it["validityList"] as? [Any])?.compactMap(DocumentReaderValidity.decode), forKey: "validityList")
1621
+ return result
1622
+ }
1623
+ func encode() -> [String: Any?] {
1624
+ return [
1625
+ "fieldType": self.fieldType.rawValue,
1626
+ "fieldName": self.fieldName,
1627
+ "lcid": self.lcid.rawValue,
1628
+ "lcidName": self.lcidName,
1629
+ "values": self.values.map { $0.encode() },
1630
+ "status": self.status.rawValue,
1631
+ "comparisonStatus": self.comparisonStatus.rawValue,
1632
+ "validityStatus": self.validityStatus.rawValue,
1633
+ "value": self.value,
1634
+ "getValue": self.getValue()?.encode(),
1635
+ "comparisonList": self.comparisonList.map { $0.encode() },
1636
+ "validityList": self.validityList.map { $0.encode() },
1637
+ ]
1638
+ }
1639
+ }
1640
+
1641
+ public extension DocumentReaderTextResult {
1642
+ static func decode(_ it: Any?) -> Self? {
1643
+ guard let it = it as? [String: Any] else { return nil }
1644
+ let result = Self.emptyInit() as Self
1645
+ result.setValue((it["fields"] as? [Any])?.compactMap(DocumentReaderTextField.decode), forKey: "fields")
1646
+ result.setValue(it["status"] as Any?, forKey: "status")
1647
+ result.setValue(it["comparisonStatus"] as Any?, forKey: "comparisonStatus")
1648
+ result.setValue(it["validityStatus"] as Any?, forKey: "validityStatus")
1649
+ result.setValue((it["availableSourceList"] as? [Any])?.compactMap(DocumentReaderTextSource.decode), forKey: "availableSourceList")
1650
+ return result
1651
+ }
1652
+ func encode() -> [String: Any?] {
1653
+ return [
1654
+ "fields": self.fields.map { $0.encode() },
1655
+ "status": self.status.rawValue,
1656
+ "comparisonStatus": self.comparisonStatus.rawValue,
1657
+ "validityStatus": self.validityStatus.rawValue,
1658
+ "availableSourceList": self.availableSourceList.map { $0.encode() },
1659
+ ]
1660
+ }
1661
+ }
1662
+
1663
+ public extension DocumentReaderTextSource {
1664
+ static func decode(_ it: Any?) -> Self? {
1665
+ guard let it = it as? [String: Any] else { return nil }
1666
+ let result = Self.emptyInit() as Self
1667
+ result.setValue(it["sourceType"] as Any?, forKey: "sourceType")
1668
+ result.setValue(it["source"] as? String, forKey: "source")
1669
+ result.setValue(it["validityStatus"] as Any?, forKey: "validityStatus")
1670
+ return result
1671
+ }
1672
+ func encode() -> [String: Any?] {
1673
+ return [
1674
+ "sourceType": self.sourceType.rawValue,
1675
+ "source": self.value(forKey: "source"),
1676
+ "validityStatus": self.validityStatus.rawValue,
1677
+ ]
1678
+ }
1679
+ }
1680
+
1681
+ public extension DocumentReaderValidity {
1682
+ static func decode(_ it: Any?) -> Self? {
1683
+ guard let it = it as? [String: Any] else { return nil }
1684
+ let result = Self.emptyInit() as Self
1685
+ result.setValue(it["sourceType"] as Any?, forKey: "sourceType")
1686
+ result.setValue(it["status"] as Any?, forKey: "status")
1687
+ return result
1688
+ }
1689
+ func encode() -> [String: Any?] {
1690
+ return [
1691
+ "sourceType": self.sourceType.rawValue,
1692
+ "status": self.status.rawValue,
1693
+ ]
1694
+ }
1695
+ }
1696
+
1697
+ public extension DocumentReaderValue {
1698
+ static func decode(_ it: Any?) -> Self? {
1699
+ guard let it = it as? [String: Any] else { return nil }
1700
+ let result = Self.emptyInit() as Self
1701
+ result.setValue(it["sourceType"] as Any?, forKey: "sourceType")
1702
+ result.setValue(it["value"] as? String, forKey: "value")
1703
+ result.setValue(it["originalValue"] as? String, forKey: "originalValue")
1704
+ result.setValue(CGRect.decode(it["boundRect"]), forKey: "boundRect")
1705
+ result.setValue(it["pageIndex"] as? Int, forKey: "pageIndex")
1706
+ result.setValue(it["probability"] as? Int, forKey: "probability")
1707
+ result.setValue((it["originalSymbols"] as? [Any])?.compactMap(DocumentReaderSymbol.decode), forKey: "originalSymbols")
1708
+ result.setValue(DocumentReaderRfidOrigin.decode(it["rfidOrigin"]), forKey: "rfidOrigin")
1709
+ return result
1710
+ }
1711
+ func encode() -> [String: Any?] {
1712
+ return [
1713
+ "sourceType": self.sourceType.rawValue,
1714
+ "value": self.value,
1715
+ "originalValue": self.originalValue,
1716
+ "boundRect": self.boundRect.encode(),
1717
+ "pageIndex": self.pageIndex,
1718
+ "probability": self.probability,
1719
+ "originalSymbols": self.originalSymbols.map { $0.encode() },
1720
+ "rfidOrigin": self.rfidOrigin?.encode(),
1721
+ ]
1722
+ }
1723
+ }
1724
+
1725
+ // MARK: - RFID
1726
+
1727
+ public extension RGLRFIDAccessControlCA {
1728
+ static func decode(_ it: Any?) -> Self? {
1729
+ guard let it = it as? [String: Any] else { return nil }
1730
+ let result = Self.emptyInit() as Self
1731
+ if let prop = it["version"] { result.version = Int(prop as! String)! }
1732
+ if let prop = it["scheme"] as? String { result.scheme = prop }
1733
+ if let prop = it["keyAlgorithm"] as? String { result.keyAlgorithm = prop }
1734
+ if let prop = it["chipIndividual"] as? Bool { result.chipIndividual = prop }
1735
+ return result
1736
+ }
1737
+ func encode() -> [String: Any?] {
1738
+ return [
1739
+ "version": String(self.version),
1740
+ "scheme": self.scheme,
1741
+ "keyAlgorithm": self.keyAlgorithm,
1742
+ "chipIndividual": self.chipIndividual,
1743
+ ]
1744
+ }
1745
+ }
1746
+
1747
+ public extension PAAttribute {
1748
+ static func decode(_ it: Any?) -> Self? {
1749
+ guard let it = it as? [String: Any] else { return nil }
1750
+ let result = Self.emptyInit() as Self
1751
+ result.setValue(it["value"] as? String, forKey: "value")
1752
+ result.setValue(it["type"] as? String, forKey: "type")
1753
+ return result
1754
+ }
1755
+ func encode() -> [String: Any?] {
1756
+ return [
1757
+ "value": self.value,
1758
+ "type": self.type,
1759
+ ]
1760
+ }
1761
+ }
1762
+
1763
+ public extension PAResourcesIssuer {
1764
+ static func decode(_ it: Any?) -> Self? {
1765
+ guard let it = it as? [String: Any] else { return nil }
1766
+ let result = Self.emptyInit() as Self
1767
+ result.setValue(Data.decode(it["data"]), forKey: "data")
1768
+ result.setValue(it["friendlyName"] as? String, forKey: "friendlyName")
1769
+ result.setValue((it["attributes"] as? [Any])?.compactMap(PAAttribute.decode), forKey: "attributes")
1770
+ return result
1771
+ }
1772
+ func encode() -> [String: Any?] {
1773
+ return [
1774
+ "data": self.data?.encode(),
1775
+ "friendlyName": self.friendlyName,
1776
+ "attributes": self.attributes?.map { $0.encode() },
1777
+ ]
1778
+ }
1779
+ }
1780
+
1781
+ public extension RGLRFIDAccessControlPACE {
1782
+ static func decode(_ it: Any?) -> Self? {
1783
+ guard let it = it as? [String: Any] else { return nil }
1784
+ let result = Self.emptyInit() as Self
1785
+ if let prop = it["version"] { result.version = Int(prop as! String)! }
1786
+ if let prop = it["stdDomainParams"] as? String { result.stdDomainParams = prop }
1787
+ if let prop = it["keyAlgorithm"] as? String { result.keyAlgorithm = prop }
1788
+ return result
1789
+ }
1790
+ func encode() -> [String: Any?] {
1791
+ return [
1792
+ "version": String(self.version),
1793
+ "stdDomainParams": self.stdDomainParams,
1794
+ "keyAlgorithm": self.keyAlgorithm,
1795
+ ]
1796
+ }
1797
+ }
1798
+
1799
+ public extension PKDCertificate {
1800
+ static func decode(_ it: Any?) -> Self? {
1801
+ guard let it = it as? [String: Any] else { return nil }
1802
+ guard let data = Data.decode(it["binaryData"]) else { return nil }
1803
+ return Self(binaryData: data,
1804
+ resourceType: PKDResourceType(rawValue: it["resourceType"] as? Int ?? 0)!,
1805
+ privateKey: Data.decode(it["privateKey"]))
1806
+ }
1807
+ func encode() -> [String: Any?] {
1808
+ return [
1809
+ "resourceType": self.resourceType.rawValue,
1810
+ "binaryData": self.binaryData.encode(),
1811
+ "privateKey": self.privateKey?.encode(),
1812
+ ]
1813
+ }
1814
+ }
1815
+
1816
+ public extension RFIDNotify {
1817
+ func encode() -> [String: Any?] {
1818
+ return [
1819
+ "notificationCode": self.code.rawValue & 0xFFFF0000,
1820
+ "dataFileType": self.attachment,
1821
+ "progress": Int(self.value),
1822
+ ]
1823
+ }
1824
+ }
1825
+
1826
+ public extension TAChallenge {
1827
+ static func decode(_ it: Any?) -> Self? {
1828
+ guard let it = it as? [String: Any] else { return nil }
1829
+ let result = Self.emptyInit() as Self
1830
+ result.setValue(Data.decode(it["data"]), forKey: "data")
1831
+ result.setValue(it["auxPCD"] as? String, forKey: "auxPCD")
1832
+ result.setValue(it["challengePICC"] as? String, forKey: "challengePICC")
1833
+ result.setValue(it["hashPK"] as? String, forKey: "hashPK")
1834
+ result.setValue(it["idPICC"] as? String, forKey: "idPICC")
1835
+ return result
1836
+ }
1837
+ func encode() -> [String: Any?] {
1838
+ return [
1839
+ "data": self.data.encode(),
1840
+ "auxPCD": self.auxPCD,
1841
+ "challengePICC": self.challengePICC,
1842
+ "hashPK": self.hashPK,
1843
+ "idPICC": self.idPICC,
1844
+ ]
1845
+ }
1846
+ }
1847
+
1848
+ public extension TCCParams {
1849
+ static func decode(_ it: Any?) -> Self? {
1850
+ guard let it = it as? [String: Any] else { return nil }
1851
+ return Self(serviceTAURLString: it["serviceUrlTA"] as? String,
1852
+ servicePAURLString: it["serviceUrlPA"] as? String,
1853
+ pfxCertURLString: it["pfxCertUrl"] as? String,
1854
+ pfxCertData: Data.decode(it["pfxCert"]),
1855
+ pfxPassPhrase: it["pfxPassPhrase"] as? String)
1856
+ }
1857
+ func encode() -> [String: Any?] {
1858
+ return [
1859
+ "serviceUrlTA": self.serviceTAURLString,
1860
+ "serviceUrlPA": self.servicePAURLString,
1861
+ "pfxCertUrl": self.pfxCertURLString,
1862
+ "pfxPassPhrase": self.pfxPassPhrase,
1863
+ "pfxCert": self.pfxCertData?.encode(),
1864
+ ]
1865
+ }
1866
+ }