Files
keyboard/keyBoard/Class/Pay/StoreKit2Manager/Converts/StoreKitConverter.swift
2025-12-16 13:10:50 +08:00

99 lines
3.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// StoreKitConverter.swift
// StoreKit2Manager
//
// Created by xiaopin on 2025/12/6.
//
import Foundation
import StoreKit
/// StoreKit
/// 便
public struct StoreKitConverter {
// MARK: - Product
/// Product Dictionary
public static func productToDictionary(_ product: Product) -> [String: Any] {
return ProductConverter.toDictionary(product)
}
/// Product Dictionary
public static func productsToDictionaryArray(_ products: [Product]) -> [[String: Any]] {
return ProductConverter.toDictionaryArray(products)
}
/// Product JSON
public static func productToJSONString(_ product: Product) -> String? {
return ProductConverter.toJSONString(product)
}
/// Product JSON
public static func productsToJSONString(_ products: [Product]) -> String? {
return ProductConverter.toJSONString(products)
}
// MARK: - Transaction
/// Transaction Dictionary
public static func transactionToDictionary(_ transaction: Transaction) -> [String: Any] {
return TransactionConverter.toDictionary(transaction)
}
/// Transaction Dictionary
public static func transactionsToDictionaryArray(_ transactions: [Transaction]) -> [[String: Any]] {
return TransactionConverter.toDictionaryArray(transactions)
}
/// Transaction JSON
public static func transactionToJSONString(_ transaction: Transaction) -> String? {
return TransactionConverter.toJSONString(transaction)
}
/// Transaction JSON
public static func transactionsToJSONString(_ transactions: [Transaction]) -> String? {
return TransactionConverter.toJSONString(transactions)
}
// MARK: - StoreKitState
/// StoreKitState Dictionary
public static func stateToDictionary(_ state: StoreKitState) -> [String: Any] {
return StoreKitStateConverter.toDictionary(state)
}
/// StoreKitState JSON
public static func stateToJSONString(_ state: StoreKitState) -> String? {
return StoreKitStateConverter.toJSONString(state)
}
// MARK: - RenewalInfo
/// RenewalInfo Dictionary
public static func renewalInfoToDictionary(_ renewalInfo: Product.SubscriptionInfo.RenewalInfo) -> [String: Any] {
return SubscriptionConverter.renewalInfoToDictionary(renewalInfo)
}
/// RenewalInfo JSON
public static func renewalInfoToJSONString(_ renewalInfo: Product.SubscriptionInfo.RenewalInfo) -> String? {
return SubscriptionConverter.renewalInfoToJSONString(renewalInfo)
}
// MARK: - RenewalState
/// RenewalState
public static func renewalStateToString(_ state: Product.SubscriptionInfo.RenewalState) -> String {
return SubscriptionConverter.renewalStateToString(state)
}
// MARK: - SubscriptionInfo
/// SubscriptionInfo Dictionary
public static func subscriptionInfoToDictionary(_ subscription: Product.SubscriptionInfo, product: Product? = nil) -> [String: Any] {
return SubscriptionConverter.subscriptionInfoToDictionary(subscription, product: product)
}
}