From 965a291680c6ab2a3e232ad38f9e84f7bc96f2d0 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 3 Jun 2024 16:01:05 +0200 Subject: [PATCH 01/54] feat(GiniBankAPILibrary): Configuration Decodable model. ConfigurationService Add Configuration Decodable model Add ConfigurationService, ConfigurationServiceProtocol, fetchConfiguration test func Add test endpoint to APIMethod & APIResource PP-352 --- .../Documents/APIMethod.swift | 2 + .../Documents/APIResource.swift | 3 ++ .../Configuration/Configuration.swift | 16 +++++++ .../Configuration/ConfigurationService.swift | 42 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift create mode 100644 BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift index 4122843a8..c3ca27ca2 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift @@ -32,4 +32,6 @@ enum APIMethod: ResourceMethod { case resolvePaymentRequest(id: String) case payment(id: String) case logErrorEvent + // TODO: [PP-352] FAKE endpoint, replace when backend will be finished + case fetchConfiguration } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift index 555880314..e8b8361ff 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift @@ -122,6 +122,9 @@ struct APIResource: Resource { return "/paymentRequests/\(id)/payment" case .logErrorEvent: return "/events/error" + case .fetchConfiguration: + // TODO: [PP-352] FAKE endpoint, replace when backend will be finished + return "/configuration-test" } } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift new file mode 100644 index 000000000..cb7fe8238 --- /dev/null +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift @@ -0,0 +1,16 @@ +// +// Configuration.swift +// +// Copyright © 2024 Gini GmbH. All rights reserved. +// + + +import Foundation + +// TODO: [PP-352] Check CodingKeys when backend will be finished +public struct Configuration: Decodable { + public let clientID: String + public let userJourneyAnalyticsEnabled: Bool + public let mixpanelToken: String + public let skontoEnabled: Bool +} diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift new file mode 100644 index 000000000..6b796405e --- /dev/null +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -0,0 +1,42 @@ +// +// ConfigurationService.swift +// +// Copyright © 2024 Gini GmbH. All rights reserved. +// + + +import Foundation + +public protocol ConfigurationServiceProtocol: AnyObject { + func fetchConfiguration(completion: @escaping CompletionResult) +} + +public final class ConfigurationService: ConfigurationServiceProtocol { + public func fetchConfiguration(completion: @escaping CompletionResult) { + self.fetchConfiguration(resourceHandler: sessionManager.data, completion: completion) + } + + let sessionManager: SessionManagerProtocol + public var apiDomain: APIDomain + + init(sessionManager: SessionManagerProtocol, apiDomain: APIDomain = .default) { + self.sessionManager = sessionManager + self.apiDomain = apiDomain + } +} + +extension ConfigurationService { + func fetchConfiguration(resourceHandler: ResourceDataHandler>, + completion: @escaping CompletionResult) { + let resource = APIResource(method: .fetchConfiguration, apiDomain: .default, httpMethod: .get) + + resourceHandler(resource, { result in + switch result { + case let .success(configuration): + completion(.success(configuration)) + case let .failure(error): + completion(.failure(error)) + } + }) + } +} From 1897eb449738a44cd7d81873785ed171bf134e48 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 5 Jun 2024 16:08:47 +0200 Subject: [PATCH 02/54] feat(GiniBankAPILibrary): Add ConfigurationService to GiniBankAPI Also refactor build func PP-352 --- .../Documents/Core/GiniBankAPI.swift | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index 260255f61..bb5161701 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -12,12 +12,14 @@ public final class GiniBankAPI { private let docService: DocumentService! private let payService: PaymentService? + private let configService: ConfigurationServiceProtocol! static var logLevel: LogLevel = .none - init(documentService: T, paymentService: PaymentService? ) + init(documentService: T, paymentService: PaymentService?, configurationService: ConfigurationServiceProtocol) { self.docService = documentService self.payService = paymentService + self.configService = configurationService } /** @@ -41,6 +43,10 @@ public final class GiniBankAPI { return payService ?? PaymentService(sessionManager: SessionManager(userDomain: .default), apiDomain: .default) } + public func configurationService() -> ConfigurationServiceProtocol { + return configService + } + /// Removes the user stored credentials. Recommended when logging a different user in your app. public func removeStoredCredentials() throws { let keychainStore: KeyStore = KeychainStore() @@ -103,25 +109,31 @@ extension GiniBankAPI { GiniBankAPI.logLevel = logLevel // Initialize GiniBankAPI + let sessionManager = createSessionManager() + let documentService = DefaultDocumentService(sessionManager: sessionManager, apiDomain: api) + let paymentService = PaymentService(sessionManager: sessionManager, apiDomain: api) + let configurationService = ConfigurationService(sessionManager: sessionManager, apiDomain: api) + + return GiniBankAPI(documentService: documentService, + paymentService: paymentService, + configurationService: configurationService) + } + + private func createSessionManager() -> SessionManager { switch api { case .default: - let sessionManager = SessionManager(userDomain: userApi, sessionDelegate: self.sessionDelegate) - return GiniBankAPI(documentService: DefaultDocumentService(sessionManager: sessionManager), paymentService: PaymentService(sessionManager: sessionManager, apiDomain: .default)) + return SessionManager(userDomain: userApi, sessionDelegate: self.sessionDelegate) case .custom(_, _, let tokenSource): - var sessionManager : SessionManager if let tokenSource = tokenSource { - sessionManager = SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate) + return SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate) } else { - sessionManager = SessionManager(userDomain: userApi, sessionDelegate: self.sessionDelegate) + return SessionManager(userDomain: userApi, sessionDelegate: self.sessionDelegate) } - return GiniBankAPI(documentService: DefaultDocumentService(sessionManager: sessionManager, apiDomain: api), paymentService: PaymentService(sessionManager: sessionManager, apiDomain: api)) case let .gym(tokenSource): - let sessionManager = SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate) - return GiniBankAPI(documentService: DefaultDocumentService(sessionManager: - sessionManager), paymentService: PaymentService(sessionManager: sessionManager)) + return SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate) } } - + private func save(_ client: Client) { do { try KeychainStore().save(item: KeychainManagerItem(key: .clientId, From 98a977946f24b235f2b5a221b216e1f1700bc2d7 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 6 Jun 2024 11:23:12 +0200 Subject: [PATCH 03/54] feat(GiniBankAPILibrary): update Configuration model resolve TODOs for APIResource & APIMethod PP-352 --- .../Sources/GiniBankAPILibrary/Documents/APIMethod.swift | 1 - .../Sources/GiniBankAPILibrary/Documents/APIResource.swift | 3 +-- .../Documents/Configuration/Configuration.swift | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift index c3ca27ca2..434f03f42 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift @@ -32,6 +32,5 @@ enum APIMethod: ResourceMethod { case resolvePaymentRequest(id: String) case payment(id: String) case logErrorEvent - // TODO: [PP-352] FAKE endpoint, replace when backend will be finished case fetchConfiguration } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift index e8b8361ff..de0566b79 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift @@ -123,8 +123,7 @@ struct APIResource: Resource { case .logErrorEvent: return "/events/error" case .fetchConfiguration: - // TODO: [PP-352] FAKE endpoint, replace when backend will be finished - return "/configuration-test" + return "/configuration" } } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift index cb7fe8238..6c8084754 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift @@ -7,10 +7,10 @@ import Foundation -// TODO: [PP-352] Check CodingKeys when backend will be finished public struct Configuration: Decodable { public let clientID: String public let userJourneyAnalyticsEnabled: Bool - public let mixpanelToken: String + public let mixpanelToken: String? public let skontoEnabled: Bool + public let returnAssistantEnabled: Bool } From 5bf337b18a019841638ff511445d3af1944b9795 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 6 Jun 2024 13:05:24 +0200 Subject: [PATCH 04/54] refactoring(GiniBankAPILibrary): remove gym domain PP-352 --- .../Sources/GiniBankAPILibrary/Documents/APIResource.swift | 5 +---- .../GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift index de0566b79..c431b29f9 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift @@ -10,15 +10,12 @@ import Foundation public enum APIDomain { /// The default one, which points to https://pay-api.gini.net case `default` - /// The GYM API, which points to https://gym.gini.net/ - case gym(tokenSource: AlternativeTokenSource) /// A custom domain with optional path and custom token source case custom(domain: String, path: String? = nil, tokenSource: AlternativeTokenSource?) var domainString: String { switch self { case .default: return "pay-api.gini.net" - case .gym: return "gym.gini.net" case .custom(let domain, _, _): return domain } } @@ -51,7 +48,7 @@ struct APIResource: Resource { var apiVersion: Int { switch domain { - case .default, .gym, .custom: return 2 + case .default, .custom: return 2 } } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index bb5161701..277b482e6 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -129,8 +129,6 @@ extension GiniBankAPI { } else { return SessionManager(userDomain: userApi, sessionDelegate: self.sessionDelegate) } - case let .gym(tokenSource): - return SessionManager(alternativeTokenSource: tokenSource, sessionDelegate: self.sessionDelegate) } } From c55510fdac56b55e8e0633e8f6e8dec8a1dd0dd7 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 6 Jun 2024 13:05:51 +0200 Subject: [PATCH 05/54] refactoring(GiniCaptureSDK): remove gym domain PP-352 --- .../Networking/GiniNetworkingScreenAPICoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift index e0f0b939e..f6fa9fe84 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift @@ -99,7 +99,7 @@ import GiniBankAPILibrary giniConfiguration: GiniConfiguration, for api: APIDomain) -> DocumentServiceProtocol { switch api { - case .default, .gym, .custom: + case .default, .custom: return DocumentService(lib: lib, metadata: documentMetadata) } } From c2228a928cb6e940614c49c34b41e113d985f0b3 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 6 Jun 2024 13:06:11 +0200 Subject: [PATCH 06/54] refactoring(GiniBankSDK): remove gym domain PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index e830da356..f18d0e03d 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -182,7 +182,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin configuration: GiniBankConfiguration, for api: APIDomain) -> DocumentServiceProtocol { switch api { - case .default, .gym, .custom: + case .default, .custom: return DocumentService(lib: lib, metadata: documentMetadata) } } From 3307f3aeb06789d6cb903309550d0a51a3a95301 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 13:43:42 +0200 Subject: [PATCH 07/54] refactor(GiniBankAPILibrary): split Configuration protocol & service by files. make inject to GiniBankAPI optional PP-352 --- .../Configuration/ConfigurationService.swift | 20 ------------- .../ConfigurationServiceProtocol.swift | 30 +++++++++++++++++++ .../Documents/Core/GiniBankAPI.swift | 4 +-- 3 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift index 6b796405e..089de90ca 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -7,10 +7,6 @@ import Foundation -public protocol ConfigurationServiceProtocol: AnyObject { - func fetchConfiguration(completion: @escaping CompletionResult) -} - public final class ConfigurationService: ConfigurationServiceProtocol { public func fetchConfiguration(completion: @escaping CompletionResult) { self.fetchConfiguration(resourceHandler: sessionManager.data, completion: completion) @@ -24,19 +20,3 @@ public final class ConfigurationService: ConfigurationServiceProtocol { self.apiDomain = apiDomain } } - -extension ConfigurationService { - func fetchConfiguration(resourceHandler: ResourceDataHandler>, - completion: @escaping CompletionResult) { - let resource = APIResource(method: .fetchConfiguration, apiDomain: .default, httpMethod: .get) - - resourceHandler(resource, { result in - switch result { - case let .success(configuration): - completion(.success(configuration)) - case let .failure(error): - completion(.failure(error)) - } - }) - } -} diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift new file mode 100644 index 000000000..381f697cd --- /dev/null +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -0,0 +1,30 @@ +// +// ConfigurationService.swift +// +// Copyright © 2024 Gini GmbH. All rights reserved. +// + + +import Foundation + +public protocol ConfigurationServiceProtocol: AnyObject { + var apiDomain: APIDomain { get set } + func fetchConfiguration(completion: @escaping CompletionResult) +} + +extension ConfigurationServiceProtocol { + func fetchConfiguration(resourceHandler: ResourceDataHandler>, + completion: @escaping CompletionResult) { + let resource = APIResource(method: .fetchConfiguration, apiDomain: apiDomain, httpMethod: .get) + + resourceHandler(resource, { result in + switch result { + case let .success(configuration): + completion(.success(configuration)) + case let .failure(error): + completion(.failure(error)) + } + }) + } +} + diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index 277b482e6..a1a79060a 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -12,7 +12,7 @@ public final class GiniBankAPI { private let docService: DocumentService! private let payService: PaymentService? - private let configService: ConfigurationServiceProtocol! + private let configService: ConfigurationServiceProtocol? static var logLevel: LogLevel = .none init(documentService: T, paymentService: PaymentService?, configurationService: ConfigurationServiceProtocol) @@ -43,7 +43,7 @@ public final class GiniBankAPI { return payService ?? PaymentService(sessionManager: SessionManager(userDomain: .default), apiDomain: .default) } - public func configurationService() -> ConfigurationServiceProtocol { + public func configurationService() -> ConfigurationServiceProtocol? { return configService } From 9d25699b9ccd2a03e25dd3c576133c8e4f8145ec Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 13:46:55 +0200 Subject: [PATCH 08/54] refactor(GiniBankAPILibrary): rename fetchConfiguration-> configurations PP-352 --- .../Sources/GiniBankAPILibrary/Documents/APIMethod.swift | 2 +- .../Sources/GiniBankAPILibrary/Documents/APIResource.swift | 4 ++-- .../Documents/Configuration/ConfigurationService.swift | 4 ++-- .../Configuration/ConfigurationServiceProtocol.swift | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift index 434f03f42..5c596a9da 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIMethod.swift @@ -32,5 +32,5 @@ enum APIMethod: ResourceMethod { case resolvePaymentRequest(id: String) case payment(id: String) case logErrorEvent - case fetchConfiguration + case configurations } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift index c431b29f9..8c3e498dd 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/APIResource.swift @@ -119,8 +119,8 @@ struct APIResource: Resource { return "/paymentRequests/\(id)/payment" case .logErrorEvent: return "/events/error" - case .fetchConfiguration: - return "/configuration" + case .configurations: + return "/configurations" } } diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift index 089de90ca..82b3c777c 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -8,8 +8,8 @@ import Foundation public final class ConfigurationService: ConfigurationServiceProtocol { - public func fetchConfiguration(completion: @escaping CompletionResult) { - self.fetchConfiguration(resourceHandler: sessionManager.data, completion: completion) + public func fetchConfigurations(completion: @escaping CompletionResult) { + self.fetchConfigurations(resourceHandler: sessionManager.data, completion: completion) } let sessionManager: SessionManagerProtocol diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift index 381f697cd..6bb573d9c 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -9,13 +9,13 @@ import Foundation public protocol ConfigurationServiceProtocol: AnyObject { var apiDomain: APIDomain { get set } - func fetchConfiguration(completion: @escaping CompletionResult) + func fetchConfigurations(completion: @escaping CompletionResult) } extension ConfigurationServiceProtocol { - func fetchConfiguration(resourceHandler: ResourceDataHandler>, + func fetchConfigurations(resourceHandler: ResourceDataHandler>, completion: @escaping CompletionResult) { - let resource = APIResource(method: .fetchConfiguration, apiDomain: apiDomain, httpMethod: .get) + let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) resourceHandler(resource, { result in switch result { From 8e56dff8d99816abb6e0f0695a0d0ac98924232a Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 14:50:26 +0200 Subject: [PATCH 09/54] refactor(GiniBankSDK): remove documentService static func init PP-352 --- .../GiniBankNetworkingScreenApiCoordinator.swift | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 52224e747..92f6276b6 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -121,10 +121,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin api: APIDomain, trackingDelegate: GiniCaptureTrackingDelegate?, lib: GiniBankAPI) { - documentService = GiniBankNetworkingScreenApiCoordinator.documentService(with: lib, - documentMetadata: documentMetadata, - configuration: configuration, - for: api) + documentService = DocumentService(lib: lib, metadata: documentMetadata) let captureConfiguration = configuration.captureConfiguration() super.init(withDelegate: nil, giniConfiguration: captureConfiguration) @@ -178,16 +175,6 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin lib: lib) } - private static func documentService(with lib: GiniBankAPI, - documentMetadata: Document.Metadata?, - configuration: GiniBankConfiguration, - for api: APIDomain) -> DocumentServiceProtocol { - switch api { - case .default, .custom: - return DocumentService(lib: lib, metadata: documentMetadata) - } - } - private func deliver(result: ExtractionResult, analysisDelegate: AnalysisDelegate) { let hasExtractions = result.extractions.count > 0 From b167f823c618d9bf9715c2ca0255d56e3252f5bf Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 14:51:54 +0200 Subject: [PATCH 10/54] feat(GiniBankSDK): fetchConfigurations request integration PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 92f6276b6..2532731ca 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -132,6 +132,14 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin self.trackAnalyticsProperties(configuration: configuration, client: client) self.resultsDelegate = resultsDelegate self.trackingDelegate = trackingDelegate + lib.configurationService()?.fetchConfigurations { result in + switch result { + case .success(let c): + print(c) + case .failure(let e): + print(e) + } + } } public init(resultsDelegate: GiniCaptureResultsDelegate, From 37dad4079532390b9822dca27d0e3a1ef16d6bda Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 14:55:35 +0200 Subject: [PATCH 11/54] feat(GiniCaptureSDK): add configuration service to GiniNetworkingScreenAPICoordinator custom networking viewController init PP-352 --- .../Extensions/GiniCapture+GiniCaptureDelegate.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift index 8da3b8975..e3e9a57d3 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift @@ -65,9 +65,10 @@ extension GiniCapture { resultsDelegate: GiniCaptureResultsDelegate, documentMetadata: Document.Metadata? = nil, trackingDelegate: GiniCaptureTrackingDelegate? = nil, - networkingService: GiniCaptureNetworkService) -> UIViewController { + networkingService: GiniCaptureNetworkService, + configurationService: ConfigurationServiceProtocol) -> UIViewController { GiniCapture.setConfiguration(configuration) - let screenCoordinator = GiniNetworkingScreenAPICoordinator(resultsDelegate: resultsDelegate, giniConfiguration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, captureNetworkService: networkingService) + let screenCoordinator = GiniNetworkingScreenAPICoordinator(resultsDelegate: resultsDelegate, giniConfiguration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, captureNetworkService: networkingService, configurationService: configurationService) configuration.giniErrorLogger = GiniErrorLogger(documentService: screenCoordinator.documentService) return screenCoordinator.start(withDocuments: importedDocuments) From 942ec285267a3de1ce8a665f0f84665881e9e224 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 14:56:08 +0200 Subject: [PATCH 12/54] refactor(GiniCaptureSDK): rename copyright PP-352 --- .../Networking/GiniNetworkingScreenAPICoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift index f6fa9fe84..f76b78bbd 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift @@ -2,7 +2,7 @@ // GiniNetworkingScreenAPICoordinator.swift // GiniCapture // -// Created by Alpár Szotyori on 25.06.19. +// Copyright © 2024 Gini GmbH. All rights reserved. // import Foundation From 5474f284b100ff04bd7d07da434544fda94593a1 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 14:57:58 +0200 Subject: [PATCH 13/54] refactor(GiniCaptureSDK): GiniNetworkingScreenAPICoordinator refactoring add configuration service dependency PP-352 --- .../GiniNetworkingScreenAPICoordinator.swift | 70 ++++++++----------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift index f76b78bbd..0a7922289 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift @@ -31,47 +31,45 @@ import GiniBankAPILibrary func giniCaptureDidEnterManually() } - public class GiniNetworkingScreenAPICoordinator: GiniScreenAPICoordinator { +public class GiniNetworkingScreenAPICoordinator: GiniScreenAPICoordinator { public weak var resultsDelegate: GiniCaptureResultsDelegate? public let documentService: DocumentServiceProtocol - + public init(client: Client, - resultsDelegate: GiniCaptureResultsDelegate, - giniConfiguration: GiniConfiguration, - documentMetadata: Document.Metadata?, - api: APIDomain, - trackingDelegate: GiniCaptureTrackingDelegate?, - lib : GiniBankAPI) { - - self.documentService = GiniNetworkingScreenAPICoordinator.documentService(with: lib, - documentMetadata: documentMetadata, - giniConfiguration: giniConfiguration, - for: api) + resultsDelegate: GiniCaptureResultsDelegate, + giniConfiguration: GiniConfiguration, + documentMetadata: Document.Metadata?, + api: APIDomain, + trackingDelegate: GiniCaptureTrackingDelegate?, + lib : GiniBankAPI) { + + self.documentService = DocumentService(lib: lib, metadata: documentMetadata) super.init(withDelegate: nil, giniConfiguration: giniConfiguration) - + + self.giniConfiguration.documentService = documentService + self.visionDelegate = self + self.resultsDelegate = resultsDelegate + self.trackingDelegate = trackingDelegate + } + + public init(resultsDelegate: GiniCaptureResultsDelegate, + giniConfiguration: GiniConfiguration, + documentMetadata: Document.Metadata?, + trackingDelegate: GiniCaptureTrackingDelegate?, + captureNetworkService: GiniCaptureNetworkService, + configurationService: ConfigurationServiceProtocol) { + + self.documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) + + super.init(withDelegate: nil, + giniConfiguration: giniConfiguration) + self.giniConfiguration.documentService = documentService self.visionDelegate = self self.resultsDelegate = resultsDelegate self.trackingDelegate = trackingDelegate } - - public init(resultsDelegate: GiniCaptureResultsDelegate, - giniConfiguration: GiniConfiguration, - documentMetadata: Document.Metadata?, - trackingDelegate: GiniCaptureTrackingDelegate?, - captureNetworkService: GiniCaptureNetworkService) { - - self.documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) - - super.init(withDelegate: nil, - giniConfiguration: giniConfiguration) - - self.giniConfiguration.documentService = documentService - self.visionDelegate = self - self.resultsDelegate = resultsDelegate - self.trackingDelegate = trackingDelegate - } convenience init(client: Client, resultsDelegate: GiniCaptureResultsDelegate, @@ -94,16 +92,6 @@ import GiniBankAPILibrary lib: lib) } - private static func documentService(with lib: GiniBankAPI, - documentMetadata: Document.Metadata?, - giniConfiguration: GiniConfiguration, - for api: APIDomain) -> DocumentServiceProtocol { - switch api { - case .default, .custom: - return DocumentService(lib: lib, metadata: documentMetadata) - } - } - public func deliver(result: ExtractionResult, and document: Document? = nil, to analysisDelegate: AnalysisDelegate) { let hasExtactions = result.extractions.count > 0 From 60a777f2ec87c67bdf7feb642511b1bdba86c0cd Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 16:06:48 +0200 Subject: [PATCH 14/54] feat(GiniCaptureSDK): mark configuration service as optional for custom networking PP-352 --- .../Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift | 2 +- .../Networking/GiniNetworkingScreenAPICoordinator.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift index e3e9a57d3..89e3f4756 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift @@ -66,7 +66,7 @@ extension GiniCapture { documentMetadata: Document.Metadata? = nil, trackingDelegate: GiniCaptureTrackingDelegate? = nil, networkingService: GiniCaptureNetworkService, - configurationService: ConfigurationServiceProtocol) -> UIViewController { + configurationService: ConfigurationServiceProtocol? = nil) -> UIViewController { GiniCapture.setConfiguration(configuration) let screenCoordinator = GiniNetworkingScreenAPICoordinator(resultsDelegate: resultsDelegate, giniConfiguration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, captureNetworkService: networkingService, configurationService: configurationService) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift index 0a7922289..7e5348809 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift @@ -58,7 +58,7 @@ public class GiniNetworkingScreenAPICoordinator: GiniScreenAPICoordinator { documentMetadata: Document.Metadata?, trackingDelegate: GiniCaptureTrackingDelegate?, captureNetworkService: GiniCaptureNetworkService, - configurationService: ConfigurationServiceProtocol) { + configurationService: ConfigurationServiceProtocol?) { self.documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) From c3beabe0432d44b7a4829d2df153e594800f63e5 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 16:47:51 +0200 Subject: [PATCH 15/54] refactor(GiniBankAPILibrary): remove setter from apiDomain in ConfigurationServiceProtocol PP-352 --- .../Documents/Configuration/ConfigurationServiceProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift index 6bb573d9c..db6961466 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -8,7 +8,7 @@ import Foundation public protocol ConfigurationServiceProtocol: AnyObject { - var apiDomain: APIDomain { get set } + var apiDomain: APIDomain { get } func fetchConfigurations(completion: @escaping CompletionResult) } From 62ac2172485acd5536e1e3434a3175d62c934f7b Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 20:10:08 +0200 Subject: [PATCH 16/54] feat(GiniBankSDK): inject configuration service to custom networking PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 3 ++- .../GiniBankSDK/Core/Networking/GiniBank+Networking.swift | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 2532731ca..3ad7eac57 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -146,7 +146,8 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin configuration: GiniBankConfiguration, documentMetadata: Document.Metadata?, trackingDelegate: GiniCaptureTrackingDelegate?, - captureNetworkService: GiniCaptureNetworkService) { + captureNetworkService: GiniCaptureNetworkService, + configurationService: ConfigurationServiceProtocol?) { documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift index d11f65a5b..01d5ae4ce 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift @@ -69,12 +69,14 @@ extension GiniBank { resultsDelegate: GiniCaptureResultsDelegate, documentMetadata: Document.Metadata? = nil, trackingDelegate: GiniCaptureTrackingDelegate? = nil, - networkingService: GiniCaptureNetworkService) -> UIViewController { + networkingService: GiniCaptureNetworkService, + configurationService: ConfigurationServiceProtocol? = nil) -> UIViewController { let screenCoordinator = GiniBankNetworkingScreenApiCoordinator(resultsDelegate: resultsDelegate, configuration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, - captureNetworkService: networkingService) + captureNetworkService: networkingService, + configurationService: configurationService) return screenCoordinator.start(withDocuments: importedDocuments) } From 8e9a9b02c9ffcce9affb2fb4dc000f452c467c4c Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Mon, 10 Jun 2024 20:10:42 +0200 Subject: [PATCH 17/54] feat(GiniCaptureSDK): remove configuration service inject from custom networking PP-352 --- .../Extensions/GiniCapture+GiniCaptureDelegate.swift | 2 +- .../Networking/GiniNetworkingScreenAPICoordinator.swift | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift index 89e3f4756..54a77bce5 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift @@ -68,7 +68,7 @@ extension GiniCapture { networkingService: GiniCaptureNetworkService, configurationService: ConfigurationServiceProtocol? = nil) -> UIViewController { GiniCapture.setConfiguration(configuration) - let screenCoordinator = GiniNetworkingScreenAPICoordinator(resultsDelegate: resultsDelegate, giniConfiguration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, captureNetworkService: networkingService, configurationService: configurationService) + let screenCoordinator = GiniNetworkingScreenAPICoordinator(resultsDelegate: resultsDelegate, giniConfiguration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, captureNetworkService: networkingService) configuration.giniErrorLogger = GiniErrorLogger(documentService: screenCoordinator.documentService) return screenCoordinator.start(withDocuments: importedDocuments) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift index 7e5348809..c40798196 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/GiniNetworkingScreenAPICoordinator.swift @@ -57,8 +57,7 @@ public class GiniNetworkingScreenAPICoordinator: GiniScreenAPICoordinator { giniConfiguration: GiniConfiguration, documentMetadata: Document.Metadata?, trackingDelegate: GiniCaptureTrackingDelegate?, - captureNetworkService: GiniCaptureNetworkService, - configurationService: ConfigurationServiceProtocol?) { + captureNetworkService: GiniCaptureNetworkService) { self.documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) From 28b4921b5a417ce04adcd9850da6aa3aa52f9b25 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 19:28:36 +0200 Subject: [PATCH 18/54] feat(GiniBankAPILibrary): add amplitude key to Configuration PP-352 --- .../Documents/Configuration/Configuration.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift index 6c8084754..586ffea5d 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift @@ -11,6 +11,7 @@ public struct Configuration: Decodable { public let clientID: String public let userJourneyAnalyticsEnabled: Bool public let mixpanelToken: String? + public let amplitudeApiKey: String? public let skontoEnabled: Bool public let returnAssistantEnabled: Bool } From 26c4c8ccfc45e62d4adcd14a73368f6ffc51f7c1 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 19:29:40 +0200 Subject: [PATCH 19/54] feat(GiniBankAPILibrary): remove extension from ConfigurationServiceProtocol and add it to ConfigurationService. remove APIDomain from protocol PP-352 --- .../Configuration/ConfigurationService.swift | 16 ++++++++++++++++ .../ConfigurationServiceProtocol.swift | 11 ----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift index 82b3c777c..fbfffd584 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -20,3 +20,19 @@ public final class ConfigurationService: ConfigurationServiceProtocol { self.apiDomain = apiDomain } } + +extension ConfigurationService { + func fetchConfigurations(resourceHandler: ResourceDataHandler>, + completion: @escaping CompletionResult) { + let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) + + resourceHandler(resource, { result in + switch result { + case let .success(configuration): + completion(.success(configuration)) + case let .failure(error): + completion(.failure(error)) + } + }) + } +} diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift index db6961466..fec85fb3a 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -8,23 +8,12 @@ import Foundation public protocol ConfigurationServiceProtocol: AnyObject { - var apiDomain: APIDomain { get } func fetchConfigurations(completion: @escaping CompletionResult) } extension ConfigurationServiceProtocol { func fetchConfigurations(resourceHandler: ResourceDataHandler>, completion: @escaping CompletionResult) { - let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) - - resourceHandler(resource, { result in - switch result { - case let .success(configuration): - completion(.success(configuration)) - case let .failure(error): - completion(.failure(error)) - } - }) } } From 88e2d13dd69c7a53d61987e12a78a2ba6140c61f Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 19:37:10 +0200 Subject: [PATCH 20/54] feat(GiniCaptureSDK): add AnalyticsConfiguration and update AnalyticsManager init PP-352 --- .../Core/Tracking/AnalyticsManager.swift | 6 ++++- .../Models/AnalyticsConfiguration.swift | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift index 0527a4ad6..b4c5a80e0 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift @@ -15,7 +15,11 @@ public class AnalyticsManager { private static var userProperties: [AnalyticsUserProperty: AnalyticsPropertyValue] = [:] private static var superProperties: [AnalyticsSuperProperty: AnalyticsPropertyValue] = [:] - public static func initializeAnalytics() { + public static func initializeAnalytics(with configuration: AnalyticsConfiguration) { + guard configuration.userJourneyAnalyticsEnabled else { + return + } + // TODO: setup mixPanelToken and amplitudeKey after prod/stage credentials setup // Identify the user with the deviceID let deviceID = UIDevice.current.identifierForVendor?.uuidString ?? "" initializeAmplitude(with: deviceID) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift new file mode 100644 index 000000000..71ce1a29f --- /dev/null +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift @@ -0,0 +1,22 @@ +// +// AnalyticsConfiguration.swift +// +// Copyright © 2024 Gini GmbH. All rights reserved. +// + + +import Foundation + +public struct AnalyticsConfiguration { + public let clientID: String + public let userJourneyAnalyticsEnabled: Bool + public let mixpanelToken: String? + public let amplitudeApiKey: String? + + public init(clientID: String, userJourneyAnalyticsEnabled: Bool, mixpanelToken: String?, amplitudeApiKey: String?) { + self.clientID = clientID + self.userJourneyAnalyticsEnabled = userJourneyAnalyticsEnabled + self.mixpanelToken = mixpanelToken + self.amplitudeApiKey = amplitudeApiKey + } +} From c9379e37907916f99205db7dea1e6cd11e8688d1 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 19:42:01 +0200 Subject: [PATCH 21/54] feat(GiniCaptureSDK): remove AnalyticsManager init PP-352 --- .../Screen API Coordinator/GiniScreenAPICoordinator.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift index b916c3741..542558f13 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Screens/Screen API Coordinator/GiniScreenAPICoordinator.swift @@ -87,7 +87,6 @@ open class GiniScreenAPICoordinator: NSObject, Coordinator { public func start(withDocuments documents: [GiniCaptureDocument]?, animated: Bool = false) -> UIViewController { - AnalyticsManager.initializeAnalytics() var viewControllers: [UIViewController] = [] if let documents = documents, !documents.isEmpty { From 75fb30d3a9352c36e50840fcc82a69d9478fdbc6 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 19:43:25 +0200 Subject: [PATCH 22/54] feat(GiniBankSDK): add startSDK method to networking coordinator. Move AnalyticsManager init to request completion PP-352 --- ...niBankNetworkingScreenApiCoordinator.swift | 32 ++++++++++++++----- .../Core/Networking/GiniBank+Networking.swift | 4 +-- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 3ad7eac57..c1841fbf4 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -112,6 +112,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin weak var resultsDelegate: GiniCaptureResultsDelegate? let documentService: DocumentServiceProtocol + var configurationService: ConfigurationServiceProtocol? var giniBankConfiguration = GiniBankConfiguration.shared public init(client: Client, @@ -122,6 +123,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin trackingDelegate: GiniCaptureTrackingDelegate?, lib: GiniBankAPI) { documentService = DocumentService(lib: lib, metadata: documentMetadata) + configurationService = lib.configurationService() let captureConfiguration = configuration.captureConfiguration() super.init(withDelegate: nil, giniConfiguration: captureConfiguration) @@ -132,14 +134,6 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin self.trackAnalyticsProperties(configuration: configuration, client: client) self.resultsDelegate = resultsDelegate self.trackingDelegate = trackingDelegate - lib.configurationService()?.fetchConfigurations { result in - switch result { - case .success(let c): - print(c) - case .failure(let e): - print(e) - } - } } public init(resultsDelegate: GiniCaptureResultsDelegate, @@ -151,6 +145,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) + self.configurationService = configurationService let captureConfiguration = configuration.captureConfiguration() super.init(withDelegate: nil, @@ -216,6 +211,27 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin public func didPressEnterManually() { self.resultsDelegate?.giniCaptureDidEnterManually() } + + public func startSDK(withDocuments documents: [GiniCaptureDocument]?, animated: Bool = false) -> UIViewController { + configurationService?.fetchConfigurations(completion: { result in + switch result { + case .success(let configuration): + self.initializeAnalytics(with: configuration) + case .failure(let error): + // TODO: Handle error + break + } + }) + return self.start(withDocuments: documents, animated: animated) + } + + private func initializeAnalytics(with configuration: Configuration) { + let analyticsConfiguration: AnalyticsConfiguration = .init(clientID: configuration.clientID, + userJourneyAnalyticsEnabled: configuration.userJourneyAnalyticsEnabled, + mixpanelToken: configuration.mixpanelToken, + amplitudeApiKey: configuration.amplitudeApiKey) + AnalyticsManager.initializeAnalytics(with: analyticsConfiguration) + } } extension GiniBankNetworkingScreenApiCoordinator { diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift index 01d5ae4ce..a1ac6c3e3 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift @@ -43,7 +43,7 @@ extension GiniBank { api: api, userApi: userApi, trackingDelegate: trackingDelegate) - return screenCoordinator.start(withDocuments: importedDocuments) + return screenCoordinator.startSDK(withDocuments: importedDocuments) } // MARK: - Screen API with Custom Networking - Initializers for 'UIViewController' @@ -77,7 +77,7 @@ extension GiniBank { trackingDelegate: trackingDelegate, captureNetworkService: networkingService, configurationService: configurationService) - return screenCoordinator.start(withDocuments: importedDocuments) + return screenCoordinator.startSDK(withDocuments: importedDocuments) } public class func removeStoredCredentials(for client: Client) throws { From 2ca864f1a0f4d25b0056ec2d66a57831f1682c88 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 19:43:58 +0200 Subject: [PATCH 23/54] feat(GiniBankSDKExample): add ConfigurationService dependency to custom networking example PP-352 --- .../Screen API/ScreenAPICoordinator.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/BankSDK/GiniBankSDKExample/GiniBankSDKExample/Screen API/ScreenAPICoordinator.swift b/BankSDK/GiniBankSDKExample/GiniBankSDKExample/Screen API/ScreenAPICoordinator.swift index fc396e0ca..034261195 100644 --- a/BankSDK/GiniBankSDKExample/GiniBankSDKExample/Screen API/ScreenAPICoordinator.swift +++ b/BankSDK/GiniBankSDKExample/GiniBankSDKExample/Screen API/ScreenAPICoordinator.swift @@ -83,11 +83,12 @@ final class ScreenAPICoordinator: NSObject, Coordinator, UINavigationControllerD trackingDelegate: trackingDelegate) // MARK: - Screen API with custom networking // let viewController = GiniBank.viewController(importedDocuments: visionDocuments, -// configuration: configuration, -// resultsDelegate: self, -// documentMetadata: documentMetadata, -// trackingDelegate: trackingDelegate, -// networkingService: self) +// configuration: configuration, +// resultsDelegate: self, +// documentMetadata: documentMetadata, +// trackingDelegate: trackingDelegate, +// networkingService: self, +// configurationService: nil) // MARK: - Screen API - UI Only // let viewController = GiniBank.viewController(withDelegate: self, withConfiguration: configuration) From 7353db36264b912a85c262f3645029b40b208fcd Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 20:11:07 +0200 Subject: [PATCH 24/54] refactoring(GiniBankSDK): refactor initializeAnalytics PP-352 --- .../GiniBankNetworkingScreenApiCoordinator.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index c1841fbf4..be131aa6a 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -219,17 +219,17 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin self.initializeAnalytics(with: configuration) case .failure(let error): // TODO: Handle error - break + print(error) } }) return self.start(withDocuments: documents, animated: animated) } - + private func initializeAnalytics(with configuration: Configuration) { - let analyticsConfiguration: AnalyticsConfiguration = .init(clientID: configuration.clientID, - userJourneyAnalyticsEnabled: configuration.userJourneyAnalyticsEnabled, - mixpanelToken: configuration.mixpanelToken, - amplitudeApiKey: configuration.amplitudeApiKey) + let analyticsConfiguration = AnalyticsConfiguration(clientID: configuration.clientID, + userJourneyAnalyticsEnabled: configuration.userJourneyAnalyticsEnabled, + mixpanelToken: configuration.mixpanelToken, + amplitudeApiKey: configuration.amplitudeApiKey) AnalyticsManager.initializeAnalytics(with: analyticsConfiguration) } } From 7d376585001c9f3ca362386c85cffd072ad7c0c2 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Tue, 11 Jun 2024 20:12:23 +0200 Subject: [PATCH 25/54] refactoring(GiniBankSDK): refactor copyrights PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index be131aa6a..1b5ee8444 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -1,8 +1,8 @@ // // GiniPayBankNetworkingScreenApiCoordinator.swift -// GiniBank +// GiniBank // -// Created by Nadya Karaban on 03.03.21. +// Copyright © 2024 Gini GmbH. All rights reserved. // import Foundation From c60a5525fbef3a83e8863852b0c8cfd3067538fb Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 08:11:35 +0200 Subject: [PATCH 26/54] refactoring(GiniBankSDK): make configuration service private in networking coordinator PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 1b5ee8444..dbd278e4b 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -112,7 +112,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin weak var resultsDelegate: GiniCaptureResultsDelegate? let documentService: DocumentServiceProtocol - var configurationService: ConfigurationServiceProtocol? + private var configurationService: ConfigurationServiceProtocol? var giniBankConfiguration = GiniBankConfiguration.shared public init(client: Client, From 44aff78d512f94524b0fc1a222b53c69ff4a68b8 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 09:16:42 +0200 Subject: [PATCH 27/54] feat(GiniCaptureSDK): integrate configuration tokens to analytics manager. Add clientID super property from configuration PP-352 --- .../Core/Tracking/AnalyticsManager.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift index b4c5a80e0..9fe2ace0c 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift @@ -19,25 +19,26 @@ public class AnalyticsManager { guard configuration.userJourneyAnalyticsEnabled else { return } - // TODO: setup mixPanelToken and amplitudeKey after prod/stage credentials setup // Identify the user with the deviceID let deviceID = UIDevice.current.identifierForVendor?.uuidString ?? "" - initializeAmplitude(with: deviceID) - initializeMixpanel(with: deviceID) + // TODO: remove default tokens after tests + initializeAmplitude(with: deviceID, apiKey: configuration.amplitudeApiKey ?? amplitudeKey) + initializeMixpanel(with: deviceID, token: configuration.mixpanelToken ?? mixPanelToken) + registerSuperProperties([.giniClientID: configuration.clientID]) registerSuperProperties(superProperties) trackUserProperties(userProperties) trackAccessibilityUserPropertiesAtInitialization() } - private static func initializeMixpanel(with deviceID: String) { - mixpanelInstance = Mixpanel.initialize(token: mixPanelToken, + private static func initializeMixpanel(with deviceID: String, token: String) { + mixpanelInstance = Mixpanel.initialize(token: token, trackAutomaticEvents: false, serverURL: "https://api-eu.mixpanel.com") mixpanelInstance?.identify(distinctId: deviceID) } - private static func initializeAmplitude(with deviceID: String) { - Amplitude.instance().initializeApiKey(amplitudeKey) + private static func initializeAmplitude(with deviceID: String, apiKey: String) { + Amplitude.instance().initializeApiKey(apiKey) Amplitude.instance().setDeviceId(deviceID) } From 6fe4ac9289d837b71c5c674223c6a3cd8e2d8028 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 09:17:43 +0200 Subject: [PATCH 28/54] feat(GiniBankSDK): remove clientID super property track from coordinator PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index dbd278e4b..3b8d55d18 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -131,7 +131,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin GiniBank.setConfiguration(configuration) giniBankConfiguration = configuration giniBankConfiguration.documentService = documentService - self.trackAnalyticsProperties(configuration: configuration, client: client) + self.trackAnalyticsProperties(configuration: configuration) self.resultsDelegate = resultsDelegate self.trackingDelegate = trackingDelegate } @@ -336,13 +336,9 @@ extension GiniBankNetworkingScreenApiCoordinator { }) } - private func trackAnalyticsProperties(configuration: GiniBankConfiguration, client: Client? = nil) { + private func trackAnalyticsProperties(configuration: GiniBankConfiguration) { AnalyticsManager.trackUserProperties([.returnAssistantEnabled: configuration.returnAssistantEnabled, .returnReasonsEnabled: configuration.enableReturnReasons]) - // TODO: No clientID user property for custom networking init - if let client { - AnalyticsManager.registerSuperProperties([.giniClientID: client.id]) - } } } From 8fa23f0cc2b56482fa03e33d7c8a60f0a5b22e74 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 11:20:27 +0200 Subject: [PATCH 29/54] refactoring(GiniCaptureSDK): refactor super properties tracking PP-352 --- .../Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift index 9fe2ace0c..1d7a9dd14 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift @@ -24,7 +24,7 @@ public class AnalyticsManager { // TODO: remove default tokens after tests initializeAmplitude(with: deviceID, apiKey: configuration.amplitudeApiKey ?? amplitudeKey) initializeMixpanel(with: deviceID, token: configuration.mixpanelToken ?? mixPanelToken) - registerSuperProperties([.giniClientID: configuration.clientID]) + superProperties[.giniClientID] = configuration.clientID registerSuperProperties(superProperties) trackUserProperties(userProperties) trackAccessibilityUserPropertiesAtInitialization() From 50cc32b317b788c970556a189d86724b2288a351 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 11:25:35 +0200 Subject: [PATCH 30/54] refactoring(GiniBankAPILibrary): refactor GiniBankAPI init, mark configuration service as optional PP-352 --- .../GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index a1a79060a..a83853145 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -15,8 +15,7 @@ public final class GiniBankAPI { private let configService: ConfigurationServiceProtocol? static var logLevel: LogLevel = .none - init(documentService: T, paymentService: PaymentService?, configurationService: ConfigurationServiceProtocol) - { + init(documentService: T, paymentService: PaymentService?, configurationService: ConfigurationServiceProtocol?) { self.docService = documentService self.payService = paymentService self.configService = configurationService From 4a8d71df5a7370a8ed328d2faf4ee04ea607bee1 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 11:31:10 +0200 Subject: [PATCH 31/54] feat(GiniCaptureSDK): remove AnalyticsManager amplitudeKey & mixPanelToken properties, use only backend ones PP-352 --- .../Core/Tracking/AnalyticsManager.swift | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift index 1d7a9dd14..74ddf3e6d 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift @@ -9,35 +9,32 @@ import Mixpanel import Amplitude public class AnalyticsManager { - private static let mixPanelToken = "6262hhdfhdb929321222" // this id is fake we need to replace it private static var mixpanelInstance: MixpanelInstance? - private static let amplitudeKey = "" private static var userProperties: [AnalyticsUserProperty: AnalyticsPropertyValue] = [:] private static var superProperties: [AnalyticsSuperProperty: AnalyticsPropertyValue] = [:] public static func initializeAnalytics(with configuration: AnalyticsConfiguration) { - guard configuration.userJourneyAnalyticsEnabled else { - return - } + guard configuration.userJourneyAnalyticsEnabled else { return } // Identify the user with the deviceID let deviceID = UIDevice.current.identifierForVendor?.uuidString ?? "" - // TODO: remove default tokens after tests - initializeAmplitude(with: deviceID, apiKey: configuration.amplitudeApiKey ?? amplitudeKey) - initializeMixpanel(with: deviceID, token: configuration.mixpanelToken ?? mixPanelToken) + initializeAmplitude(with: deviceID, apiKey: configuration.amplitudeApiKey) + initializeMixpanel(with: deviceID, token: configuration.mixpanelToken) superProperties[.giniClientID] = configuration.clientID registerSuperProperties(superProperties) trackUserProperties(userProperties) trackAccessibilityUserPropertiesAtInitialization() } - private static func initializeMixpanel(with deviceID: String, token: String) { + private static func initializeMixpanel(with deviceID: String, token: String?) { + guard let token else { return } mixpanelInstance = Mixpanel.initialize(token: token, trackAutomaticEvents: false, serverURL: "https://api-eu.mixpanel.com") mixpanelInstance?.identify(distinctId: deviceID) } - private static func initializeAmplitude(with deviceID: String, apiKey: String) { + private static func initializeAmplitude(with deviceID: String, apiKey: String?) { + guard let apiKey else { return } Amplitude.instance().initializeApiKey(apiKey) Amplitude.instance().setDeviceId(deviceID) } From ccaa83a57cd9dcb05fa4a47c465c4daae62ae8b1 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 13:16:06 +0200 Subject: [PATCH 32/54] feat(GiniBankSDK): remove TODO and leave comment for error handling PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 3b8d55d18..678cd4f44 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -217,9 +217,11 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin switch result { case .success(let configuration): self.initializeAnalytics(with: configuration) - case .failure(let error): - // TODO: Handle error - print(error) + case .failure(let error): + break + /* There will be no retries if the endpoint fails. + We will not implement any caching mechanism on our side if the request is too slow. + In case of a failure, the UJ analytics will remain disabled for that session. */ } }) return self.start(withDocuments: documents, animated: animated) From c0c1bbd7bcf51e7d1d57f9ae2843738addece119 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 13:22:22 +0200 Subject: [PATCH 33/54] feat(GiniBankAPILibrary): add documentation for Configuration PP-352 --- .../Configuration/Configuration.swift | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift index 586ffea5d..022e9c2ef 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift @@ -7,7 +7,34 @@ import Foundation +/** + Struct for configuration settings + */ public struct Configuration: Decodable { + /** + An initializer for a `Configuration` structure + + - parameter clientID: A unique identifier for the client. + - parameter userJourneyAnalyticsEnabled: A flag indicating whether user journey analytics is enabled. + - parameter mixpanelToken: An optional token for Mixpanel integration. + - parameter amplitudeApiKey: An optional API key for Amplitude integration. + - parameter skontoEnabled: A flag indicating whether Skonto is enabled. + - parameter returnAssistantEnabled: A flag indicating whether the return assistant feature is enabled. + */ + public init(clientID: String, + userJourneyAnalyticsEnabled: Bool, + mixpanelToken: String? = nil, + amplitudeApiKey: String? = nil, + skontoEnabled: Bool, + returnAssistantEnabled: Bool) { + self.clientID = clientID + self.userJourneyAnalyticsEnabled = userJourneyAnalyticsEnabled + self.mixpanelToken = mixpanelToken + self.amplitudeApiKey = amplitudeApiKey + self.skontoEnabled = skontoEnabled + self.returnAssistantEnabled = returnAssistantEnabled + } + public let clientID: String public let userJourneyAnalyticsEnabled: Bool public let mixpanelToken: String? From 5f967383d24531f514e94fb68b6bc8d704482ff9 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 13:55:02 +0200 Subject: [PATCH 34/54] feat(GiniBankAPILibrary): add documentation for ConfigurationService & ConfigurationServiceProtocol PP-352 --- .../Configuration/ConfigurationService.swift | 5 ++++- .../ConfigurationServiceProtocol.swift | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift index fbfffd584..c3ed9b0a7 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -7,6 +7,9 @@ import Foundation +/** + A service class to fetch configuration settings + */ public final class ConfigurationService: ConfigurationServiceProtocol { public func fetchConfigurations(completion: @escaping CompletionResult) { self.fetchConfigurations(resourceHandler: sessionManager.data, completion: completion) @@ -23,7 +26,7 @@ public final class ConfigurationService: ConfigurationServiceProtocol { extension ConfigurationService { func fetchConfigurations(resourceHandler: ResourceDataHandler>, - completion: @escaping CompletionResult) { + completion: @escaping CompletionResult) { let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) resourceHandler(resource, { result in diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift index fec85fb3a..2fb1fe0c6 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -7,13 +7,28 @@ import Foundation +/** + Protocol for configuration service + */ public protocol ConfigurationServiceProtocol: AnyObject { + /** + Fetches configurations from the server. + + - parameter completion: A closure that handles the result of the configuration fetch operation. + */ func fetchConfigurations(completion: @escaping CompletionResult) } extension ConfigurationServiceProtocol { + /** + Fetches configurations using the provided resource handler. + + - parameter resourceHandler: The handler that processes the API resource data. + - parameter completion: A closure that handles the result of the configuration fetch operation. + */ func fetchConfigurations(resourceHandler: ResourceDataHandler>, - completion: @escaping CompletionResult) { + completion: @escaping CompletionResult) { + // Default implementation is empty } } From c7800d534e1863966bfad6fa16014e034944363b Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 13:56:31 +0200 Subject: [PATCH 35/54] refactoring(GiniBankAPILibrary): rename copyrights filename for ConfigurationServiceProtocol PP-352 --- .../Documents/Configuration/ConfigurationServiceProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift index 2fb1fe0c6..2ed4f15f1 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -1,5 +1,5 @@ // -// ConfigurationService.swift +// ConfigurationServiceProtocol.swift // // Copyright © 2024 Gini GmbH. All rights reserved. // From f57072d240213d79f1e00d6bdb25265a4dde6b45 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 14:00:52 +0200 Subject: [PATCH 36/54] feat(GiniCaptureSDK): add documentation for AnalyticsConfiguration PP-352 --- .../Models/AnalyticsConfiguration.swift | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift index 71ce1a29f..50c7aabcf 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/Models/AnalyticsConfiguration.swift @@ -4,19 +4,30 @@ // Copyright © 2024 Gini GmbH. All rights reserved. // - -import Foundation - +/** + Struct for analytics configuration settings + */ public struct AnalyticsConfiguration { - public let clientID: String - public let userJourneyAnalyticsEnabled: Bool - public let mixpanelToken: String? - public let amplitudeApiKey: String? - - public init(clientID: String, userJourneyAnalyticsEnabled: Bool, mixpanelToken: String?, amplitudeApiKey: String?) { + /** + An initializer for an `AnalyticsConfiguration` structure + + - parameter clientID: A unique identifier for the client. + - parameter userJourneyAnalyticsEnabled: A flag indicating whether user journey analytics is enabled. + - parameter mixpanelToken: An optional token for Mixpanel integration. + - parameter amplitudeApiKey: An optional API key for Amplitude integration. + */ + public init(clientID: String, + userJourneyAnalyticsEnabled: Bool, + mixpanelToken: String?, + amplitudeApiKey: String?) { self.clientID = clientID self.userJourneyAnalyticsEnabled = userJourneyAnalyticsEnabled self.mixpanelToken = mixpanelToken self.amplitudeApiKey = amplitudeApiKey } + + public let clientID: String + public let userJourneyAnalyticsEnabled: Bool + public let mixpanelToken: String? + public let amplitudeApiKey: String? } From ff5c58cba00ff54c2eae90cd302b259eedeb2c3c Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Wed, 12 Jun 2024 15:45:48 +0200 Subject: [PATCH 37/54] feat(GiniCaptureSDK): add trackingAuthorized check before analytics init PP-352 --- .../GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift index 72529e5ad..2f6699943 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift @@ -14,7 +14,8 @@ public class AnalyticsManager { private static var superProperties: [AnalyticsSuperProperty: AnalyticsPropertyValue] = [:] public static func initializeAnalytics(with configuration: AnalyticsConfiguration) { - guard configuration.userJourneyAnalyticsEnabled else { return } + guard configuration.userJourneyAnalyticsEnabled, + GiniTrackingPermissionManager.shared.trackingAuthorized() else { return } // Identify the user with the deviceID let deviceID = UIDevice.current.identifierForVendor?.uuidString ?? "" initializeAmplitude(with: deviceID, apiKey: configuration.amplitudeApiKey) From 54bed5a73d6a7c203913aeed151613e1176f4e03 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 15:14:21 +0200 Subject: [PATCH 38/54] refactoring(GiniBankAPILibrary): improve documentation for Configuration PP-352 --- .../Documents/Configuration/Configuration.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift index 022e9c2ef..f5f18feb9 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift @@ -8,16 +8,18 @@ import Foundation /** - Struct for configuration settings + A struct representing configuration settings for an application. + + This struct holds various configuration options that can be used to customize the behavior and features of the application. */ public struct Configuration: Decodable { /** - An initializer for a `Configuration` structure + Creates a new `Configuration` instance. - parameter clientID: A unique identifier for the client. - parameter userJourneyAnalyticsEnabled: A flag indicating whether user journey analytics is enabled. - - parameter mixpanelToken: An optional token for Mixpanel integration. - - parameter amplitudeApiKey: An optional API key for Amplitude integration. + - parameter mixpanelToken: An optional token for Mixpanel integration. Defaults to `nil`. + - parameter amplitudeApiKey: An optional API key for Amplitude integration. Defaults to `nil`. - parameter skontoEnabled: A flag indicating whether Skonto is enabled. - parameter returnAssistantEnabled: A flag indicating whether the return assistant feature is enabled. */ From 496cd40eb13efc9c034c57b98627acb4cec60d56 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 15:14:36 +0200 Subject: [PATCH 39/54] refactoring(GiniBankAPILibrary): improve documentation for ConfigurationService PP-352 --- .../Configuration/ConfigurationService.swift | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift index c3ed9b0a7..fbbb55d39 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -8,16 +8,35 @@ import Foundation /** - A service class to fetch configuration settings + A service responsible for fetching configuration settings. + + This service implements the `ConfigurationServiceProtocol` and provides methods to retrieve configuration data from a specified API domain. */ public final class ConfigurationService: ConfigurationServiceProtocol { + /** + Fetches configuration settings. + + - Parameter completion: A closure to be called upon completion of the fetch operation. The closure takes a `CompletionResult` as its parameter. + + This method initiates the process of fetching configuration settings by utilizing the provided session manager to handle the network request. + */ public func fetchConfigurations(completion: @escaping CompletionResult) { self.fetchConfigurations(resourceHandler: sessionManager.data, completion: completion) } + /// The session manager responsible for handling network requests. let sessionManager: SessionManagerProtocol + + /// The API domain to be used for fetching configurations. public var apiDomain: APIDomain + /** + Initializes a new instance of `ConfigurationService`. + + - Parameters: + - sessionManager: An object conforming to `SessionManagerProtocol` responsible for managing network sessions. + - apiDomain: The domain of the API to fetch configurations from. Defaults to `.default`. + */ init(sessionManager: SessionManagerProtocol, apiDomain: APIDomain = .default) { self.sessionManager = sessionManager self.apiDomain = apiDomain @@ -25,6 +44,15 @@ public final class ConfigurationService: ConfigurationServiceProtocol { } extension ConfigurationService { + /** + A helper method to fetch configurations using a resource handler. + + - Parameters: + - resourceHandler: A handler responsible for processing the API resource data. + - completion: A closure to be called upon completion of the fetch operation. The closure takes a `CompletionResult` as its parameter. + + This method constructs an `APIResource` object with the required parameters and utilizes the resource handler to perform the network request. The result is then passed to the completion handler. + */ func fetchConfigurations(resourceHandler: ResourceDataHandler>, completion: @escaping CompletionResult) { let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) From ed082b3980b4d9805bb023ec213efc047f6b7a5b Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 15:15:02 +0200 Subject: [PATCH 40/54] refactoring(GiniBankAPILibrary): refactor GiniBankAPI init to multiline PP-352 --- .../GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index a83853145..b3b6b14ff 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -15,7 +15,9 @@ public final class GiniBankAPI { private let configService: ConfigurationServiceProtocol? static var logLevel: LogLevel = .none - init(documentService: T, paymentService: PaymentService?, configurationService: ConfigurationServiceProtocol?) { + init(documentService: T, + paymentService: PaymentService?, + configurationService: ConfigurationServiceProtocol?) { self.docService = documentService self.payService = paymentService self.configService = configurationService From 5c880ad83000d17e6e4ce2ffcab595bca3804559 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 15:16:32 +0200 Subject: [PATCH 41/54] fix(GiniBankSDK): return correct method for screenCoordinator for custom networking PP-352 --- .../GiniBankSDK/Core/Networking/GiniBank+Networking.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift index 6190371c4..c41f79c85 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift @@ -79,7 +79,7 @@ extension GiniBank { captureNetworkService: networkingService, configurationService: configurationService) AnalyticsManager.firstSDKOpen = true - return screenCoordinator.start(withDocuments: importedDocuments) + return screenCoordinator.startSDK(withDocuments: importedDocuments) } public class func removeStoredCredentials(for client: Client) throws { From 27b5f3203dee0bb360141d93ed1b0ebb8e81ad7f Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 15:25:37 +0200 Subject: [PATCH 42/54] refactoring(GiniBankSDK): GiniBankNetworkingScreenApiCoordinator: refactor API call completion remove extra comment, remove error, init analytics on main thread PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index c61ee83c7..cddcd1db3 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -216,12 +216,11 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin configurationService?.fetchConfigurations(completion: { result in switch result { case .success(let configuration): - self.initializeAnalytics(with: configuration) - case .failure(let error): + DispatchQueue.main.async { + self.initializeAnalytics(with: configuration) + } + case .failure(_): break - /* There will be no retries if the endpoint fails. - We will not implement any caching mechanism on our side if the request is too slow. - In case of a failure, the UJ analytics will remain disabled for that session. */ } }) return self.start(withDocuments: documents, animated: animated) From 676cb6dd5d15819df85886506562079f051d4465 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 16:21:37 +0200 Subject: [PATCH 43/54] feat(GiniBankSDK): GiniBankNetworkingScreenApiCoordinator: add documentation for startSDK PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index cddcd1db3..4b5fe79b2 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -212,6 +212,12 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin self.resultsDelegate?.giniCaptureDidEnterManually() } + /** + This method first attempts to fetch configuration settings using the `configurationService`. + If the configurations are successfully fetched, it initializes the analytics with the fetched configuration + on the main thread. Regardless of the result of fetching configurations, it then proceeds to start the + SDK with the provided documents. + */ public func startSDK(withDocuments documents: [GiniCaptureDocument]?, animated: Bool = false) -> UIViewController { configurationService?.fetchConfigurations(completion: { result in switch result { From f08d07b4004b7ade8ae76907a6894b9630eef050 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 16:35:10 +0200 Subject: [PATCH 44/54] refactoring(GiniCaptureSDK): remove firstSDKOpen flag from AnalyticsManager PP-352 --- .../GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift index 8afd1799b..2f6699943 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Core/Tracking/AnalyticsManager.swift @@ -12,7 +12,6 @@ public class AnalyticsManager { private static var mixpanelInstance: MixpanelInstance? private static var userProperties: [AnalyticsUserProperty: AnalyticsPropertyValue] = [:] private static var superProperties: [AnalyticsSuperProperty: AnalyticsPropertyValue] = [:] - public static var firstSDKOpen: Bool = false public static func initializeAnalytics(with configuration: AnalyticsConfiguration) { guard configuration.userJourneyAnalyticsEnabled, @@ -25,10 +24,7 @@ public class AnalyticsManager { registerSuperProperties(superProperties) trackUserProperties(userProperties) trackAccessibilityUserPropertiesAtInitialization() - if firstSDKOpen { - firstSDKOpen = false - AnalyticsManager.track(event: .sdkOpened, screenName: nil) - } + AnalyticsManager.track(event: .sdkOpened, screenName: nil) } private static func initializeMixpanel(with deviceID: String, token: String?) { From 2921aceb4925bd715b2e3ded9b1b31d52517fd0f Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Thu, 13 Jun 2024 16:35:49 +0200 Subject: [PATCH 45/54] refactoring(GiniBankSDK): GiniBank+Networking: remove firstSDKOpen flag PP-352 --- .../GiniBankSDK/Core/Networking/GiniBank+Networking.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift index c41f79c85..a1ac6c3e3 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift @@ -43,7 +43,6 @@ extension GiniBank { api: api, userApi: userApi, trackingDelegate: trackingDelegate) - AnalyticsManager.firstSDKOpen = true return screenCoordinator.startSDK(withDocuments: importedDocuments) } @@ -78,7 +77,6 @@ extension GiniBank { trackingDelegate: trackingDelegate, captureNetworkService: networkingService, configurationService: configurationService) - AnalyticsManager.firstSDKOpen = true return screenCoordinator.startSDK(withDocuments: importedDocuments) } From 6e16dcc2370c46cd8b073a46a3ed8bcd1369b8f7 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 08:25:34 +0200 Subject: [PATCH 46/54] refactoring(GiniBankAPILibrary): update documentation for Configuration PP-352 --- .../Documents/Configuration/Configuration.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift index f5f18feb9..c32384e7f 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift @@ -8,9 +8,9 @@ import Foundation /** - A struct representing configuration settings for an application. + A struct representing configuration settings. - This struct holds various configuration options that can be used to customize the behavior and features of the application. + This struct holds various configuration options that can be used to customize the behavior and features. */ public struct Configuration: Decodable { /** From 09aef6389776e51372b96880b2abefaa34fab76f Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:12:25 +0200 Subject: [PATCH 47/54] refactor(GiniBankAPILibrary): rename Configuration - > ClientConfiguration PP-352 --- .../{Configuration.swift => ClientConfiguration.swift} | 4 ++-- .../Documents/Configuration/ConfigurationService.swift | 8 ++++---- .../Configuration/ConfigurationServiceProtocol.swift | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) rename BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/{Configuration.swift => ClientConfiguration.swift} (95%) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift similarity index 95% rename from BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift rename to BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift index c32384e7f..6602fc403 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/Configuration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift @@ -1,5 +1,5 @@ // -// Configuration.swift +// ClientConfiguration.swift // // Copyright © 2024 Gini GmbH. All rights reserved. // @@ -12,7 +12,7 @@ import Foundation This struct holds various configuration options that can be used to customize the behavior and features. */ -public struct Configuration: Decodable { +public struct ClientConfiguration: Decodable { /** Creates a new `Configuration` instance. diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift index fbbb55d39..a944d12e2 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift @@ -20,7 +20,7 @@ public final class ConfigurationService: ConfigurationServiceProtocol { This method initiates the process of fetching configuration settings by utilizing the provided session manager to handle the network request. */ - public func fetchConfigurations(completion: @escaping CompletionResult) { + public func fetchConfigurations(completion: @escaping CompletionResult) { self.fetchConfigurations(resourceHandler: sessionManager.data, completion: completion) } @@ -53,9 +53,9 @@ extension ConfigurationService { This method constructs an `APIResource` object with the required parameters and utilizes the resource handler to perform the network request. The result is then passed to the completion handler. */ - func fetchConfigurations(resourceHandler: ResourceDataHandler>, - completion: @escaping CompletionResult) { - let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) + func fetchConfigurations(resourceHandler: ResourceDataHandler>, + completion: @escaping CompletionResult) { + let resource = APIResource(method: .configurations, apiDomain: apiDomain, httpMethod: .get) resourceHandler(resource, { result in switch result { diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift index 2ed4f15f1..1d4d822fc 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift @@ -16,7 +16,7 @@ public protocol ConfigurationServiceProtocol: AnyObject { - parameter completion: A closure that handles the result of the configuration fetch operation. */ - func fetchConfigurations(completion: @escaping CompletionResult) + func fetchConfigurations(completion: @escaping CompletionResult) } extension ConfigurationServiceProtocol { @@ -26,8 +26,8 @@ extension ConfigurationServiceProtocol { - parameter resourceHandler: The handler that processes the API resource data. - parameter completion: A closure that handles the result of the configuration fetch operation. */ - func fetchConfigurations(resourceHandler: ResourceDataHandler>, - completion: @escaping CompletionResult) { + func fetchConfigurations(resourceHandler: ResourceDataHandler>, + completion: @escaping CompletionResult) { // Default implementation is empty } } From 23c4bf9a96615c144087e6dbdb109ac84c253c85 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:12:41 +0200 Subject: [PATCH 48/54] refactor(GiniBankSDK): rename Configuration - > ClientConfiguration PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 4b5fe79b2..5d50ea7f6 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -232,7 +232,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin return self.start(withDocuments: documents, animated: animated) } - private func initializeAnalytics(with configuration: Configuration) { + private func initializeAnalytics(with configuration: ClientConfiguration) { let analyticsConfiguration = AnalyticsConfiguration(clientID: configuration.clientID, userJourneyAnalyticsEnabled: configuration.userJourneyAnalyticsEnabled, mixpanelToken: configuration.mixpanelToken, From c43c580b74222a8a5db22b7e86a8e8307f5e61f6 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:17:21 +0200 Subject: [PATCH 49/54] refactor(GiniBankAPILibrary): rename ConfigurationService - > ClientConfigurationService PP-352 --- ...rationService.swift => ClientConfigurationService.swift} | 6 +++--- .../GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/{ConfigurationService.swift => ClientConfigurationService.swift} (94%) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift similarity index 94% rename from BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift rename to BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift index a944d12e2..59addc842 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift @@ -1,5 +1,5 @@ // -// ConfigurationService.swift +// ClientConfigurationService.swift // // Copyright © 2024 Gini GmbH. All rights reserved. // @@ -12,7 +12,7 @@ import Foundation This service implements the `ConfigurationServiceProtocol` and provides methods to retrieve configuration data from a specified API domain. */ -public final class ConfigurationService: ConfigurationServiceProtocol { +public final class ClientConfigurationService: ConfigurationServiceProtocol { /** Fetches configuration settings. @@ -43,7 +43,7 @@ public final class ConfigurationService: ConfigurationServiceProtocol { } } -extension ConfigurationService { +extension ClientConfigurationService { /** A helper method to fetch configurations using a resource handler. diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index b3b6b14ff..49e66c56d 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -113,7 +113,7 @@ extension GiniBankAPI { let sessionManager = createSessionManager() let documentService = DefaultDocumentService(sessionManager: sessionManager, apiDomain: api) let paymentService = PaymentService(sessionManager: sessionManager, apiDomain: api) - let configurationService = ConfigurationService(sessionManager: sessionManager, apiDomain: api) + let configurationService = ClientConfigurationService(sessionManager: sessionManager, apiDomain: api) return GiniBankAPI(documentService: documentService, paymentService: paymentService, From df7de36343653d5b85b7b281f0b97b3fcb087e58 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:35:22 +0200 Subject: [PATCH 50/54] refactor(GiniBankAPILibrary): rename ConfigurationServiceProtocol - > ClientConfigurationServiceProtocol PP-352 --- .../Configuration/ClientConfigurationService.swift | 2 +- ...tocol.swift => ClientConfigurationServiceProtocol.swift} | 6 +++--- .../GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/{ConfigurationServiceProtocol.swift => ClientConfigurationServiceProtocol.swift} (85%) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift index 59addc842..1b379731b 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift @@ -12,7 +12,7 @@ import Foundation This service implements the `ConfigurationServiceProtocol` and provides methods to retrieve configuration data from a specified API domain. */ -public final class ClientConfigurationService: ConfigurationServiceProtocol { +public final class ClientConfigurationService: ClientConfigurationServiceProtocol { /** Fetches configuration settings. diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift similarity index 85% rename from BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift rename to BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift index 1d4d822fc..53969d4f2 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift @@ -1,5 +1,5 @@ // -// ConfigurationServiceProtocol.swift +// ClientConfigurationServiceProtocol.swift // // Copyright © 2024 Gini GmbH. All rights reserved. // @@ -10,7 +10,7 @@ import Foundation /** Protocol for configuration service */ -public protocol ConfigurationServiceProtocol: AnyObject { +public protocol ClientConfigurationServiceProtocol: AnyObject { /** Fetches configurations from the server. @@ -19,7 +19,7 @@ public protocol ConfigurationServiceProtocol: AnyObject { func fetchConfigurations(completion: @escaping CompletionResult) } -extension ConfigurationServiceProtocol { +extension ClientConfigurationServiceProtocol { /** Fetches configurations using the provided resource handler. diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift index 49e66c56d..e1014049f 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Core/GiniBankAPI.swift @@ -12,12 +12,12 @@ public final class GiniBankAPI { private let docService: DocumentService! private let payService: PaymentService? - private let configService: ConfigurationServiceProtocol? + private let configService: ClientConfigurationServiceProtocol? static var logLevel: LogLevel = .none init(documentService: T, paymentService: PaymentService?, - configurationService: ConfigurationServiceProtocol?) { + configurationService: ClientConfigurationServiceProtocol?) { self.docService = documentService self.payService = paymentService self.configService = configurationService @@ -44,7 +44,7 @@ public final class GiniBankAPI { return payService ?? PaymentService(sessionManager: SessionManager(userDomain: .default), apiDomain: .default) } - public func configurationService() -> ConfigurationServiceProtocol? { + public func configurationService() -> ClientConfigurationServiceProtocol? { return configService } From 2b7b9b58c1aa351bdedad37fe0b9562f988ee399 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:35:53 +0200 Subject: [PATCH 51/54] refactor(GiniBankSDK): rename ConfigurationServiceProtocol - > ClientConfigurationServiceProtocol PP-352 --- .../Core/GiniBankNetworkingScreenApiCoordinator.swift | 4 ++-- .../GiniBankSDK/Core/Networking/GiniBank+Networking.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift index 5d50ea7f6..21565dcf7 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/GiniBankNetworkingScreenApiCoordinator.swift @@ -112,7 +112,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin weak var resultsDelegate: GiniCaptureResultsDelegate? let documentService: DocumentServiceProtocol - private var configurationService: ConfigurationServiceProtocol? + private var configurationService: ClientConfigurationServiceProtocol? var giniBankConfiguration = GiniBankConfiguration.shared public init(client: Client, @@ -141,7 +141,7 @@ open class GiniBankNetworkingScreenApiCoordinator: GiniScreenAPICoordinator, Gin documentMetadata: Document.Metadata?, trackingDelegate: GiniCaptureTrackingDelegate?, captureNetworkService: GiniCaptureNetworkService, - configurationService: ConfigurationServiceProtocol?) { + configurationService: ClientConfigurationServiceProtocol?) { documentService = DocumentService(giniCaptureNetworkService: captureNetworkService, metadata: documentMetadata) diff --git a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift index a1ac6c3e3..99435e4ec 100644 --- a/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift +++ b/BankSDK/GiniBankSDK/Sources/GiniBankSDK/Core/Networking/GiniBank+Networking.swift @@ -70,7 +70,7 @@ extension GiniBank { documentMetadata: Document.Metadata? = nil, trackingDelegate: GiniCaptureTrackingDelegate? = nil, networkingService: GiniCaptureNetworkService, - configurationService: ConfigurationServiceProtocol? = nil) -> UIViewController { + configurationService: ClientConfigurationServiceProtocol? = nil) -> UIViewController { let screenCoordinator = GiniBankNetworkingScreenApiCoordinator(resultsDelegate: resultsDelegate, configuration: configuration, documentMetadata: documentMetadata, From 40e70a8916f082c4d9e51f54143e7e79ef491d83 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:36:08 +0200 Subject: [PATCH 52/54] refactor(GiniCaptureSDK): rename ConfigurationServiceProtocol - > ClientConfigurationServiceProtocol PP-352 --- .../Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift index 54a77bce5..f997a917f 100644 --- a/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift +++ b/CaptureSDK/GiniCaptureSDK/Sources/GiniCaptureSDK/Networking/Extensions/GiniCapture+GiniCaptureDelegate.swift @@ -66,7 +66,7 @@ extension GiniCapture { documentMetadata: Document.Metadata? = nil, trackingDelegate: GiniCaptureTrackingDelegate? = nil, networkingService: GiniCaptureNetworkService, - configurationService: ConfigurationServiceProtocol? = nil) -> UIViewController { + configurationService: ClientConfigurationServiceProtocol? = nil) -> UIViewController { GiniCapture.setConfiguration(configuration) let screenCoordinator = GiniNetworkingScreenAPICoordinator(resultsDelegate: resultsDelegate, giniConfiguration: configuration, documentMetadata: documentMetadata, trackingDelegate: trackingDelegate, captureNetworkService: networkingService) From b9d2684ada5b3bc6658cb10334dcdbc4d75c4dc8 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:55:41 +0200 Subject: [PATCH 53/54] refactor(GiniBankAPILibrary): rename Configuration - > ClientConfiguration in docs PP-352 --- .../Documents/Configuration/ClientConfiguration.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift index 6602fc403..e730bb685 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfiguration.swift @@ -14,7 +14,7 @@ import Foundation */ public struct ClientConfiguration: Decodable { /** - Creates a new `Configuration` instance. + Creates a new `ClientConfiguration` instance. - parameter clientID: A unique identifier for the client. - parameter userJourneyAnalyticsEnabled: A flag indicating whether user journey analytics is enabled. From 3722403e09118d87afb37ab484fd8b6f93bee036 Mon Sep 17 00:00:00 2001 From: Gleb Kulik Date: Fri, 14 Jun 2024 15:58:27 +0200 Subject: [PATCH 54/54] refactor(GiniBankAPILibrary): rename in docs for ClientConfigurationServiceProtocol & ClientConfigurationService PP-352 --- .../Documents/Configuration/ClientConfigurationService.swift | 4 ++-- .../Configuration/ClientConfigurationServiceProtocol.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift index 1b379731b..3cd572ef7 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationService.swift @@ -10,7 +10,7 @@ import Foundation /** A service responsible for fetching configuration settings. - This service implements the `ConfigurationServiceProtocol` and provides methods to retrieve configuration data from a specified API domain. + This service implements the `ClientConfigurationServiceProtocol` and provides methods to retrieve configuration data from a specified API domain. */ public final class ClientConfigurationService: ClientConfigurationServiceProtocol { /** @@ -31,7 +31,7 @@ public final class ClientConfigurationService: ClientConfigurationServiceProtoco public var apiDomain: APIDomain /** - Initializes a new instance of `ConfigurationService`. + Initializes a new instance of `ClientConfigurationService`. - Parameters: - sessionManager: An object conforming to `SessionManagerProtocol` responsible for managing network sessions. diff --git a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift index 53969d4f2..42d9dbebf 100644 --- a/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift +++ b/BankAPILibrary/GiniBankAPILibrary/Sources/GiniBankAPILibrary/Documents/Configuration/ClientConfigurationServiceProtocol.swift @@ -8,7 +8,7 @@ import Foundation /** - Protocol for configuration service + Protocol for client configuration service */ public protocol ClientConfigurationServiceProtocol: AnyObject { /**