×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Paulo Martín
Added: Sep 15, 2021 8:57 PM
Views: 3043
Tags: no tags
  1. /*
  2. See LICENSE folder for this sample’s licensing information.
  3.  
  4. Abstract:
  5. Handles the application's configuration information.
  6. */
  7.  
  8. import Foundation
  9.  
  10. // MARK: - Download Information
  11.  
  12. /// A structure that specifies a downloadable content's information that will be displayed to users.
  13. struct DownloadContentLabels {
  14.     static let contentIdentifier = "Identifier"
  15.     static let contentVersion = "Version"
  16.     static let contentLength = "Length"
  17.     static let transactionDate = "Transaction Date"
  18.     static let transactionIdentifier = "Transaction ID"
  19. }
  20.  
  21. /// An enumeration that specifies whether a product has associated Apple-hosted content.
  22. enum Hosted: String, CustomStringConvertible {
  23.     case yes = "Yes"
  24.     case not = "No"
  25.    
  26.     var description: String {
  27.         return self.rawValue
  28.     }
  29. }
  30.  
  31. // MARK: - Message
  32.  
  33. /// A structure of messages that will be displayed to users.
  34. struct Messages {
  35.     #if os (iOS)
  36.     static let cannotMakePayments = "\(notAuthorized) \(installing)"
  37.     #else
  38.     static let cannotMakePayments = "In-App Purchases are not allowed."
  39.     #endif
  40.     static let couldNotFind = "Could not find resource file:"
  41.     static let deferred = "Allow the user to continue using your app."
  42.     static let deliverContent = "Deliver content for"
  43.     static let emptyString = ""
  44.     static let error = "Error: "
  45.     static let failed = "failed."
  46.     static let installing = "In-App Purchases may be restricted on your device."
  47.     static let invalidIndexPath = "Invalid selected index path"
  48.     static let noRestorablePurchases = "There are no restorable purchases.\n\(previouslyBought)"
  49.     static let noPurchasesAvailable = "No purchases available."
  50.     static let notAuthorized = "You are not authorized to make payments."
  51.     static let okButton = "OK"
  52.     static let previouslyBought = "Only previously bought non-consumable products and auto-renewable subscriptions can be restored."
  53.     static let productRequestStatus = "Product Request Status"
  54.     static let purchaseOf = "Purchase of"
  55.     static let purchaseStatus = "Purchase Status"
  56.     static let removed = "was removed from the payment queue."
  57.     static let restorable = "All restorable transactions have been processed by the payment queue."
  58.     static let restoreContent = "Restore content for"
  59.     static let status = "Status"
  60.     static let unableToInstantiateAvailableProducts = "Unable to instantiate an AvailableProducts."
  61.     static let unableToInstantiateInvalidProductIds = "Unable to instantiate an InvalidProductIdentifiers."
  62.     static let unableToInstantiateMessages = "Unable to instantiate a MessagesViewController."
  63.     static let unableToInstantiateNavigationController = "Unable to instantiate a navigation controller."
  64.     static let unableToInstantiateProducts = "Unable to instantiate a Products."
  65.     static let unableToInstantiatePurchases = "Unable to instantiate a Purchases."
  66.     static let unableToInstantiateSettings = "Unable to instantiate a Settings."
  67.     static let unknownPaymentTransaction = "Unknown payment transaction case."
  68.     static let unknownDestinationViewController = "Unknown destination view controller."
  69.     static let unknownDetail = "Unknown detail row:"
  70.     static let unknownPurchase = "No selected purchase."
  71.     static let unknownSelectedSegmentIndex = "Unknown selected segment index: "
  72.     static let unknownSelectedViewController = "Unknown selected view controller."
  73.     static let unknownTabBarIndex = "Unknown tab bar index:"
  74.     static let unknownToolbarItem = "Unknown selected toolbar item: "
  75.     static let updateResource = "Update it with your product identifiers to retrieve product information."
  76.     static let useStoreRestore = "Use Store > Restore to restore your previously bought non-consumable products and auto-renewable subscriptions."
  77.     static let viewControllerDoesNotExist = "The main content view controller does not exist."
  78.     static let windowDoesNotExist = "The window does not exist."
  79. }
  80.  
  81. // MARK: - Resource File
  82.  
  83. /// A structure that specifies the name and file extension of a resource file, which contains the product identifiers to be queried.
  84. struct ProductIdentifiers {
  85.     /// Name of the resource file containing the product identifiers.
  86.     let name = "ProductIds"
  87.     /// Filename extension of the resource file containing the product identifiers.
  88.     let fileExtension = "plist"
  89. }
  90.  
  91. // MARK: - Data Management
  92.  
  93. /// An enumeration of all the types of products or purchases.
  94. enum SectionType: String, CustomStringConvertible {
  95.     #if os (macOS)
  96.     case availableProducts = "Available Products"
  97.     case invalidProductIdentifiers = "Invalid Product Identifiers"
  98.     case purchased = "Purchased"
  99.     case restored = "Restored"
  100.     #else
  101.     case availableProducts = "AVAILABLE PRODUCTS"
  102.     case invalidProductIdentifiers = "INVALID PRODUCT IDENTIFIERS"
  103.     case purchased = "PURCHASED"
  104.     case restored = "RESTORED"
  105.     #endif
  106.     case download = "DOWNLOAD"
  107.     case originalTransaction = "ORIGINAL TRANSACTION"
  108.     case productIdentifier = "PRODUCT IDENTIFIER"
  109.     case transactionDate = "TRANSACTION DATE"
  110.     case transactionIdentifier = "TRANSACTION ID"
  111.    
  112.     var description: String {
  113.         return self.rawValue
  114.     }
  115. }
  116.  
  117. /// A structure that is used to represent a list of products or purchases.
  118. struct Section {
  119.     /// Products/Purchases are organized by category.
  120.     var type: SectionType
  121.     /// List of products/purchases.
  122.     var elements = [Any]()
  123. }
  124.  
  125. // MARK: - View Controllers
  126.  
  127. /// A structure that specifies all the view controller identifiers.
  128. struct ViewControllerIdentifiers {
  129.     static let availableProducts = "availableProducts"
  130.     static let invalidProductdentifiers = "invalidProductIdentifiers"
  131.     static let messages = "messages"
  132.     static let products = "products"
  133.     static let purchases = "purchases"
  134. }
  135.  
  136. /// An enumeration of view controller names.
  137. enum ViewControllerNames: String, CustomStringConvertible {
  138.     case messages = "Messages"
  139.     case products = "Products"
  140.     case purchases = "Purchases"
  141.    
  142.     var description: String {
  143.         return self.rawValue
  144.     }
  145. }
  146.