Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-138 alternative token source #703

Merged
merged 7 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum APIDomain {
/// A custom domain with optional path and custom token source
case custom(domain: String, path: String? = nil, tokenSource: AlternativeTokenSource?)

var domainString: String {
public var domainString: String {
switch self {
case .default: return "pay-api.gini.net"
case .custom(let domain, _, _): return domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension GiniBankAPI {
/**
* Creates a Gini Bank API Library to be used with a transparent proxy and a custom api access token source.
*/
public init(customApiDomain: String,
public init(customApiDomain: String = APIDomain.default.domainString,
alternativeTokenSource: AlternativeTokenSource,
logLevel: LogLevel = .none,
sessionDelegate: URLSessionDelegate? = nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
self.trackingDelegate = trackingDelegate
}

private init(resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
trackingDelegate: GiniCaptureTrackingDelegate?,
lib: GiniBankAPI) {
documentService = DocumentService(lib: lib, metadata: documentMetadata)
configurationService = lib.configurationService()
let captureConfiguration = configuration.captureConfiguration()
super.init(withDelegate: nil, giniConfiguration: captureConfiguration)

visionDelegate = self
GiniBank.setConfiguration(configuration)
giniBankConfiguration = configuration
giniBankConfiguration.documentService = documentService
self.resultsDelegate = resultsDelegate
self.trackingDelegate = trackingDelegate
}

public init(resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
Expand Down Expand Up @@ -193,6 +211,22 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
lib: lib)
}

convenience init(alternativeTokenSource tokenSource: AlternativeTokenSource,
resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
trackingDelegate: GiniCaptureTrackingDelegate?) {
let lib = GiniBankAPI
.Builder(alternativeTokenSource: tokenSource)
.build()

self.init(resultsDelegate: resultsDelegate,
configuration: configuration,
documentMetadata: documentMetadata,
trackingDelegate: trackingDelegate,
lib: lib)
}

private func deliver(result: ExtractionResult, analysisDelegate: AnalysisDelegate) {
let hasExtractions = result.extractions.count > 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,33 @@ extension GiniBank {
return screenCoordinator.startSDK(withDocuments: importedDocuments)
}

/**
Returns a view controller which will handle the analysis process.
It's the easiest way to get started with the Gini Bank SDK as it comes pre-configured and handles
all screens and transitions out of the box, including the networking.

- parameter alternativeTokenSource: Alternative token source
- parameter resultsDelegate: Results delegate object where you can get the results of the analysis.
- parameter configuration: The configuration to set.
- parameter documentMetadata: Additional HTTP headers to send when uploading documents
- parameter trackingDelegate: A delegate object to receive user events
ValentinaIancu-Gini marked this conversation as resolved.
Show resolved Hide resolved

- returns: A presentable view controller.
*/
public class func viewController(withAlternativeTokenSource tokenSource: AlternativeTokenSource,
importedDocuments: [GiniCaptureDocument]? = nil,
configuration: GiniBankConfiguration,
resultsDelegate: GiniCaptureResultsDelegate,
documentMetadata: Document.Metadata? = nil,
trackingDelegate: GiniCaptureTrackingDelegate? = nil) -> UIViewController {
let screenCoordinator = GiniBankNetworkingScreenApiCoordinator(alternativeTokenSource: tokenSource,
resultsDelegate: resultsDelegate,
configuration: configuration,
documentMetadata: documentMetadata,
trackingDelegate: trackingDelegate)
return screenCoordinator.startSDK(withDocuments: importedDocuments)
}

// MARK: - Screen API with Custom Networking - Initializers for 'UIViewController'

/**
Expand Down
Loading