Skip to content

Commit

Permalink
Merge branch 'main' into Payment-Component
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinaIancu-Gini committed Nov 26, 2024
2 parents 6315f66 + 846dc82 commit 91e39f5
Show file tree
Hide file tree
Showing 83 changed files with 4,297 additions and 1,386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Once you have your Swift package set up, adding `GiniBankAPILibrary` as a depend

```swift
dependencies: [
.package(url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.3.1"))
.package(url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.4.0"))
]
```

In case that you want to use the certificate pinning in the library, add `GiniBankAPILibraryPinning`:
```swift
dependencies: [
.package(url: "https://github.com/gini/bank-api-library-pinning-ios.git", .exact("3.3.1"))
.package(url: "https://github.com/gini/bank-api-library-pinning-ios.git", .exact("3.4.0"))
]
```

Expand Down
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 @@ -7,8 +7,7 @@

import Foundation

public final class Token {

public final class Token: Hashable {
var expiration: Date
var scope: String?
var type: String?
Expand All @@ -28,6 +27,16 @@ public final class Token {
case accessToken = "access_token"
}

public static func == (lhs: Token, rhs: Token) -> Bool {
lhs.hashValue == rhs.hashValue
}

public func hash(into hasher: inout Hasher) {
hasher.combine(expiration)
hasher.combine(scope)
hasher.combine(type)
hasher.combine(accessToken)
}
}

extension Token: Decodable {
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 @@ -5,4 +5,4 @@
// Copyright © 2024 Gini GmbH. All rights reserved.
//

public let GiniBankAPILibraryVersion = "3.3.1"
public let GiniBankAPILibraryVersion = "3.4.0"
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ final class DocumentServicesTests: XCTestCase {
osName: UIDevice.current.systemName,
osVersion: UIDevice.current.systemVersion,
captureSdkVersion: "Not available",
apiLibVersion: "3.3.1",
apiLibVersion: "3.4.0",
description: "Error logging test",
documentId: "1234",
originalRequestId: "5678")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
// .package(url: /* package url */, from: "1.0.0"),

.package(name: "TrustKit", url: "https://github.com/datatheorem/TrustKit.git", from: "2.0.0"),
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.3.1")),
.package(name: "GiniBankAPILibrary", url: "https://github.com/gini/bank-api-library-ios.git", .exact("3.4.0")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Copyright © 2024 Gini GmbH. All rights reserved.
//

public let GiniBankAPILibraryPinningVersion = "3.3.1"
public let GiniBankAPILibraryPinningVersion = "3.4.0"
2 changes: 1 addition & 1 deletion BankSDK/GiniBankSDK/Package-release.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(name: "GiniCaptureSDK", url: "https://github.com/gini/capture-sdk-ios.git", .exact("3.10.1")),
.package(name: "GiniCaptureSDK", url: "https://github.com/gini/capture-sdk-ios.git", .exact("3.11.0")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ final class DocumentPagesFooterView: UIView {
for item in items {
let label = UILabel()
label.text = item
label.accessibilityValue = item
label.font = configuration.textStyleFonts[.footnote]
label.textColor = .GiniBank.light1
label.translatesAutoresizingMaskIntoConstraints = false
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 Expand Up @@ -576,10 +610,11 @@ extension GiniBankNetworkingScreenApiCoordinator: SkontoCoordinatorDelegate {
self?.transactionDocsDataCoordinator?.transactionDocs = [.init(documentId: documentId,
fileName: "Document",
type: .document)]
self?.setTransactionDocsDataToDisplay(with: extractionResult, for: documentId)
} else {
self?.transactionDocsDataCoordinator?.transactionDocs = []
}
self?.setTransactionDocsDataToDisplay(with: extractionResult)

deliveryFunction(extractionResult)
})
}
Expand Down Expand Up @@ -728,18 +763,31 @@ extension GiniBankNetworkingScreenApiCoordinator: SkontoCoordinatorDelegate {
}

extension GiniBankNetworkingScreenApiCoordinator {
private func setTransactionDocsDataToDisplay(with extractionResult: ExtractionResult) {
private func setTransactionDocsDataToDisplay(with extractionResult: ExtractionResult, for documentId: String) {
transactionDocsDataCoordinator?.loadDocumentData = { [weak self] in
self?.loadDocumentPages { [weak self] images, error in
guard let self = self else { return }
DispatchQueue.main.async {
if let error = error {
self.handlePreviewDocumentError(error: error)
return
}
guard let viewModel = self?.transactionDocsDataCoordinator?.getTransactionDocsViewModel(),
let images = viewModel.cachedImages[documentId],
!images.isEmpty else {
self?.loadDocumentPagesAndHandleErrors(for: documentId, with: extractionResult)
return
}
self?.updateTransactionDocsViewModel(with: images,
extractionResult: extractionResult,
for: documentId)
}
}

self.updateTransactionDocsViewModel(with: images, extractionResult: extractionResult)
private func loadDocumentPagesAndHandleErrors(for documentId: String, with extractionResult: ExtractionResult) {
loadDocumentPages { [weak self] images, error in
guard let self = self else { return }
DispatchQueue.main.async {
if let error = error {
self.handlePreviewDocumentError(error: error)
return
}
self.updateTransactionDocsViewModel(with: images,
extractionResult: extractionResult,
for: documentId)
}
}
}
Expand All @@ -753,12 +801,14 @@ extension GiniBankNetworkingScreenApiCoordinator {
}
}

private func updateTransactionDocsViewModel(with images: [UIImage], extractionResult: ExtractionResult) {
private func updateTransactionDocsViewModel(with images: [UIImage],
extractionResult: ExtractionResult,
for documentId: String) {
let extractionInfo = TransactionDocsExtractions(extractions: extractionResult)
let viewModel = TransactionDocsDocumentPagesViewModel(originalImages: images,
extractions: extractionInfo)
transactionDocsDataCoordinator?
.getTransactionDocsViewModel()?
.setTransactionDocsDocumentPagesViewModel(viewModel)
.setTransactionDocsDocumentPagesViewModel(viewModel, for: documentId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension GiniBank {
all screens and transitions out of the box, including the networking.

- parameter client: `GiniClient` with the information needed to enable document analysis
- parameter importedDocuments: There should be either images or one PDF, and they should be validated before calling this method.
- 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
Expand Down Expand Up @@ -46,6 +47,34 @@ 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 tokenSource: Alternative token source
- parameter importedDocuments: There should be either images or one PDF, and they should be validated before calling this method.
- 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

- 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
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.textSuggestionEnabled.uiColor()
label.textColor = .giniColorScheme().badge.content.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
label.setContentHuggingPriority(.defaultLow, for: .horizontal)
Expand All @@ -80,7 +80,7 @@ final class DigitalInvoiceBottomNavigationBar: UIView {

private lazy var skontoBadgeView: UIView = {
let view = UIView()
view.backgroundColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
view.backgroundColor = .giniColorScheme().badge.background.uiColor()
view.layer.cornerRadius = Constants.cornerRadius
view.layer.masksToBounds = true
view.isHidden = true
Expand All @@ -93,15 +93,15 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
label.textColor = .giniColorScheme().text.success.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
return label
}()

private lazy var dividerView: UIView = {
let dividerView = UIView()
dividerView.backgroundColor = .giniColorScheme().bg.divider.uiColor()
dividerView.backgroundColor = .giniColorScheme().bottomBar.border.uiColor()
dividerView.translatesAutoresizingMaskIntoConstraints = false
return dividerView
}()
Expand Down Expand Up @@ -156,7 +156,7 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
}

private func setupView() {
backgroundColor = .giniColorScheme().bg.surface.uiColor()
backgroundColor = .giniColorScheme().background.secondary.uiColor()

addSubview(contentView)
addSubview(dividerView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DigitalInvoiceProceedView: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.textSuggestionEnabled.uiColor()
label.textColor = .giniColorScheme().badge.content.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
label.setContentHuggingPriority(.defaultLow, for: .horizontal)
Expand All @@ -67,7 +67,7 @@ class DigitalInvoiceProceedView: UIView {

private lazy var skontoBadgeView: UIView = {
let view = UIView()
view.backgroundColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
view.backgroundColor = .giniColorScheme().badge.background.uiColor()
view.layer.cornerRadius = Constants.cornerRadius
view.layer.masksToBounds = true
view.isHidden = true
Expand All @@ -80,15 +80,15 @@ class DigitalInvoiceProceedView: UIView {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = configuration.textStyleFonts[.footnoteBold]
label.textColor = .giniColorScheme().chips.suggestionEnabled.uiColor()
label.textColor = .giniColorScheme().badge.background.uiColor()
label.adjustsFontForContentSizeCategory = true
label.adjustsFontSizeToFitWidth = true
return label
}()

private lazy var dividerView: UIView = {
let dividerView = UIView()
dividerView.backgroundColor = .giniColorScheme().bg.divider.uiColor()
dividerView.backgroundColor = .giniColorScheme().bottomBar.border.uiColor()
dividerView.translatesAutoresizingMaskIntoConstraints = false
return dividerView
}()
Expand All @@ -107,7 +107,7 @@ class DigitalInvoiceProceedView: UIView {
}

private func setupView() {
backgroundColor = .giniColorScheme().bg.surface.uiColor()
backgroundColor = .giniColorScheme().background.secondary.uiColor()
translatesAutoresizingMaskIntoConstraints = false

addSubview(contentView)
Expand Down
Loading

0 comments on commit 91e39f5

Please sign in to comment.