From 383ed5dc02b71766d4fb6ad65974a0dc7b739ba5 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 10:20:05 +0200 Subject: [PATCH 01/10] Rename configuration --- ...ration.swift => ProcessOutConfiguration.swift} | 15 +++++++++------ .../ProcessOut/Sources/Api/ProcessOutApi.swift | 6 +++--- .../Sources/Api/ProcessOutApiType.swift | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) rename Sources/ProcessOut/Sources/Api/Models/{ProcessOutApiConfiguration.swift => ProcessOutConfiguration.swift} (81%) diff --git a/Sources/ProcessOut/Sources/Api/Models/ProcessOutApiConfiguration.swift b/Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift similarity index 81% rename from Sources/ProcessOut/Sources/Api/Models/ProcessOutApiConfiguration.swift rename to Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift index c553a27b7..2e0ddd61d 100644 --- a/Sources/ProcessOut/Sources/Api/Models/ProcessOutApiConfiguration.swift +++ b/Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift @@ -1,5 +1,5 @@ // -// ProcessOutApiConfiguration.swift +// ProcessOutConfiguration.swift // ProcessOut // // Created by Andrii Vysotskyi on 10.10.2022. @@ -7,10 +7,13 @@ import Foundation +@available(*, deprecated, renamed: "ProcessOutConfiguration") +public typealias ProcessOutApiConfiguration = ProcessOutConfiguration + /// Defines configuration parameters that are used to create API singleton. In order to create instance -/// of this structure one should use ``ProcessOutApiConfiguration/production(projectId:isDebug:)`` +/// of this structure one should use ``ProcessOutConfiguration/production(projectId:isDebug:)`` /// method. -public struct ProcessOutApiConfiguration { +public struct ProcessOutConfiguration { /// Project id. public let projectId: String @@ -33,7 +36,7 @@ public struct ProcessOutApiConfiguration { let checkoutBaseUrl: URL } -extension ProcessOutApiConfiguration { +extension ProcessOutConfiguration { /// Creates production configuration. public static func production(projectId: String, isDebug: Bool = false) -> Self { @@ -41,7 +44,7 @@ extension ProcessOutApiConfiguration { let apiBaseUrl = URL(string: "https://api.processout.com")! let checkoutBaseUrl = URL(string: "https://checkout.processout.com")! // swiftlint:enable force_unwrapping - return ProcessOutApiConfiguration( + return ProcessOutConfiguration( projectId: projectId, isDebug: isDebug, privateKey: nil, @@ -53,7 +56,7 @@ extension ProcessOutApiConfiguration { /// Creates test configuration. @_spi(PO) public static func test(projectId: String, privateKey: String?, apiBaseUrl: URL, checkoutBaseUrl: URL) -> Self { - ProcessOutApiConfiguration( + ProcessOutConfiguration( projectId: projectId, isDebug: true, privateKey: privateKey, diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutApi.swift b/Sources/ProcessOut/Sources/Api/ProcessOutApi.swift index 4ac79d89c..e85515791 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutApi.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOutApi.swift @@ -17,7 +17,7 @@ public enum ProcessOutApi { /// Configures ``ProcessOutApi/shared`` instance. /// - NOTE: Method must be called from main thread. Only the first invocation takes effect, all /// subsequent calls to this method are ignored. - public static func configure(configuration: ProcessOutApiConfiguration) { + public static func configure(configuration: ProcessOutConfiguration) { assert(Thread.isMainThread, "Method must be called only from main thread") if let shared { shared.logger.info("ProcessOutApi can be configured only once, ignored") @@ -30,13 +30,13 @@ public enum ProcessOutApi { private final class SharedProcessOutApi: ProcessOutApiType { - init(configuration: ProcessOutApiConfiguration) { + init(configuration: ProcessOutConfiguration) { self.configuration = configuration } // MARK: - ProcessOutApiType - let configuration: ProcessOutApiConfiguration + let configuration: ProcessOutConfiguration private(set) lazy var gatewayConfigurations: POGatewayConfigurationsRepository = { HttpGatewayConfigurationsRepository(connector: httpConnector, failureMapper: failureMapper) diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift b/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift index 5e48b7442..a833e7e3c 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift @@ -11,7 +11,7 @@ import Foundation public protocol ProcessOutApiType { /// Current configuration. - var configuration: ProcessOutApiConfiguration { get } + var configuration: ProcessOutConfiguration { get } /// Returns gateway configurations repository. var gatewayConfigurations: POGatewayConfigurationsRepository { get } From fe5a9786b4bc18fb255543d56c900135379a0a45 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 10:29:35 +0200 Subject: [PATCH 02/10] Rename process out file --- .../{ProcessOutApi.swift => ProcessOut.swift} | 11 +++++++---- .../Sources/Legacy/ProcessOutLegacyApi.swift | 8 ++++---- .../Sources/Legacy/ProcessOutWebView.swift | 2 +- .../PO3DSRedirectViewControllerBuilder.swift | 2 +- ...ativePaymentMethodViewControllerBuilder.swift | 2 +- ...ativePaymentMethodViewControllerBuilder.swift | 2 +- ...NativeAlternativePaymentMethodViewModel.swift | 16 ++++++++-------- 7 files changed, 23 insertions(+), 20 deletions(-) rename Sources/ProcessOut/Sources/Api/{ProcessOutApi.swift => ProcessOut.swift} (94%) diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutApi.swift b/Sources/ProcessOut/Sources/Api/ProcessOut.swift similarity index 94% rename from Sources/ProcessOut/Sources/Api/ProcessOutApi.swift rename to Sources/ProcessOut/Sources/Api/ProcessOut.swift index e85515791..79f0ae90b 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutApi.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOut.swift @@ -1,5 +1,5 @@ // -// ProcessOutApi.swift +// ProcessOut.swift // ProcessOut // // Created by Andrii Vysotskyi on 07.10.2022. @@ -8,8 +8,11 @@ import Foundation import UIKit +@available(*, deprecated, renamed: "ProcessOut") +public typealias ProcessOutApi = ProcessOut + /// Provides access to shared api instance and a way to configure it. -public enum ProcessOutApi { +public enum ProcessOut { /// Shared instance. public private(set) static var shared: ProcessOutApiType! // swiftlint:disable:this implicitly_unwrapped_optional @@ -20,11 +23,11 @@ public enum ProcessOutApi { public static func configure(configuration: ProcessOutConfiguration) { assert(Thread.isMainThread, "Method must be called only from main thread") if let shared { - shared.logger.info("ProcessOutApi can be configured only once, ignored") + shared.logger.info("ProcessOut can be configured only once, ignored") return } shared = SharedProcessOutApi(configuration: configuration) - shared.logger.debug("Did complete ProcessOutApi configuration") + shared.logger.debug("Did complete ProcessOut configuration") } } diff --git a/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift b/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift index fe080c2a2..0bf209d49 100644 --- a/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift +++ b/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift @@ -79,21 +79,21 @@ public final class ProcessOutLegacyApi { } private static var ApiUrl: String { - ProcessOutApi.shared.configuration.apiBaseUrl.absoluteString + ProcessOut.shared.configuration.apiBaseUrl.absoluteString } internal static var CheckoutUrl: String { - ProcessOutApi.shared.configuration.checkoutBaseUrl.absoluteString + ProcessOut.shared.configuration.checkoutBaseUrl.absoluteString } internal static var ProjectId: String { - ProcessOutApi.shared.configuration.projectId + ProcessOut.shared.configuration.projectId } internal static let threeDS2ChallengeSuccess: String = "gway_req_eyJib2R5Ijoie1widHJhbnNTdGF0dXNcIjpcIllcIn0ifQ==" internal static let threeDS2ChallengeError: String = "gway_req_eyJib2R5Ijoie1widHJhbnNTdGF0dXNcIjpcIk5cIn0ifQ==" - internal static let requestManager = ProcessOutRequestManager(apiUrl: ApiUrl, apiVersion: type(of: ProcessOutApi.shared).version, defaultUserAgent: defaultUserAgent) + internal static let requestManager = ProcessOutRequestManager(apiUrl: ApiUrl, apiVersion: type(of: ProcessOut.shared).version, defaultUserAgent: defaultUserAgent) // Getting the device user agent private static let defaultUserAgent = "iOS/" + UIDevice.current.systemVersion diff --git a/Sources/ProcessOut/Sources/Legacy/ProcessOutWebView.swift b/Sources/ProcessOut/Sources/Legacy/ProcessOutWebView.swift index c83861993..d1abef5e6 100644 --- a/Sources/ProcessOut/Sources/Legacy/ProcessOutWebView.swift +++ b/Sources/ProcessOut/Sources/Legacy/ProcessOutWebView.swift @@ -26,7 +26,7 @@ public class ProcessOutWebView: WKWebView, WKNavigationDelegate, WKUIDelegate { self.onResult = onResult self.onAuthenticationError = onAuthenticationError super.init(frame: frame, configuration: config) - self.customUserAgent = "ProcessOut iOS-Webview/" + type(of: ProcessOutApi.shared).version + self.customUserAgent = "ProcessOut iOS-Webview/" + type(of: ProcessOut.shared).version self.navigationDelegate = self self.uiDelegate = self } diff --git a/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift index 88e6749bb..c1dbad286 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift @@ -28,7 +28,7 @@ public final class PO3DSRedirectViewControllerBuilder { /// /// - NOTE: Caller should dismiss view controller after completion is called. public func build() -> UIViewController { - let api: ProcessOutApiType = ProcessOutApi.shared + let api: ProcessOutApiType = ProcessOut.shared let configuration = WebViewControllerConfiguration( returnUrls: [api.configuration.checkoutBaseUrl], version: type(of: api).version, diff --git a/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift index c589c90bf..1f380edb2 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift @@ -25,7 +25,7 @@ public final class POAlternativePaymentMethodViewControllerBuilder { /// Creates and returns view controller that is capable of handling alternative payment request. public func build() -> UIViewController { - let api: ProcessOutApiType = ProcessOutApi.shared + let api: ProcessOutApiType = ProcessOut.shared let delegate = WebViewControllerDelegateAlternativePaymentMethod( alternativePaymentMethodsService: api.alternativePaymentMethods, request: request, diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift index f36bb9dd8..3f3544b43 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift @@ -49,7 +49,7 @@ public final class PONativeAlternativePaymentMethodViewControllerBuilder { // sw /// /// - NOTE: Caller should dismiss view controller after completion is called. public func build() -> UIViewController { - let api: ProcessOutApiType = ProcessOutApi.shared + let api: ProcessOutApiType = ProcessOut.shared let interactor = DefaultNativeAlternativePaymentMethodInteractor( invoicesService: api.invoices, imagesRepository: api.images, diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/DefaultNativeAlternativePaymentMethodViewModel.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/DefaultNativeAlternativePaymentMethodViewModel.swift index df911110d..0924831ef 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/DefaultNativeAlternativePaymentMethodViewModel.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/DefaultNativeAlternativePaymentMethodViewModel.swift @@ -33,7 +33,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: // MARK: - Private Nested Types private typealias InteractorState = NativeAlternativePaymentMethodInteractorState - private typealias Strings = ProcessOut.Strings.NativeAlternativePayment + private typealias Text = Strings.NativeAlternativePayment private enum Constants { static let captureSuccessCompletionDelay: TimeInterval = 3 @@ -116,7 +116,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: return viewModel } let state = State.Started( - title: configuration.title ?? Strings.title(startedState.gatewayDisplayName), + title: configuration.title ?? Text.title(startedState.gatewayDisplayName), parameters: parameters, isSubmitting: isSubmitting, primaryAction: submitAction(startedState: startedState, isSubmitting: isSubmitting), @@ -150,7 +150,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: } ) let submittedState = State.Submitted( - message: Strings.Success.message, + message: Text.Success.message, logoImage: capturedState.gatewayLogo, image: Asset.Images.success.image, isCaptured: true @@ -166,9 +166,9 @@ final class DefaultNativeAlternativePaymentMethodViewModel: case .numeric, .text, .singleSelect: return nil case .email: - return Strings.Email.placeholder + return Text.Email.placeholder case .phone: - return Strings.Phone.placeholder + return Text.Phone.placeholder } } @@ -180,9 +180,9 @@ final class DefaultNativeAlternativePaymentMethodViewModel: priceFormatter.currencyCode = startedState.currencyCode // swiftlint:disable:next legacy_objc_type if let formattedAmount = priceFormatter.string(from: startedState.amount as NSDecimalNumber) { - title = Strings.SubmitButton.title(formattedAmount) + title = Text.SubmitButton.title(formattedAmount) } else { - title = Strings.SubmitButton.defaultTitle + title = Text.SubmitButton.defaultTitle } } let action = State.Action( @@ -201,7 +201,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: return nil } let action = State.Action( - title: title ?? Strings.CancelButton.title, + title: title ?? Text.CancelButton.title, isEnabled: isEnabled, isExecuting: false, handler: { [weak self] in From 56a34dfd1668d442e7ca88dd5e7cb884b716d5c8 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 10:29:47 +0200 Subject: [PATCH 03/10] Update example application --- Example/Example/Sources/Application/AppDelegate.swift | 6 +++--- .../Methods/AlternativePaymentMethodsBuilder.swift | 4 ++-- .../Sources/UI/Modules/CardPayment/CardPaymentBuilder.swift | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Example/Example/Sources/Application/AppDelegate.swift b/Example/Example/Sources/Application/AppDelegate.swift index 398836be4..ea0f25291 100644 --- a/Example/Example/Sources/Application/AppDelegate.swift +++ b/Example/Example/Sources/Application/AppDelegate.swift @@ -6,7 +6,7 @@ // import UIKit -@_spi(PO) import ProcessOut +@_spi(PO) import ProcessOutKit @main final class AppDelegate: UIResponder, UIApplicationDelegate { @@ -32,7 +32,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { // MARK: - Private Methods private func configureProcessOut() { - let configuration = ProcessOutApiConfiguration.test( + let configuration = ProcessOutConfiguration.test( projectId: Constants.projectId, privateKey: Constants.projectPrivateKey, // swiftlint:disable force_unwrapping @@ -40,6 +40,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { checkoutBaseUrl: URL(string: Constants.checkoutBaseUrl)! // swiftlint:enable force_unwrapping ) - ProcessOutApi.configure(configuration: configuration) + ProcessOut.configure(configuration: configuration) } } diff --git a/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/AlternativePaymentMethodsBuilder.swift b/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/AlternativePaymentMethodsBuilder.swift index 1d88a4a2a..27adb2590 100644 --- a/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/AlternativePaymentMethodsBuilder.swift +++ b/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/AlternativePaymentMethodsBuilder.swift @@ -16,8 +16,8 @@ final class AlternativePaymentMethodsBuilder { func build() -> UIViewController { let interactor = AlternativePaymentMethodsInteractor( - gatewayConfigurationsRepository: ProcessOutApi.shared.gatewayConfigurations, - invoicesService: ProcessOutApi.shared.invoices, + gatewayConfigurationsRepository: ProcessOut.shared.gatewayConfigurations, + invoicesService: ProcessOut.shared.invoices, filter: filter ) let router = AlternativePaymentMethodsRouter() diff --git a/Example/Example/Sources/UI/Modules/CardPayment/CardPaymentBuilder.swift b/Example/Example/Sources/UI/Modules/CardPayment/CardPaymentBuilder.swift index bb1836d62..960716e67 100644 --- a/Example/Example/Sources/UI/Modules/CardPayment/CardPaymentBuilder.swift +++ b/Example/Example/Sources/UI/Modules/CardPayment/CardPaymentBuilder.swift @@ -15,8 +15,8 @@ final class CardPaymentBuilder { let router = CardPaymentRouter() let viewModel = CardPaymentViewModel( router: router, - invoicesService: ProcessOutApi.shared.invoices, - cardsService: ProcessOutApi.shared.cards, + invoicesService: ProcessOut.shared.invoices, + cardsService: ProcessOut.shared.cards, threeDSService: threeDSService ) let viewController = CardPaymentViewController(viewModel: viewModel) From 89003d87b34c85f4bd6c731fb2e525f70259c1c3 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 10:52:25 +0200 Subject: [PATCH 04/10] Rename api type --- Scripts/UpdateVersion.sh | 6 +++--- Sources/ProcessOut/Sources/Api/ProcessOut.swift | 6 +++--- ...cessOutApiType.swift => ProcessOutType.swift} | 16 ++++++++++++++-- ...pe+Version.swift => ProcessOut+Version.swift} | 4 ++-- .../PO3DSRedirectViewControllerBuilder.swift | 4 ++-- ...ativePaymentMethodViewControllerBuilder.swift | 4 ++-- ...ativePaymentMethodViewControllerBuilder.swift | 2 +- 7 files changed, 27 insertions(+), 15 deletions(-) rename Sources/ProcessOut/Sources/Api/{ProcessOutApiType.swift => ProcessOutType.swift} (69%) rename Sources/ProcessOut/Sources/Generated/{ProcessOutApiType+Version.swift => ProcessOut+Version.swift} (77%) diff --git a/Scripts/UpdateVersion.sh b/Scripts/UpdateVersion.sh index 29e8f330f..28b9ba089 100755 --- a/Scripts/UpdateVersion.sh +++ b/Scripts/UpdateVersion.sh @@ -31,15 +31,15 @@ fi echo $VERSION > Version.resolved # Generates ProcessOut+Version.swift -cat > "Sources/ProcessOut/Sources/Generated/ProcessOutApiType+Version.swift" <<- EOF +cat > "Sources/ProcessOut/Sources/Generated/ProcessOut+Version.swift" <<- EOF // -// ProcessOutApiType+Version.swift +// ProcessOut+Version.swift // // This file was generated by UpdateVersion.sh // Do not edit this file directly. // -extension ProcessOutApiType { +extension ProcessOut { /// The current version of this library, value is "${VERSION}". public static var version: String { diff --git a/Sources/ProcessOut/Sources/Api/ProcessOut.swift b/Sources/ProcessOut/Sources/Api/ProcessOut.swift index 79f0ae90b..394ce9302 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOut.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOut.swift @@ -15,7 +15,7 @@ public typealias ProcessOutApi = ProcessOut public enum ProcessOut { /// Shared instance. - public private(set) static var shared: ProcessOutApiType! // swiftlint:disable:this implicitly_unwrapped_optional + public private(set) static var shared: ProcessOutType! // swiftlint:disable:this implicitly_unwrapped_optional /// Configures ``ProcessOutApi/shared`` instance. /// - NOTE: Method must be called from main thread. Only the first invocation takes effect, all @@ -31,7 +31,7 @@ public enum ProcessOut { } } -private final class SharedProcessOutApi: ProcessOutApiType { +private final class SharedProcessOutApi: ProcessOutType { init(configuration: ProcessOutConfiguration) { self.configuration = configuration @@ -98,7 +98,7 @@ private final class SharedProcessOutApi: ProcessOutApiType { baseUrl: configuration.apiBaseUrl, projectId: configuration.projectId, privateKey: configuration.privateKey, - version: Self.version + version: ProcessOut.version ) let connector = ProcessOutHttpConnectorBuilder() .with(configuration: connectorConfiguration) diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift b/Sources/ProcessOut/Sources/Api/ProcessOutType.swift similarity index 69% rename from Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift rename to Sources/ProcessOut/Sources/Api/ProcessOutType.swift index a833e7e3c..b5327e867 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOutType.swift @@ -1,5 +1,5 @@ // -// ProcessOutApiType.swift +// ProcessOutType.swift // ProcessOut // // Created by Andrii Vysotskyi on 10.10.2022. @@ -7,8 +7,11 @@ import Foundation +@available(*, deprecated, renamed: "ProcessOutType") +typealias ProcessOutApiType = ProcessOutType + // todo(andrii-vysotskyi): remove suffix before releasing version 4.0.0 -public protocol ProcessOutApiType { +public protocol ProcessOutType { /// Current configuration. var configuration: ProcessOutConfiguration { get } @@ -34,3 +37,12 @@ public protocol ProcessOutApiType { /// Logger with application category. var logger: POLogger { get } } + +extension ProcessOutType { + + /// The current version of this library, value is "3.5.0". + @available(*, deprecated, message: "Use ProcessOut.version instead") + public static var version: String { + ProcessOut.version + } +} diff --git a/Sources/ProcessOut/Sources/Generated/ProcessOutApiType+Version.swift b/Sources/ProcessOut/Sources/Generated/ProcessOut+Version.swift similarity index 77% rename from Sources/ProcessOut/Sources/Generated/ProcessOutApiType+Version.swift rename to Sources/ProcessOut/Sources/Generated/ProcessOut+Version.swift index 06958bef3..255946472 100644 --- a/Sources/ProcessOut/Sources/Generated/ProcessOutApiType+Version.swift +++ b/Sources/ProcessOut/Sources/Generated/ProcessOut+Version.swift @@ -1,11 +1,11 @@ // -// ProcessOutApiType+Version.swift +// ProcessOut+Version.swift // // This file was generated by UpdateVersion.sh // Do not edit this file directly. // -extension ProcessOutApiType { +extension ProcessOut { /// The current version of this library, value is "3.5.0". public static var version: String { diff --git a/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift index c1dbad286..821029a56 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift @@ -28,10 +28,10 @@ public final class PO3DSRedirectViewControllerBuilder { /// /// - NOTE: Caller should dismiss view controller after completion is called. public func build() -> UIViewController { - let api: ProcessOutApiType = ProcessOut.shared + let api: ProcessOutType = ProcessOut.shared let configuration = WebViewControllerConfiguration( returnUrls: [api.configuration.checkoutBaseUrl], - version: type(of: api).version, + version: ProcessOut.version, timeout: redirect.timeout ) let viewController = WebViewController( diff --git a/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift index 1f380edb2..4c8338848 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift @@ -25,7 +25,7 @@ public final class POAlternativePaymentMethodViewControllerBuilder { /// Creates and returns view controller that is capable of handling alternative payment request. public func build() -> UIViewController { - let api: ProcessOutApiType = ProcessOut.shared + let api: ProcessOutType = ProcessOut.shared let delegate = WebViewControllerDelegateAlternativePaymentMethod( alternativePaymentMethodsService: api.alternativePaymentMethods, request: request, @@ -35,7 +35,7 @@ public final class POAlternativePaymentMethodViewControllerBuilder { ) let configuration = WebViewControllerConfiguration( returnUrls: [api.configuration.checkoutBaseUrl], - version: type(of: api).version, + version: ProcessOut.version, timeout: nil ) let viewController = WebViewController( diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift index 3f3544b43..d46ee8181 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift @@ -49,7 +49,7 @@ public final class PONativeAlternativePaymentMethodViewControllerBuilder { // sw /// /// - NOTE: Caller should dismiss view controller after completion is called. public func build() -> UIViewController { - let api: ProcessOutApiType = ProcessOut.shared + let api: ProcessOutType = ProcessOut.shared let interactor = DefaultNativeAlternativePaymentMethodInteractor( invoicesService: api.invoices, imagesRepository: api.images, From 2599488c42f8e42313e18bbce981bb38b8d45c00 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 10:54:03 +0200 Subject: [PATCH 05/10] Fix example build issue --- Example/Example/Sources/Application/AppDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Example/Sources/Application/AppDelegate.swift b/Example/Example/Sources/Application/AppDelegate.swift index ea0f25291..dfb448129 100644 --- a/Example/Example/Sources/Application/AppDelegate.swift +++ b/Example/Example/Sources/Application/AppDelegate.swift @@ -6,7 +6,7 @@ // import UIKit -@_spi(PO) import ProcessOutKit +@_spi(PO) import ProcessOut @main final class AppDelegate: UIResponder, UIApplicationDelegate { From 1aea68c640eff27208b4f7b1a08ddef9f852c841 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 11:07:25 +0200 Subject: [PATCH 06/10] Update settings --- Package.swift | 5 ++++- ProcessOut.podspec | 1 + project.yml | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index fd29b542a..7026df2db 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,10 @@ let package = Package( dependencies: [], // Having DocC in sources may cause build failures so excluded until issue is resolved by Apple. See // https://forums.swift.org/t/xcode-and-swift-package-manager/44704 for details. - exclude: ["ProcessOut.docc"] + exclude: ["ProcessOut.docc"], + swiftSettings: [ + .unsafeFlags(["-Xfrontend", "-module-interface-preserve-types-as-written"]) + ] ) ] ) diff --git a/ProcessOut.podspec b/ProcessOut.podspec index 66ad9a402..a4bf0512d 100644 --- a/ProcessOut.podspec +++ b/ProcessOut.podspec @@ -12,4 +12,5 @@ Pod::Spec.new do |s| s.ios.deployment_target = '12.0' s.ios.resource_bundle = { 'ProcessOut' => 'Sources/ProcessOut/Resources/**/*' } s.source_files = 'Sources/ProcessOut/**/*.swift' + s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-Xfrontend -module-interface-preserve-types-as-written' } end diff --git a/project.yml b/project.yml index ed3d59af8..90d2b315f 100644 --- a/project.yml +++ b/project.yml @@ -21,6 +21,7 @@ targets: CURRENT_PROJECT_VERSION: ${CURRENT_VERSION} SKIP_INSTALL: NO BUILD_LIBRARY_FOR_DISTRIBUTION: YES + OTHER_SWIFT_FLAGS: "-Xfrontend -module-interface-preserve-types-as-written" preBuildScripts: - path: Scripts/Lint.sh name: Swiftlint From 51a5c1459ce34fd5405f9e50bf8eab08b3417ced Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Wed, 10 May 2023 11:16:26 +0200 Subject: [PATCH 07/10] Update documentation --- .../ProcessOut.docc/MigratingFromProcessOut2.md | 2 +- Sources/ProcessOut/ProcessOut.docc/ProcessOut.md | 10 +++++----- Sources/ProcessOut/Sources/Api/ProcessOut.swift | 8 ++++---- Sources/ProcessOut/Sources/Api/ProcessOutType.swift | 2 +- Sources/ProcessOut/Sources/Legacy/APMTokenReturn.swift | 2 +- .../Sources/Legacy/AuthorizationRequest.swift | 2 +- .../Sources/Legacy/GatewayConfiguration.swift | 2 +- .../Sources/Legacy/ProcessOutLegacyApi.swift | 10 +++++----- Sources/ProcessOut/Sources/Legacy/TokenRequest.swift | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Sources/ProcessOut/ProcessOut.docc/MigratingFromProcessOut2.md b/Sources/ProcessOut/ProcessOut.docc/MigratingFromProcessOut2.md index bb7e010aa..00a757151 100644 --- a/Sources/ProcessOut/ProcessOut.docc/MigratingFromProcessOut2.md +++ b/Sources/ProcessOut/ProcessOut.docc/MigratingFromProcessOut2.md @@ -6,7 +6,7 @@ Version 3 is not backward compatible with previous versions, although migration straightforward. There are some changes that should be addressed when migrating: 1. Instead of `ProcessOut.Setup(projectId: String)` there is new method that should be used to configure -SDK ``ProcessOutApi/configure(configuration:)``. +SDK ``ProcessOut/configure(configuration:)``. 2. `ProcessOut` was renamed to ``ProcessOutLegacyApi`` to avoid shadowing module name as it may cause issues. For more information, see [Swift Issue](https://github.com/apple/swift/issues/56573). diff --git a/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md b/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md index 9c9c84e0b..28ef9f14f 100644 --- a/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md +++ b/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md @@ -7,8 +7,8 @@ Before using ProcessOut SDK make sure to configure it. ```swift import ProcessOut -let configuration = ProcessOutApiConfiguration.production(projectId: "your_project_id") -ProcessOutApi.configure(configuration: configuration) +let configuration = ProcessOutConfiguration.production(projectId: "your_project_id") +ProcessOut.configure(configuration: configuration) ``` ## Topics @@ -17,9 +17,9 @@ ProcessOutApi.configure(configuration: configuration) - - -- ``ProcessOutApi`` -- ``ProcessOutApiConfiguration`` -- ``ProcessOutApiType`` +- ``ProcessOut`` +- ``ProcessOutConfiguration`` +- ``ProcessOutType`` ### Errors diff --git a/Sources/ProcessOut/Sources/Api/ProcessOut.swift b/Sources/ProcessOut/Sources/Api/ProcessOut.swift index 394ce9302..ce3ee0d03 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOut.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOut.swift @@ -17,7 +17,7 @@ public enum ProcessOut { /// Shared instance. public private(set) static var shared: ProcessOutType! // swiftlint:disable:this implicitly_unwrapped_optional - /// Configures ``ProcessOutApi/shared`` instance. + /// Configures ``ProcessOut/shared`` instance. /// - NOTE: Method must be called from main thread. Only the first invocation takes effect, all /// subsequent calls to this method are ignored. public static func configure(configuration: ProcessOutConfiguration) { @@ -26,18 +26,18 @@ public enum ProcessOut { shared.logger.info("ProcessOut can be configured only once, ignored") return } - shared = SharedProcessOutApi(configuration: configuration) + shared = SharedProcessOut(configuration: configuration) shared.logger.debug("Did complete ProcessOut configuration") } } -private final class SharedProcessOutApi: ProcessOutType { +private final class SharedProcessOut: ProcessOutType { init(configuration: ProcessOutConfiguration) { self.configuration = configuration } - // MARK: - ProcessOutApiType + // MARK: - ProcessOutType let configuration: ProcessOutConfiguration diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutType.swift b/Sources/ProcessOut/Sources/Api/ProcessOutType.swift index b5327e867..3f63f0e88 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutType.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOutType.swift @@ -8,7 +8,7 @@ import Foundation @available(*, deprecated, renamed: "ProcessOutType") -typealias ProcessOutApiType = ProcessOutType +public typealias ProcessOutApiType = ProcessOutType // todo(andrii-vysotskyi): remove suffix before releasing version 4.0.0 public protocol ProcessOutType { diff --git a/Sources/ProcessOut/Sources/Legacy/APMTokenReturn.swift b/Sources/ProcessOut/Sources/Legacy/APMTokenReturn.swift index 73db99d23..e288e99be 100644 --- a/Sources/ProcessOut/Sources/Legacy/APMTokenReturn.swift +++ b/Sources/ProcessOut/Sources/Legacy/APMTokenReturn.swift @@ -7,7 +7,7 @@ import Foundation -@available(*, deprecated, message: "Use ProcessOutApi.shared.customerTokens.assignCustomerToken() instead.") +@available(*, deprecated, message: "Use ProcessOut.shared.customerTokens.assignCustomerToken() instead.") public final class APMTokenReturn { public enum APMReturnType { diff --git a/Sources/ProcessOut/Sources/Legacy/AuthorizationRequest.swift b/Sources/ProcessOut/Sources/Legacy/AuthorizationRequest.swift index 57350268c..42cc5e4eb 100644 --- a/Sources/ProcessOut/Sources/Legacy/AuthorizationRequest.swift +++ b/Sources/ProcessOut/Sources/Legacy/AuthorizationRequest.swift @@ -5,7 +5,7 @@ // Created by Jeremy Lejoux on 17/06/2019. // -@available(*, deprecated, message: "Use ProcessOutApi.shared.invoices.authorizeInvoice() instead.") +@available(*, deprecated, message: "Use ProcessOut.shared.invoices.authorizeInvoice() instead.") public final class AuthorizationRequest: Codable { var invoiceID: String = "" diff --git a/Sources/ProcessOut/Sources/Legacy/GatewayConfiguration.swift b/Sources/ProcessOut/Sources/Legacy/GatewayConfiguration.swift index 59ed1f966..46a598c16 100644 --- a/Sources/ProcessOut/Sources/Legacy/GatewayConfiguration.swift +++ b/Sources/ProcessOut/Sources/Legacy/GatewayConfiguration.swift @@ -7,7 +7,7 @@ import Foundation -@available(*, deprecated, message: "Use ProcessOutApi.shared.gatewayConfigurations instead.") +@available(*, deprecated, message: "Use ProcessOut.shared.gatewayConfigurations instead.") public class GatewayConfiguration: Decodable { enum CodingKeys: String, CodingKey { diff --git a/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift b/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift index 0bf209d49..3312b9ff7 100644 --- a/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift +++ b/Sources/ProcessOut/Sources/Legacy/ProcessOutLegacyApi.swift @@ -16,7 +16,7 @@ enum HTTPMethod: String { case connect = "CONNECT" } -@available(*, deprecated, message: "Use ProcessOutApi instead.") +@available(*, deprecated, message: "Use ProcessOut instead.") public final class ProcessOutLegacyApi { public struct Contact { @@ -286,7 +286,7 @@ public final class ProcessOutLegacyApi { /// - Parameters: /// - completion: Completion callback /// - paginationOptions: Pagination options to use - @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOutApi.shared.gatewayConfigurations.all instead.") + @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOut.shared.gatewayConfigurations.all instead.") public static func fetchGatewayConfigurations(filter: GatewayConfigurationsFilter, completion: @escaping ([GatewayConfiguration]?, ProcessOutException?) -> Void, paginationOptions: PaginationOptions? = nil) { let paginationParams = paginationOptions != nil ? "&" + generatePaginationParamsString(paginationOptions: paginationOptions!) : "" @@ -701,7 +701,7 @@ public final class ProcessOutLegacyApi { /// /// - Parameter url: URI from the deep-link app opening /// - Returns: nil if the URL is not a ProcessOut return URL, an APMTokenReturn object otherwise - @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOutApi.shared.alternativePaymentMethods.alternativePaymentMethodResponse instead.") + @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOut.shared.alternativePaymentMethods.alternativePaymentMethodResponse instead.") public static func handleAPMURLCallback(url: URL) -> APMTokenReturn? { // Check for the URL host guard let host = url.host, host == "processout.return" else { @@ -737,7 +737,7 @@ public final class ProcessOutLegacyApi { /// - gateway: The alternative payment method configuration /// - customerId: The customer ID /// - tokenId: The token ID generated on your backend with an empty source - @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOutApi.shared.alternativePaymentMethods.alternativePaymentMethodUrl instead.") + @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOut.shared.alternativePaymentMethods.alternativePaymentMethodUrl instead.") public static func makeAPMToken(gateway: GatewayConfiguration, customerId: String, tokenId: String, additionalData: [String: String] = [:]) { // Generate the redirection URL let checkout = ProcessOutLegacyApi.ProjectId + "/" + customerId + "/" + tokenId + "/redirect/" + gateway.id @@ -755,7 +755,7 @@ public final class ProcessOutLegacyApi { /// - gateway: Gateway to use (previously fetched) /// - invoiceId: Invoice ID generated on your backend /// - Returns: Redirect URL that should be displayed in a webview - @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOutApi.shared.alternativePaymentMethods.alternativePaymentMethodUrl instead.") + @available(*, deprecated, message: "Declaration will be removed in version 4.0 use ProcessOut.shared.alternativePaymentMethods.alternativePaymentMethodUrl instead.") public static func makeAPMPayment(gateway: GatewayConfiguration, invoiceId: String, additionalData: [String: String] = [:]) -> String { // Generate the redirection URL let checkout = ProcessOutLegacyApi.ProjectId + "/" + invoiceId + "/redirect/" + gateway.id diff --git a/Sources/ProcessOut/Sources/Legacy/TokenRequest.swift b/Sources/ProcessOut/Sources/Legacy/TokenRequest.swift index 523274bb1..0810a1701 100644 --- a/Sources/ProcessOut/Sources/Legacy/TokenRequest.swift +++ b/Sources/ProcessOut/Sources/Legacy/TokenRequest.swift @@ -7,7 +7,7 @@ import Foundation -@available(*, deprecated, message: "Use ProcessOutApi.shared.customerTokens.assignCustomerToken() with POAssignCustomerTokenRequest instead.") +@available(*, deprecated, message: "Use ProcessOut.shared.customerTokens.assignCustomerToken() with POAssignCustomerTokenRequest instead.") public final class TokenRequest: Encodable { var customerID: String = "" From 0dd6352eec9a6f98554ccb23441e54c308a847e6 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Thu, 11 May 2023 11:08:14 +0200 Subject: [PATCH 08/10] Fix documentation --- Sources/ProcessOut/ProcessOut.docc/ProcessOut.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md b/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md index 28ef9f14f..321c4d9c3 100644 --- a/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md +++ b/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md @@ -17,7 +17,7 @@ ProcessOut.configure(configuration: configuration) - - -- ``ProcessOut`` +- ``ProcessOut/ProcessOut`` - ``ProcessOutConfiguration`` - ``ProcessOutType`` From 238ba910c28fd2d7a513a9b926a409c43be5a24f Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Thu, 11 May 2023 11:27:05 +0200 Subject: [PATCH 09/10] Deprecate api type --- .../ProcessOut/ProcessOut.docc/ProcessOut.md | 1 - .../ProcessOut/Sources/Api/ProcessOut.swift | 46 +++++++++++-------- ...sOutType.swift => ProcessOutApiType.swift} | 12 ++--- .../PO3DSRedirectViewControllerBuilder.swift | 2 +- ...vePaymentMethodViewControllerBuilder.swift | 2 +- ...vePaymentMethodViewControllerBuilder.swift | 2 +- 6 files changed, 35 insertions(+), 30 deletions(-) rename Sources/ProcessOut/Sources/Api/{ProcessOutType.swift => ProcessOutApiType.swift} (79%) diff --git a/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md b/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md index 321c4d9c3..98ee5e100 100644 --- a/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md +++ b/Sources/ProcessOut/ProcessOut.docc/ProcessOut.md @@ -19,7 +19,6 @@ ProcessOut.configure(configuration: configuration) - - ``ProcessOut/ProcessOut`` - ``ProcessOutConfiguration`` -- ``ProcessOutType`` ### Errors diff --git a/Sources/ProcessOut/Sources/Api/ProcessOut.swift b/Sources/ProcessOut/Sources/Api/ProcessOut.swift index ce3ee0d03..923ab0f35 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOut.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOut.swift @@ -12,10 +12,10 @@ import UIKit public typealias ProcessOutApi = ProcessOut /// Provides access to shared api instance and a way to configure it. -public enum ProcessOut { +public final class ProcessOut { /// Shared instance. - public private(set) static var shared: ProcessOutType! // swiftlint:disable:this implicitly_unwrapped_optional + public private(set) static var shared: ProcessOut! // swiftlint:disable:this implicitly_unwrapped_optional /// Configures ``ProcessOut/shared`` instance. /// - NOTE: Method must be called from main thread. Only the first invocation takes effect, all @@ -26,43 +26,40 @@ public enum ProcessOut { shared.logger.info("ProcessOut can be configured only once, ignored") return } - shared = SharedProcessOut(configuration: configuration) + shared = ProcessOut(configuration: configuration) shared.logger.debug("Did complete ProcessOut configuration") } -} - -private final class SharedProcessOut: ProcessOutType { - - init(configuration: ProcessOutConfiguration) { - self.configuration = configuration - } // MARK: - ProcessOutType - let configuration: ProcessOutConfiguration + /// Current configuration. + public let configuration: ProcessOutConfiguration - private(set) lazy var gatewayConfigurations: POGatewayConfigurationsRepository = { + /// Returns gateway configurations repository. + public private(set) lazy var gatewayConfigurations: POGatewayConfigurationsRepository = { HttpGatewayConfigurationsRepository(connector: httpConnector, failureMapper: failureMapper) }() - private(set) lazy var invoices: POInvoicesService = { + /// Returns invoices service. + public private(set) lazy var invoices: POInvoicesService = { let repository = HttpInvoicesRepository(connector: httpConnector, failureMapper: failureMapper) return DefaultInvoicesService(repository: repository, threeDSService: threeDSService) }() - private(set) lazy var images: POImagesRepository = { + /// Images repository. + public private(set) lazy var images: POImagesRepository = { UrlSessionImagesRepository(session: .shared) }() - private(set) lazy var alternativePaymentMethods: POAlternativePaymentMethodsService = { + /// Returns alternative payment methods service. + public private(set) lazy var alternativePaymentMethods: POAlternativePaymentMethodsService = { DefaultAlternativePaymentMethodsService( projectId: configuration.projectId, baseUrl: configuration.checkoutBaseUrl, logger: serviceLogger ) }() - private(set) lazy var logger: POLogger = createLogger(for: Constants.applicationLoggerCategory) - - private(set) lazy var cards: POCardsService = { + /// Returns cards repository. + public private(set) lazy var cards: POCardsService = { let requestMapper = DefaultApplePayCardTokenizationRequestMapper( decoder: JSONDecoder(), logger: repositoryLogger ) @@ -73,11 +70,15 @@ private final class SharedProcessOut: ProcessOutType { return service }() - private(set) lazy var customerTokens: POCustomerTokensService = { + /// Returns customer tokens service. + public private(set) lazy var customerTokens: POCustomerTokensService = { let repository = HttpCustomerTokensRepository(connector: httpConnector, failureMapper: failureMapper) return DefaultCustomerTokensService(repository: repository, threeDSService: threeDSService) }() + /// Logger with application category. + public private(set) lazy var logger: POLogger = createLogger(for: Constants.applicationLoggerCategory) + // MARK: - Private Nested Types private enum Constants { @@ -120,6 +121,10 @@ private final class SharedProcessOut: ProcessOutType { // MARK: - Private Methods + private init(configuration: ProcessOutConfiguration) { + self.configuration = configuration + } + private func createLogger(for category: String) -> POLogger { let destinations: [LoggerDestination] = [ SystemLoggerDestination(subsystem: Constants.systemLoggerSubsystem, category: category) @@ -128,3 +133,6 @@ private final class SharedProcessOut: ProcessOutType { return POLogger(destinations: destinations, minimumLevel: minimumLevel) } } + +@available(*, deprecated, message: "Use ProcessOut directly") +extension ProcessOut: ProcessOutApiType { } diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutType.swift b/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift similarity index 79% rename from Sources/ProcessOut/Sources/Api/ProcessOutType.swift rename to Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift index 3f63f0e88..0eba07ec0 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutType.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift @@ -1,5 +1,5 @@ // -// ProcessOutType.swift +// ProcessOutApiType.swift // ProcessOut // // Created by Andrii Vysotskyi on 10.10.2022. @@ -7,11 +7,8 @@ import Foundation -@available(*, deprecated, renamed: "ProcessOutType") -public typealias ProcessOutApiType = ProcessOutType - -// todo(andrii-vysotskyi): remove suffix before releasing version 4.0.0 -public protocol ProcessOutType { +@available(*, deprecated) +public protocol ProcessOutApiType { /// Current configuration. var configuration: ProcessOutConfiguration { get } @@ -38,7 +35,8 @@ public protocol ProcessOutType { var logger: POLogger { get } } -extension ProcessOutType { +@available(*, deprecated) +extension ProcessOutApiType { /// The current version of this library, value is "3.5.0". @available(*, deprecated, message: "Use ProcessOut.version instead") diff --git a/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift index 821029a56..1ac4a0195 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/3DSRedirect/Builder/PO3DSRedirectViewControllerBuilder.swift @@ -28,7 +28,7 @@ public final class PO3DSRedirectViewControllerBuilder { /// /// - NOTE: Caller should dismiss view controller after completion is called. public func build() -> UIViewController { - let api: ProcessOutType = ProcessOut.shared + let api: ProcessOut = ProcessOut.shared // swiftlint:disable:this redundant_type_annotation let configuration = WebViewControllerConfiguration( returnUrls: [api.configuration.checkoutBaseUrl], version: ProcessOut.version, diff --git a/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift index 4c8338848..7f0739bbf 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/AlternativePaymentMethod/Builder/POAlternativePaymentMethodViewControllerBuilder.swift @@ -25,7 +25,7 @@ public final class POAlternativePaymentMethodViewControllerBuilder { /// Creates and returns view controller that is capable of handling alternative payment request. public func build() -> UIViewController { - let api: ProcessOutType = ProcessOut.shared + let api: ProcessOut = ProcessOut.shared // swiftlint:disable:this redundant_type_annotation let delegate = WebViewControllerDelegateAlternativePaymentMethod( alternativePaymentMethodsService: api.alternativePaymentMethods, request: request, diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift index d46ee8181..f50b07954 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/Builder/PONativeAlternativePaymentMethodViewControllerBuilder.swift @@ -49,7 +49,7 @@ public final class PONativeAlternativePaymentMethodViewControllerBuilder { // sw /// /// - NOTE: Caller should dismiss view controller after completion is called. public func build() -> UIViewController { - let api: ProcessOutType = ProcessOut.shared + let api: ProcessOut = ProcessOut.shared // swiftlint:disable:this redundant_type_annotation let interactor = DefaultNativeAlternativePaymentMethodInteractor( invoicesService: api.invoices, imagesRepository: api.images, From 370a4d93265b39f8956ab93379320ddb2a2c0fa3 Mon Sep 17 00:00:00 2001 From: Andrii Vysotskyi Date: Thu, 11 May 2023 11:46:17 +0200 Subject: [PATCH 10/10] Update comment --- Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift b/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift index 0eba07ec0..5282cd526 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOutApiType.swift @@ -38,7 +38,7 @@ public protocol ProcessOutApiType { @available(*, deprecated) extension ProcessOutApiType { - /// The current version of this library, value is "3.5.0". + /// The current version of this library. @available(*, deprecated, message: "Use ProcessOut.version instead") public static var version: String { ProcessOut.version