SubscriptionProductID.swift 791 B

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