@regulaforensics/react-native-document-reader-api 9.11.948-rc → 9.11.949-nightly

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