-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Douglas Poveda
committed
Oct 25, 2024
1 parent
de1771d
commit 5c7e0f7
Showing
11 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// GetW8BenE.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Get single w8BenE document by ID from Veryfi inbox. | ||
/// - Parameters: | ||
/// - documentId: ID of document to retreive | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func getW8BenE(documentId: String, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .GET, route: .w8BenE, queryItem: documentId, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// GetW8BenEs.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Get all w8BenE documents from Veryfi inbox. | ||
/// - Parameters: | ||
/// - queryItems: Query items to apply to the get request. | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func getW8BenEs(queryItems: [URLQueryItem]? = nil, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .GET, route: .w8BenE, queryItems: queryItems, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// GetW9.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Get single w9 document by ID from Veryfi inbox. | ||
/// - Parameters: | ||
/// - documentId: ID of document to retreive | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func getW9(documentId: String, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .GET, route: .w9s, queryItem: documentId, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// GetW9s.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Get all w9 documents from Veryfi inbox. | ||
/// - Parameters: | ||
/// - queryItems: Query items to apply to the get request. | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func getW9s(queryItems: [URLQueryItem]? = nil, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .GET, route: .w9s, queryItems: queryItems, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ProcessW8BenE.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Upload a w8BenE image for the Veryfi API to process. | ||
/// - Parameters: | ||
/// - fileName: Name of the file to upload to the Veryfi API. | ||
/// - fileData: UTF8 encoded file data | ||
/// - params: Additional parameters. | ||
/// - completion: Function called after request completes. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func processW8BenE(fileName: String, | ||
fileData: Data, | ||
params: [String: Any]? = nil, | ||
withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
var requestParams = params ?? [String: Any]() | ||
requestParams["file_data"] = fileData.base64EncodedString() | ||
requestParams["file_name"] = fileName | ||
|
||
guard let jsonData = try? JSONSerialization.data(withJSONObject: requestParams, options: .prettyPrinted) else { | ||
completion(.failure(.parsingError)) | ||
return | ||
} | ||
|
||
self.request(method: .POST, route: .w8BenE, uploadData: jsonData, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// ProcessW8BenEUrl.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Upload w8BenE document to Veryfi API with URL. | ||
/// - Parameters: | ||
/// - fileUrl: Publicly available URL. | ||
/// - fileUrls: List of publicly available URLs. | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func processW8BenEURL(fileUrl: String? = nil, | ||
fileUrls: [String]? = nil, | ||
withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
let params: [String: Any] = [ | ||
"file_url": fileUrl as Any, //implicit coerce | ||
"file_urls": fileUrls as Any, //implicit coerce | ||
] //implicit coerce | ||
let jsonData = try? JSONSerialization.data(withJSONObject: params) | ||
self.request(method: .POST, route: .w8BenE, body: jsonData, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ProcessW9.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Upload a w9 image for the Veryfi API to process. | ||
/// - Parameters: | ||
/// - fileName: Name of the file to upload to the Veryfi API. | ||
/// - fileData: UTF8 encoded file data | ||
/// - params: Additional parameters. | ||
/// - completion: Function called after request completes. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func processW9(fileName: String, | ||
fileData: Data, | ||
params: [String: Any]? = nil, | ||
withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
var requestParams = params ?? [String: Any]() | ||
requestParams["file_data"] = fileData.base64EncodedString() | ||
requestParams["file_name"] = fileName | ||
|
||
guard let jsonData = try? JSONSerialization.data(withJSONObject: requestParams, options: .prettyPrinted) else { | ||
completion(.failure(.parsingError)) | ||
return | ||
} | ||
|
||
self.request(method: .POST, route: .w9s, uploadData: jsonData, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// ProcessW9Url.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Upload w9 document to Veryfi API with URL. | ||
/// - Parameters: | ||
/// - fileUrl: Publicly available URL. | ||
/// - fileUrls: List of publicly available URLs. | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func processW9URL(fileUrl: String? = nil, | ||
fileUrls: [String]? = nil, | ||
withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
let params: [String: Any] = [ | ||
"file_url": fileUrl as Any, //implicit coerce | ||
"file_urls": fileUrls as Any, //implicit coerce | ||
] //implicit coerce | ||
let jsonData = try? JSONSerialization.data(withJSONObject: params) | ||
self.request(method: .POST, route: .w9s, body: jsonData, completion: completion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters