SubscriptionProductID.swift 727 B

123456789101112131415161718192021222324
  1. import Foundation
  2. enum SubscriptionProductID {
  3. static let monthly = "com.app_for_reddit.pro.monthly"
  4. static let yearly = "com.app_for_reddit.pro.yearly"
  5. static let lifetime = "com.app_for_reddit.pro.lifetime"
  6. static let catalog: [String] = [monthly, yearly, lifetime]
  7. static func productIDs(from config: PaywallConfig) -> [String] {
  8. if let ids = config.productIDs, !ids.isEmpty {
  9. return ids
  10. }
  11. return catalog
  12. }
  13. static func planKey(for productID: String) -> String {
  14. productID.split(separator: ".").last.map(String.init) ?? productID
  15. }
  16. static func plan(for productID: String) -> PaywallPlan? {
  17. PaywallPlan(productID: productID)
  18. }
  19. }