Custom Implementation
The networking logic is abstracted in the GiniCaptureNetworkService
protocol which is used to upload, analyze, and delete documents.
Please see how you can implement your custom version of GiniCaptureNetworkService
in the code snippet below:
class YourCustomNetworkService: GiniCaptureNetworkService {
func delete(document: Document, completion: @escaping (Result<String, GiniError>) -> Void) {
print("custom networking - delete called")
}
func cleanup() {
print("custom networking - cleanup called")
}
func analyse(partialDocuments: [PartialDocumentInfo],
metadata: Document.Metadata?,
cancellationToken: CancellationToken,
completion: @escaping (Result<(document: Document,
extractionResult: ExtractionResult), GiniError>) -> Void) {
print("custom networking - analyse called")
}
func upload(document: GiniCaptureDocument,
metadata: Document.Metadata?,
completion: @escaping UploadDocumentCompletion) {
print("custom networking - upload called")
}
func sendFeedback(document: Document,
updatedExtractions: [Extraction],
updatedCompoundExtractions: [String : [[Extraction]]]?,
completion: @escaping (Result<Void, GiniError>) -> Void) {
print("custom networking - sendFeedback called")
}
func log(errorEvent: ErrorEvent, completion: @escaping (Result<Void, GiniError>) -> Void) {
print("custom networking - log error event called")
}
}
You can provide your own networking by implementing the GiniCaptureNetworkService
protocol and passing your instance to the UIViewController
initializer of GiniCapture
.
Please see an example below:
let viewController = GiniCapture.viewController(importedDocuments: visionDocuments,
configuration: visionConfiguration,
resultsDelegate: resultsDelegate,
documentMetadata: documentMetadata,
trackingDelegate: trackingDelegate,
networkingService: <YourCustomNetworkService>)
present(viewController, animated: true, completion: nil)
Also, you can use the Gini Bank API Library or implement the communication with the Gini Bank API yourself.