-
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.
Merge pull request #17 from veryfi/feature/LP-958-add-new-apis
LP-958: Add apis for any document, bank statements and tags
- Loading branch information
Showing
90 changed files
with
3,941 additions
and
722 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
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
// | ||
// AddLineItem.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Create line item for document in Veryfi inbox. | ||
/// - Parameters: | ||
/// - documentId: ID of document to modify. | ||
/// - params: Line item data. | ||
/// - completion: A block to execute | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func addLineItem(documentId: String, params: AddLineItem, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
let jsonData = try? JSONSerialization.data(withJSONObject: params.dictionary) | ||
self.request(method: .POST, route: .documents, body: jsonData, queryItem: String(format: "%@/line-items", 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,21 @@ | ||
// | ||
// AddTag.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Add tag to document. | ||
/// - Parameters: | ||
/// - documentId: ID of document to add tag. | ||
/// - params: Tag data. | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func addTag(documentId: String, params: AddTag, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
let jsonData = try? JSONSerialization.data(withJSONObject: params.dictionary) | ||
self.request(method: .PUT, route: .documents, body: jsonData, queryItem: String(format: "%@/tags", 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,21 @@ | ||
// | ||
// AddTags.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Add multiple tags in document. | ||
/// - Parameters: | ||
/// - documentId: ID of document to replace tags. | ||
/// - params: Tags data. | ||
/// - completion: Block executed after request. | ||
/// - detail: Response from server. | ||
/// - error: Error from server. | ||
public func addTags(documentId: String, params: AddTags, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
let jsonData = try? JSONSerialization.data(withJSONObject: params.dictionary) | ||
self.request(method: .POST, route: .documents, body: jsonData, queryItem: String(format: "%@/tags", 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,26 @@ | ||
import Foundation | ||
#if canImport(FoundationNetworking) | ||
import FoundationNetworking | ||
#endif | ||
|
||
struct VeryfiCredentials { | ||
let clientId: String | ||
let clientSecret: String | ||
let username: String | ||
let apiKey: String | ||
} | ||
|
||
public class Client: NetworkManager { | ||
|
||
/// Init Client. | ||
/// - Parameters: | ||
/// - clientId: Your client id from veryfi-hub. | ||
/// - clientSecret: Your client secret from veryfi-hub. | ||
/// - username: Your username from veryfi-hub. | ||
/// - apiKey: Your api key from veryfi-hub. | ||
/// - apiVersion: Api version to use, by default "v8". | ||
public init(clientId: String, clientSecret: String, username: String, apiKey: String, apiVersion: String = "v8") { | ||
let credentials = VeryfiCredentials(clientId: clientId, clientSecret: clientSecret, username: username, apiKey: apiKey) | ||
super.init(credentials: credentials, apiVersion: apiVersion) | ||
} | ||
} |
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,17 @@ | ||
// | ||
// DeleteDocument.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Delete document from Veryfi inbox. | ||
/// - Parameters: | ||
/// - documentId: ID of document to delete. | ||
/// - completion: completion description | ||
public func deleteDocument(documentId: String, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .DELETE, route: .documents, 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,18 @@ | ||
// | ||
// DeleteLineItem.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Delete line item from document from Veryfi inbox. | ||
/// - Parameters: | ||
/// - documentId: ID of document | ||
/// - lineItemId: ID of line item to delete. | ||
/// - completion: completion description | ||
public func deleteLineItem(documentId: String, lineItemId: String, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .DELETE, route: .documents, queryItem: String(format: "%@/line-items/%@", documentId, lineItemId), 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,17 @@ | ||
// | ||
// DeleteLineItems.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Delete all line items from document from Veryfi inbox. | ||
/// - Parameters: | ||
/// - documentId: ID of document | ||
/// - completion: completion description | ||
public func deleteDocumentLineItems(documentId: String, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .DELETE, route: .documents, queryItem: String(format: "%@/line-items", 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 @@ | ||
// | ||
// GetAnyDocument.swift | ||
// VeryfiSDK | ||
// | ||
// Created by Veryfi on 25/10/24. | ||
// | ||
import Foundation | ||
|
||
extension Client { | ||
/// Get single any 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 getAnyDocument(documentId: String, withCompletion completion: @escaping (Result<Data, APIError>) -> Void) { | ||
self.request(method: .GET, route: .anyDocuments, queryItem: documentId, completion: completion) | ||
} | ||
} |
Oops, something went wrong.