Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 21 additions & 36 deletions Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

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 ``ProcessOutConfiguration/production(projectId:appVersion:isDebug:)``
/// method.
Expand All @@ -35,13 +32,6 @@ public struct ProcessOutConfiguration: Sendable {
/// Application name.
public let application: Application?

/// Host application version. Providing this value helps ProcessOut to troubleshoot potential
/// issues.
@available(*, deprecated, renamed: "application.version")
public var appVersion: String? {
application?.version
}

/// Session ID is a constant value
@_spi(PO)
public let sessionId = UUID().uuidString
Expand All @@ -60,38 +50,33 @@ public struct ProcessOutConfiguration: Sendable {
@_spi(PO)
public let privateKey: String?

/// Api base URL.
let apiBaseUrl = URL(string: "https://api.processout.com")! // swiftlint:disable:this force_unwrapping

/// Checkout base URL.
let checkoutBaseUrl = URL(string: "https://checkout.processout.com")! // swiftlint:disable:this force_unwrapping
}

extension ProcessOutConfiguration {

/// Creates production configuration.
///
/// - Parameters:
/// - appVersion: when application parameter is set, it takes precedence over this parameter.
public static func production(
/// Creates configuration.
public init(
projectId: String,
application: Application? = nil,
appVersion: String? = nil,
isDebug: Bool = false,
isTelemetryEnabled: Bool = true
) -> Self {
.init(
projectId: projectId,
application: application ?? .init(name: nil, version: appVersion),
isDebug: isDebug,
isTelemetryEnabled: isTelemetryEnabled,
privateKey: nil
)
) {
self.projectId = projectId
self.application = application
self.isDebug = isDebug
self.isTelemetryEnabled = isTelemetryEnabled
self.privateKey = nil
}

/// Creates debug production configuration with optional private key.
/// Creates debug configuration.
@_spi(PO)
public static func production(projectId: String, privateKey: String? = nil) -> Self {
.init(projectId: projectId, application: nil, isDebug: true, isTelemetryEnabled: false, privateKey: privateKey)
public init(projectId: String, privateKey: String) {
self.projectId = projectId
self.application = nil
self.isDebug = true
self.isTelemetryEnabled = false
self.privateKey = privateKey
}

/// Api base URL.
let apiBaseUrl = URL(string: "https://api.processout.com")! // swiftlint:disable:this force_unwrapping

/// Checkout base URL.
let checkoutBaseUrl = URL(string: "https://checkout.processout.com")! // swiftlint:disable:this force_unwrapping
}
3 changes: 0 additions & 3 deletions Sources/ProcessOut/Sources/Api/ProcessOut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import Foundation
import UIKit

@available(*, deprecated, renamed: "ProcessOut")
public typealias ProcessOutApi = ProcessOut

/// Provides access to shared api instance and a way to configure it.
/// - NOTE: Instance methods and properties of this class could be access from any thread.
public final class ProcessOut: @unchecked Sendable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
// Created by Andrii Vysotskyi on 21.12.2022.
//

@available(*, deprecated, renamed: "POCancellable")
public typealias POCancellableType = POCancellable

/// A protocol indicating that an activity or action supports cancellation.
public protocol POCancellable: Sendable {

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// POImmutableStringCodableDecimal.swift
// POStringCodableDecimal.swift
// ProcessOut
//
// Created by Andrii Vysotskyi on 30.11.2022.
Expand All @@ -12,9 +12,9 @@ import Foundation
/// Property wrapper that allows to encode and decode `Decimal` to/from string representation. Value is coded
/// in en_US locale.
@propertyWrapper
public struct POImmutableStringCodableDecimal: Codable, Sendable {
public struct POStringCodableDecimal: Codable, Sendable {

public let wrappedValue: Decimal
public var wrappedValue: Decimal

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
Expand Down Expand Up @@ -50,7 +50,7 @@ public struct POImmutableStringCodableDecimal: Codable, Sendable {
extension KeyedEncodingContainer {

public mutating func encode(
_ value: POImmutableStringCodableDecimal, forKey key: KeyedEncodingContainer<K>.Key
_ value: POStringCodableDecimal, forKey key: KeyedEncodingContainer<K>.Key
) throws {
try value.encode(to: superEncoder(forKey: key))
}
Expand All @@ -59,8 +59,8 @@ extension KeyedEncodingContainer {
extension KeyedDecodingContainer {

public func decode(
_ type: POImmutableStringCodableDecimal.Type, forKey key: KeyedDecodingContainer<K>.Key
) throws -> POImmutableStringCodableDecimal {
_ type: POStringCodableDecimal.Type, forKey key: KeyedDecodingContainer<K>.Key
) throws -> POStringCodableDecimal {
try type.init(from: try superDecoder(forKey: key))
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// POImmutableStringCodableOptionalDecimal.swift
// POStringCodableOptionalDecimal.swift
// ProcessOut
//
// Created by Andrii Vysotskyi on 18.10.2022.
Expand All @@ -12,9 +12,9 @@ import Foundation
/// Property wrapper that allows to encode and decode optional `Decimal` to/from string representation. Value is coded
/// in en_US locale.
@propertyWrapper
public struct POImmutableStringCodableOptionalDecimal: Codable, Sendable {
public struct POStringCodableOptionalDecimal: Codable, Sendable {

public let wrappedValue: Decimal?
public var wrappedValue: Decimal?

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
Expand Down Expand Up @@ -54,7 +54,7 @@ public struct POImmutableStringCodableOptionalDecimal: Codable, Sendable {
extension KeyedEncodingContainer {

public mutating func encode(
_ value: POImmutableStringCodableOptionalDecimal, forKey key: KeyedEncodingContainer<K>.Key
_ value: POStringCodableOptionalDecimal, forKey key: KeyedEncodingContainer<K>.Key
) throws {
try value.encode(to: superEncoder(forKey: key))
}
Expand All @@ -63,8 +63,8 @@ extension KeyedEncodingContainer {
extension KeyedDecodingContainer {

public func decode(
_ type: POImmutableStringCodableOptionalDecimal.Type, forKey key: KeyedDecodingContainer<K>.Key
) throws -> POImmutableStringCodableOptionalDecimal {
_ type: POStringCodableOptionalDecimal.Type, forKey key: KeyedDecodingContainer<K>.Key
) throws -> POStringCodableOptionalDecimal {
try type.init(from: try superDecoder(forKey: key))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ actor DefaultDeviceMetadataProvider: DeviceMetadataProvider {
@MainActor var deviceMetadata: DeviceMetadata {
get async {
let metadata = DeviceMetadata(
id: .init(value: await deviceId),
installationId: .init(value: device.identifierForVendor?.uuidString),
systemVersion: .init(value: device.systemVersion),
model: .init(value: await machineName),
id: await deviceId,
installationId: device.identifierForVendor?.uuidString,
systemVersion: device.systemVersion,
model: await machineName,
appLanguage: bundle.preferredLocalizations.first!, // swiftlint:disable:this force_unwrapping
appScreenWidth: Int(screen.nativeBounds.width), // Specified in pixels
appScreenHeight: Int(screen.nativeBounds.height),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@

import Foundation

struct DeviceMetadata: Encodable, Sendable {
struct DeviceMetadata: Encodable, Sendable { // sourcery: AutoCodingKeys

/// Current device identifier.
@POImmutableExcludedCodable
var id: String?
let id: String? // sourcery:coding: skip

/// Installation identifier. Value changes if host application is reinstalled.
@POImmutableExcludedCodable
var installationId: String?
let installationId: String? // sourcery:coding: skip

/// Device system version.
@POImmutableExcludedCodable
var systemVersion: String
let systemVersion: String // sourcery:coding: skip

/// Device model.
@POImmutableExcludedCodable
var model: String?
let model: String? // sourcery:coding: skip

/// Default app language.
let appLanguage: String
Expand Down
Loading