Skip to content

Commit

Permalink
fix(GiniBankSDK): PP-142 fix alternative token source
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-gini committed Nov 4, 2024
1 parent 6fc92a0 commit 2ba39aa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ public struct Client {
self.domain = domain
}
}

public protocol TokenSource {
var domain: String { get }
var id: String { get }
var secret: String { get }
}
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 = "pay-api.gini.net",
alternativeTokenSource: AlternativeTokenSource,
logLevel: LogLevel = .none,
sessionDelegate: URLSessionDelegate? = nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
self.trackingDelegate = trackingDelegate
}

public init(alternativeTokenSource tokenSource: TokenSource,
resultsDelegate: GiniCaptureResultsDelegate,
public init(resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
api: APIDomain,
trackingDelegate: GiniCaptureTrackingDelegate?,
lib: GiniBankAPI) {
documentService = DocumentService(lib: lib, metadata: documentMetadata)
Expand Down Expand Up @@ -213,22 +211,18 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin
lib: lib)
}

convenience init(alternativeTokenSource tokenSource: TokenSource,
convenience init(alternativeTokenSource tokenSource: AlternativeTokenSource,
resultsDelegate: GiniCaptureResultsDelegate,
configuration: GiniBankConfiguration,
documentMetadata: Document.Metadata?,
api: APIDomain,
userApi: UserDomain,
trackingDelegate: GiniCaptureTrackingDelegate?) {
let lib = GiniBankAPI
.Builder(client: Client(id: tokenSource.id, secret: tokenSource.secret, domain: tokenSource.domain), api: api, userApi: userApi)
.Builder(alternativeTokenSource: tokenSource)
.build()

self.init(alternativeTokenSource: tokenSource,
resultsDelegate: resultsDelegate,
self.init(resultsDelegate: resultsDelegate,
configuration: configuration,
documentMetadata: documentMetadata,
api: api,
trackingDelegate: trackingDelegate,
lib: lib)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,20 @@ extension GiniBank {
- 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 api: The Gini backend API to use. Supply .custom("domain") in order to specify a custom domain.
- parameter userApi: The Gini user backend API to use. Supply .custom("domain") in order to specify a custom domain.
- parameter trackingDelegate: A delegate object to receive user events

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

0 comments on commit 2ba39aa

Please sign in to comment.