Skip to content

Commit

Permalink
Merge branch 'main' into PP-304-Transaction-Docs-MVP
Browse files Browse the repository at this point in the history
# Conflicts:
#	BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift
  • Loading branch information
ValentinaIancu-Gini committed Sep 27, 2024
2 parents a8d8a9e + 4aecf5e commit e4e9137
Show file tree
Hide file tree
Showing 44 changed files with 410 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bank-api-library.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
target: [GiniBankAPILibrary, GiniBankAPILibraryPinning]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bank-sdk.build.xcframeworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ on:
jobs:
prepare-frameworks:
name: Create Release
runs-on: macos-latest
runs-on: macos-13
steps:
- uses: maxim-lobanov/[email protected]
with:
xcode-version: '15.3'
xcode-version: '14.3.1'

- name: Checkout repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bank-sdk.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
target: [GiniBankSDK, GiniBankSDKPinning]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/capture-sdk.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
target: [GiniCaptureSDK, GiniCaptureSDKPinning]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/health-api-library.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
target: [GiniHealthAPILibrary, GiniHealthAPILibraryPinning]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/health-sdk.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
target: [GiniHealthSDK, GiniHealthSDKPinning]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merchant-sdk.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
target: [GiniMerchantSDK]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/utilites.check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
target: [GiniUtilites]
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 15 Pro Max']
destination: ['platform=iOS Simulator,OS=17.2,name=iPhone SE (3rd generation)', 'platform=iOS Simulator,OS=18.1,name=iPhone 14 Pro Max']
steps:
- uses: maxim-lobanov/[email protected]
with:
Expand Down
71 changes: 36 additions & 35 deletions BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@ public protocol GiniBankAnalysisDelegate: AnalysisDelegate {}

/**
Returns a localized string resource preferably from the client's bundle. Used in Return Assistant Screens.

- parameter key: The key to search for in the strings file.
- parameter comment: The corresponding comment.

- returns: String resource for the given key.
*/
func NSLocalizedStringPreferredGiniBankFormat(_ key: String,
fallbackKey: String = "",
comment: String,
isCustomizable: Bool = true) -> String {
if isCustomizable {
if let clientLocalizedStringMainBundle = clientLocalizedString(key,
fallbackKey: fallbackKey,
comment: comment,
bundle: .main) {
return clientLocalizedStringMainBundle

} else if let customBundle = GiniBankConfiguration.shared.customResourceBundle,
let clientLocalizedStringCustomBundle = clientLocalizedString(key,
fallbackKey: fallbackKey,
comment: comment,
bundle: customBundle) {
return clientLocalizedStringCustomBundle
}
}
return giniLocalizedString(key, fallbackKey: fallbackKey, comment: comment)
}
if isCustomizable {
if let clientLocalizedStringMainBundle = clientLocalizedString(key,
fallbackKey: fallbackKey,
comment: comment,
bundle: .main) {
return clientLocalizedStringMainBundle

} else if let customBundle = GiniBankConfiguration.shared.customResourceBundle,
let clientLocalizedStringCustomBundle = clientLocalizedString(key,
fallbackKey: fallbackKey,
comment: comment,
bundle: customBundle) {
return clientLocalizedStringCustomBundle
}
}
return giniLocalizedString(key, fallbackKey: fallbackKey, comment: comment)
}

