@@ -22,11 +22,6 @@ public enum AssuranceType: String {
2222 case liveness
2323}
2424
25- public enum Result < T> {
26- case success( T )
27- case failure( Error )
28- }
29-
3025public class APIClient {
3126 private let baseURL : String
3227 private let apiKey : String
@@ -76,7 +71,7 @@ public class APIClient {
7671 type: ClaimType ,
7772 userID: String ,
7873 additionalOptions: [ String : Any ] = [ : ] ,
79- completion: @escaping ( Result < String > ) -> Void ) {
74+ completion: @escaping ( Result < String , Swift . Error > ) -> Void ) {
8075
8176 let url = String ( format: " %@/claim/%@/token " , baseURL, type. rawValue)
8277
@@ -101,7 +96,7 @@ public class APIClient {
10196 public func enrolPhoto( token: String ,
10297 image: UIImage ,
10398 source: PhotoSource ,
104- completion: @escaping ( Result < String > ) -> Void ) {
99+ completion: @escaping ( Result < String , Swift . Error > ) -> Void ) {
105100
106101 let url = String ( format: " %@/claim/enrol/image " , baseURL)
107102
@@ -126,7 +121,7 @@ public class APIClient {
126121
127122 public func validate( token: String ,
128123 userID: String ,
129- completion: @escaping ( Result < ValidationResult > ) -> Void ) {
124+ completion: @escaping ( Result < ValidationResult , Swift . Error > ) -> Void ) {
130125
131126 let url = String ( format: " %@/claim/verify/validate " , baseURL)
132127
@@ -171,7 +166,7 @@ public extension APIClient {
171166 private struct ErrorSink < T> {
172167 let failure : ( Swift . Error ) -> Void
173168
174- func onSuccess( _ next: @escaping ( T ) -> Void ) -> ( Result < T > ) -> Void {
169+ func onSuccess( _ next: @escaping ( T ) -> Void ) -> ( Result < T , Swift . Error > ) -> Void {
175170 return { result in
176171 switch result {
177172 case let . success( value) :
@@ -187,7 +182,7 @@ public extension APIClient {
187182 func enrolPhotoAndGetVerifyToken( userID: String ,
188183 image: UIImage ,
189184 source: PhotoSource ,
190- completion: @escaping ( Result < String > ) -> Void ) {
185+ completion: @escaping ( Result < String , Swift . Error > ) -> Void ) {
191186
192187 let errorSink = ErrorSink< String> { completion ( . failure( $0) ) }
193188
@@ -203,7 +198,7 @@ public extension APIClient {
203198extension DataRequest {
204199
205200 @discardableResult
206- public func responseToken( completionHandler: @escaping ( Result < String > ) -> Void ) -> Self {
201+ public func responseToken( completionHandler: @escaping ( Result < String , Swift . Error > ) -> Void ) -> Self {
207202
208203 responseJSON { response in
209204 switch response. result {
0 commit comments