Skip to content

Commit

Permalink
1.6.40
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Korney committed Sep 3, 2024
1 parent 2b561f6 commit 5f80306
Show file tree
Hide file tree
Showing 40 changed files with 661 additions and 231 deletions.
2 changes: 1 addition & 1 deletion AffiseAttributionLib.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Pod::Spec.new do |spec|
spec.name = "AffiseAttributionLib"
spec.version = ENV['LIB_VERSION'] || "1.6.39"
spec.version = ENV['LIB_VERSION'] || "1.6.40"
spec.summary = "Affise Attribution iOS library"
spec.description = "Affise SDK is a software you can use to collect app usage statistics, device identifiers, deeplink usage, track install referrer."
spec.homepage = "https://github.com/affise/sdk-ios"
Expand Down
4 changes: 2 additions & 2 deletions AffiseAttributionLib/Classes/errors/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ extension AffiseError : LocalizedError {
private var localized: String? {
switch self {
case .cloud(url: let url, error: let error, attempts: let attempts, retry: let retry):
return NSLocalizedString("AffiseError.cloud(url=\(url), error=\(error.localizedDescription.toJsonGuardString()), attempts=\(attempts), retry=\(retry))", comment: "")
return NSLocalizedString(#"AffiseError.cloud(url=\#(url), error=\#(error.localizedDescription), attempts=\#(attempts), retry=\#(retry))"#, comment: "")
case .network(status: let status, message: let message):
return NSLocalizedString("AffiseError.network(status=\(status), message=\(message?.toJsonGuardString() ?? ""))", comment: "")
return NSLocalizedString(#"AffiseError.network(status=\#(status), message=\#(message ?? ""))"#, comment: "")
case .offlineModeEnabled:
return NSLocalizedString("AffiseError.offlineModeEnabled", comment: "")
case .trackingDisabledException:
Expand Down
2 changes: 1 addition & 1 deletion AffiseAttributionLib/Classes/internal/BuildConfig.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

internal struct BuildConfig {
static let AFFISE_VERSION = "1.6.39"
static let AFFISE_VERSION = "1.6.40"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,57 @@ import Foundation

@objc
public class AffiseProduct: NSObject {

public internal(set) var type: AffiseProductType?

public internal(set) var productId: String?

public internal(set) var localizedTitle: String?

public internal(set) var localizedDescription: String?

public internal(set) var price: Decimal?

public internal(set) var currencyCode: String?

public internal(set) var currencySymbol: String?

public internal(set) var regionCode: String?
public internal(set) var productId: String
public internal(set) var title: String
public internal(set) var productDescription: String

public internal(set) var productType: AffiseProductType?

public internal(set) var priceLocale: Locale?
public internal(set) var price: AffiseProductPrice?
public internal(set) var subscription: AffiseProductSubscriptionDetail?

public internal(set) var skData: Any? = nil
public internal(set) var productDetails: Any? = nil

public convenience init(
type: AffiseProductType?,
productId: String?,
localizedTitle: String?,
localizedDescription: String?,
price: Decimal?,
priceLocale: Locale?,
skData: Any?
public init(
productId: String,
title: String,
productDescription: String,
productType: AffiseProductType?,
price: AffiseProductPrice?,
subscription: AffiseProductSubscriptionDetail?,
productDetails: Any?
) {
self.init()
self.type = type
self.productId = productId
self.localizedTitle = localizedTitle
self.localizedDescription = localizedDescription
self.title = title
self.productDescription = productDescription
self.productType = productType
self.price = price
self.currencyCode = priceLocale?.currencyCode
self.currencySymbol = priceLocale?.currencySymbol
self.regionCode = priceLocale?.regionCode
self.priceLocale = priceLocale
self.skData = skData
self.subscription = subscription
self.productDetails = productDetails
}

public func asConsumable() -> AffiseProduct {
self.productType = .CONSUMABLE
return self
}

public func asNonConsumable() -> AffiseProduct {
self.productType = .NON_CONSUMABLE
return self
}

public func asNonSubscription() -> AffiseProduct {
self.productType = .RENEWABLE_SUBSCRIPTION
return self
}

public func asNonRenewableSubscription() -> AffiseProduct {
self.productType = .NON_RENEWABLE_SUBSCRIPTION
return self
}

public override var description: String {
"AffiseProduct(productId=\"\(productId ?? "")\", localizedTitle=\"\(localizedTitle ?? "")\", price=\"\(price ?? 0)\", currencyCode=\"\(currencyCode ?? "")\", type=\"\(type?.enumValue ?? "")\")"
"AffiseProduct(productId=\"\(productId)\", title=\"\(title)\", productDescription=\"\(productDescription)\", price=\"\(price?.description ?? "")\", type=\"\(productType?.enumValue ?? "")\")"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Foundation

@objc
public class AffiseProductPrice: NSObject {
public internal(set) var value: Decimal
public internal(set) var currencyCode: String
public internal(set) var formattedPrice: String

public internal(set) var locale: Locale = Locale.current

public init(
value: Decimal,
currencyCode: String,
formattedPrice: String
) {
self.value = value
self.currencyCode = currencyCode
self.formattedPrice = formattedPrice
}

public convenience init(
value: Decimal,
priceLocale: Locale? = Locale.current
) {
let locale = priceLocale ?? Locale.current

let formatter = NumberFormatter()
formatter.locale = locale
formatter.numberStyle = .currency

let currencyCode = locale.currencyCode ?? ""

// if #available(iOS 16, *) {
// currencyCode = locale.currency?.identifier ?? "" // TODO
// }

self.init(
value: value,
currencyCode: currencyCode,
formattedPrice: formatter.string(from: NSDecimalNumber(decimal: value)) ?? "\(value) \(currencyCode)"
)
}

public override var description: String {
"AffiseProductPrice(value=\"\(value)\", currencyCode=\"\(currencyCode)\", formattedPrice=\"\(formattedPrice)\")"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation


@objc
public class AffiseProductSubscriptionDetail: NSObject {
// public internal(set) var offerToken: String
public internal(set) var offerId: String?
public internal(set) var timeUnit: TimeUnitType
public internal(set) var numberOfUnits: Int

public init(
offerId: String? = nil,
timeUnit: TimeUnitType,
numberOfUnits: Int
) {
self.offerId = offerId
self.timeUnit = timeUnit
self.numberOfUnits = numberOfUnits
}

public override var description: String {
"AffiseProductSubscriptionDetail(offerId=\"\(offerId ?? "")\", timeUnit=\"\(timeUnit)\", numberOfUnits=\"\(numberOfUnits)\")"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ public enum AffiseProductType: Int {
}
}
}

extension AffiseProductType: CaseIterable, CustomStringConvertible {

public var description: String { enumValue }

public static func from(_ name: String?) -> AffiseProductType? {
guard let name = name else { return nil }
return allCases.first { name == $0.enumValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class AffiseProductsResult: NSObject {
}

public override var description: String {
"AffiseProductsResult(products=[\(products.map { $0.productId ?? "" }.joined(separator: ", "))], invalidIds=[\(invalidIds.joined(separator: ", "))])"
"AffiseProductsResult(products=[\(products.map { $0.productId }.joined(separator: ", "))], invalidIds=[\(invalidIds.joined(separator: ", "))])"
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import Foundation


@objc
public class AffisePurchasedInfo: NSObject {

public internal(set) var product: AffiseProduct?

public internal(set) var operationDate: Date?

public internal(set) var orderId: String?

public internal(set) var originalOrderId: String?
public internal(set) var purchase: Any? = nil

public internal(set) var skData: Any? = nil

public convenience init(_ transaction: Any?, _ product: AffiseProduct?, orderId: String? = nil, originalOrderId: String?, operationDate: Date?) {
public internal(set) var operationDate: Date?

public convenience init(
_ transaction: Any?,
_ product: AffiseProduct?,
orderId: String? = nil,
originalOrderId: String?,
operationDate: Date?
) {
self.init()
self.skData = transaction
self.product = product
self.orderId = orderId
self.originalOrderId = originalOrderId
self.purchase = transaction
self.operationDate = operationDate
}
public override var description: String {

override public var description: String {
"AffisePurchasedInfo(productId=\"\(product?.productId ?? "")\", orderId=\"\(orderId ?? "")\", originalOrderId=\"\(originalOrderId ?? "")\")"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ public enum TimeUnitType: Int {
case .YEAR: return "year"
}
}
}
}

extension TimeUnitType: CaseIterable, CustomStringConvertible {

public var description: String { return self.enumValue }

public static func from(_ name: String?) -> TimeUnitType? {
guard let name = name else { return nil }
return allCases.first { name == $0.enumValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extension NetworkServiceImpl: NetworkService {
Thread.sleep(forTimeInterval: 1)
}

let httpResponse = HttpResponse(responseCode, responseMessage, responseBody, responseHeaders)
let httpResponse = HttpResponse(responseCode, responseMessage, responseBody?.toSinglQuote, responseHeaders)
if let debugRequest = debugRequest {
debugRequest(HttpRequest(httpsUrl, method, headers, data?.toString()), httpResponse)
}
Expand Down
4 changes: 4 additions & 0 deletions AffiseAttributionLib/Classes/utils/StringUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public extension String {
return self.replacingOccurrences(of: "\"", with: "\\\"")
}

var toSinglQuote: String {
return self.replacingOccurrences(of: "\\\"", with: "\'")
}

var isBlank: Bool {
return allSatisfy { $0.isWhitespace }
}
Expand Down
2 changes: 1 addition & 1 deletion AffiseInternal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |spec|
spec.name = "AffiseInternal"
spec.version = ENV['LIB_VERSION'] || "1.6.39"
spec.version = ENV['LIB_VERSION'] || "1.6.40"
spec.summary = "Affise Internal library"
spec.description = "Affise Internal wrapper library for crossplatform"
spec.homepage = "https://github.com/affise/sdk-ios"
Expand Down
7 changes: 7 additions & 0 deletions AffiseInternal/Classes/AffiseApiMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public enum AffiseApiMethod: Int {
case GET_STATUS_CALLBACK
// Link Module
case MODULE_LINK_LINK_RESOLVE_CALLBACK
// Subscription Module
case MODULE_SUBS_FETCH_PRODUCTS_CALLBACK
case MODULE_SUBS_PURCHASE_CALLBACK
////////////////////////////////////////
// modules
////////////////////////////////////////
Expand Down Expand Up @@ -91,7 +94,11 @@ public enum AffiseApiMethod: Int {
case .MODULE_START: return "module_start"
case .GET_MODULES_INSTALLED: return "get_modules_installed"
case .GET_STATUS_CALLBACK: return "get_status_callback"
// Link Module
case .MODULE_LINK_LINK_RESOLVE_CALLBACK: return "module_link_link_resolve_callback"
// Subscription Module
case .MODULE_SUBS_FETCH_PRODUCTS_CALLBACK: return "module_subs_fetch_products_callback"
case .MODULE_SUBS_PURCHASE_CALLBACK: return "module_subs_purchase_callback"
////////////////////////////////////////
// modules
////////////////////////////////////////
Expand Down
Loading

0 comments on commit 5f80306

Please sign in to comment.