private func clientLocalizedString(_ key: String,
fallbackKey: String,
Expand All @@ -50,7 +50,7 @@ private func clientLocalizedString(_ key: String,
var fallbackClientString = NSLocalizedString(fallbackKey,
bundle: bundle,
comment: comment)

if let localizedResourceName = GiniBankConfiguration.shared.localizedStringsTableName {
clientString = NSLocalizedString(key,
tableName: localizedResourceName,
Expand All @@ -61,29 +61,30 @@ private func clientLocalizedString(_ key: String,
bundle: bundle,
comment: comment)
}

guard (clientString.lowercased() != key.lowercased() || fallbackClientString.lowercased() != fallbackKey.lowercased()) else {

guard clientString.lowercased() != key.lowercased()
|| fallbackClientString.lowercased() != fallbackKey.lowercased() else {
return nil
}

return clientString
}

private func giniLocalizedString(_ key: String,
fallbackKey: String,
comment: String) -> String {
let giniBundle = giniBankBundle()

var defaultFormat = NSLocalizedString(key,
bundle: giniBundle,
comment: comment)

if defaultFormat.lowercased() == key.lowercased() {
defaultFormat = NSLocalizedString(fallbackKey,
bundle: giniBundle,
comment: comment)
}

return defaultFormat
}

Expand All @@ -93,9 +94,9 @@ func giniBankBundle() -> Bundle {

/**
Returns an optional `UIImage` instance with the given `name` preferably from the client's bundle.

- parameter name: The name of the image file without file extension.

- returns: Image if found with name.
*/
func prefferedImage(named name: String) -> UIImage? {
Expand All @@ -117,9 +118,9 @@ func prefferedImage(named name: String) -> UIImage? {
}
/**
Returns an optional `UIColor` instance with the given `name` preferably from the client's bundle.

- parameter name: The name of the UIColor from `GiniColors` asset catalog.

- returns: UIColor if found with name.
*/
func prefferedColor(named name: String) -> UIColor {
Expand Down Expand Up @@ -164,19 +165,19 @@ public func prefferedColorByProvider(named name: String) -> UIColor {
Getting the payment request id from incoming url
Should be called inside function:
func application(_ application: UIApplication,
open url: URL,
options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -> Bool
open url: URL,
options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -> Bool

- parameter url: The incoming url from the business app
- parameter completion: An action for processing asynchronous data received from the service with Result type as a paramater. Result is a value that represents either a success or a failure, including an associated value in each case.
In success case it includes payment request Id.
In case of failure error that there is no requestId in incoming url from the business app.

*/
public func receivePaymentRequestId(url: URL, completion: @escaping (Result<String, GiniBankError>) -> Void) {
// Process the URL.
guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true),
let params = components.queryItems else {
let params = components.queryItems else {
completion(.failure(.noRequestId))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ extension GiniBank {
documentMetadata: Document.Metadata? = nil,
trackingDelegate: GiniCaptureTrackingDelegate? = nil,
networkingService: GiniCaptureNetworkService,
configurationService: ClientConfigurationServiceProtocol? = nil) -> UIViewController {
configurationService: ClientConfigurationServiceProtocol? = nil)
-> UIViewController {
let screenCoordinator = GiniBankNetworkingScreenApiCoordinator(resultsDelegate: resultsDelegate,
configuration: configuration,
documentMetadata: documentMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ final class DigitalInvoiceBottomNavigationBar: UIView {

NSLayoutConstraint.activate([
contentView.centerXAnchor.constraint(equalTo: centerXAnchor),
contentView.widthAnchor.constraint(equalTo: widthAnchor, multiplier: multiplier),
contentView.widthAnchor.constraint(equalTo: widthAnchor,
multiplier: multiplier),
contentView.topAnchor.constraint(equalTo: topAnchor)
])
}
Expand All @@ -201,7 +202,8 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
private func setupTotalLabelConstraints() {
NSLayoutConstraint.activate([
totalLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: Constants.padding),
totalLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constants.padding),
totalLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor,
constant: Constants.padding),
totalLabel.trailingAnchor.constraint(lessThanOrEqualTo: skontoBadgeView.leadingAnchor,
constant: -Constants.badgeHorizontalPadding)
])
Expand All @@ -211,7 +213,8 @@ final class DigitalInvoiceBottomNavigationBar: UIView {
NSLayoutConstraint.activate([
totalValueLabel.topAnchor.constraint(equalTo: totalLabel.bottomAnchor,
constant: Constants.totalValueLabelTopPadding),
totalValueLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: Constants.padding),
totalValueLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor,
constant: Constants.padding),
totalValueLabel.trailingAnchor.constraint(lessThanOrEqualTo: contentView.trailingAnchor,
constant: -Constants.padding)
])
Expand Down Expand Up @@ -247,26 +250,32 @@ final class DigitalInvoiceBottomNavigationBar: UIView {

private func setupHelpButtonConstraints() {
NSLayoutConstraint.activate([
helpButton.buttonView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -Constants.padding),
helpButton.buttonView.trailingAnchor.constraint(equalTo: trailingAnchor,
constant: -Constants.padding),
helpButton.buttonView.centerYAnchor.constraint(equalTo: proceedButton.centerYAnchor)
])
}

private func setupProceedButtonConstraints() {
NSLayoutConstraint.activate([
proceedButton.topAnchor.constraint(equalTo: contentView.bottomAnchor, constant: Constants.proceedButtonTopPadding),
proceedButton.topAnchor.constraint(equalTo: contentView.bottomAnchor,
constant: Constants.proceedButtonTopPadding),
proceedButton.centerXAnchor.constraint(equalTo: centerXAnchor),
proceedButton.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor, constant: -Constants.verticalPadding),
proceedButton.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor,
constant: -Constants.verticalPadding),
proceedButton.heightAnchor.constraint(equalToConstant: Constants.proceedButtonHeight)
])
if UIDevice.current.isIpad {
NSLayoutConstraint.activate([
proceedButton.widthAnchor.constraint(equalTo: contentView.widthAnchor, constant: -Constants.padding * 2)
proceedButton.widthAnchor.constraint(equalTo: contentView.widthAnchor,
constant: -Constants.padding * 2)
])
} else {
NSLayoutConstraint.activate([
proceedButton.widthAnchor.constraint(lessThanOrEqualTo: contentView.widthAnchor, constant: -Constants.padding * 2),
proceedButton.trailingAnchor.constraint(equalTo: helpButton.buttonView.leadingAnchor, constant: -Constants.helpButtonHorizontalPadding)
proceedButton.widthAnchor.constraint(lessThanOrEqualTo: contentView.widthAnchor,
constant: -Constants.padding * 2),
proceedButton.trailingAnchor.constraint(equalTo: helpButton.buttonView.leadingAnchor,
constant: -Constants.helpButtonHorizontalPadding)
])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ class DigitalInvoiceProceedView: UIView {

private let configuration = GiniBankConfiguration.shared

private let skontoPercentageText = NSLocalizedStringPreferredGiniBankFormat("ginibank.skonto.total.skontopercentage",
comment: "%@ Skonto discount")

init() {
super.init(frame: .zero)
setupView()
Expand Down Expand Up @@ -139,7 +136,8 @@ class DigitalInvoiceProceedView: UIView {

NSLayoutConstraint.activate([
contentView.centerXAnchor.constraint(equalTo: centerXAnchor),
contentView.widthAnchor.constraint(equalTo: widthAnchor, multiplier: multiplier),
contentView.widthAnchor.constraint(equalTo: widthAnchor,
multiplier: multiplier),
contentView.topAnchor.constraint(equalTo: topAnchor),
contentView.bottomAnchor.constraint(equalTo: bottomAnchor)
])
Expand All @@ -157,7 +155,8 @@ class DigitalInvoiceProceedView: UIView {
private func setupTotalStringLabelConstraints() {
NSLayoutConstraint.activate([
totalStringLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: Constants.padding),
totalStringLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor,constant: Constants.padding),
totalStringLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor,
constant: Constants.padding),
totalStringLabel.trailingAnchor.constraint(lessThanOrEqualTo: skontoBadgeView.leadingAnchor,
constant: -Constants.badgeHorizontalPadding)
])
Expand Down Expand Up @@ -228,8 +227,11 @@ class DigitalInvoiceProceedView: UIView {
if let skontoViewModel = viewModel.skontoViewModel {
let isSkontoApplied = skontoViewModel.isSkontoApplied
skontoBadgeView.isHidden = !isSkontoApplied
let skontoPercentageLabelText = String.localizedStringWithFormat(skontoPercentageText,
skontoViewModel.formattedPercentageDiscounted)
let formattedPercentageDiscounted = skontoViewModel.formattedPercentageDiscounted
let percentageText = NSLocalizedStringPreferredGiniBankFormat("ginibank.skonto.total.skontopercentage",
comment: "%@ Skonto discount")
let skontoPercentageLabelText = String.localizedStringWithFormat(percentageText,
formattedPercentageDiscounted)
skontoPercentageLabel.text = skontoPercentageLabelText
skontoPercentageLabel.accessibilityValue = skontoPercentageLabelText
savingsAmountLabel.isHidden = !isSkontoApplied
Expand Down
Loading

0 comments on commit e4e9137

Please sign in to comment.