Response.swift 1.08 KB
Newer Older
Javohir Savriy's avatar
Javohir Savriy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Foundation
// import Onfido
//
// func createResponse(_ results: [OnfidoResult], faceVariant: String?) -> [String: [String: Any]] {
//   var jsonResponse = [String: [String: Any]]()
//
//   let document: [OnfidoResult]? = results.filter({ result in
//     if case OnfidoResult.document = result { return true }
//     return false;
//   });
//
//   let onfidoResult: OnfidoResult? = document?.first
//
//   let face: OnfidoResult? = results.filter({ result in
//     if case OnfidoResult.face = result { return true }
//     return false
//   }).first
//
//   if let documentUnwrapped = onfidoResult, case OnfidoResult.document(let documentResponse) = documentUnwrapped {
//       jsonResponse["document"] = ["front": ["id": documentResponse.front.id]]
//
//       if let back = documentResponse.back {
//           jsonResponse["document"]?["back"] = ["id": back.id]
//       }
//   }
//
//   if let faceUnwrapped = face, case OnfidoResult.face(let faceResponse) = faceUnwrapped {
//     jsonResponse["face"] = ["id": faceResponse.id, "variant": faceVariant!]
//   }
//
//   return jsonResponse
// }