Class: CandyCheck::AppStore::Receipt
- Inherits:
-
Object
- Object
- CandyCheck::AppStore::Receipt
- Includes:
- Utils::AttributeReader
- Defined in:
- lib/candy_check/app_store/receipt.rb
Overview
Describes a successful response from the AppStore verification server
Instance Attribute Summary collapse
-
#attributes ⇒ Hash
readonly
The raw attributes returned from the server.
Instance Method Summary collapse
-
#app_version ⇒ String
The version number for the app.
-
#bundle_identifier ⇒ String
The app’s bundle identifier.
-
#cancellation_date ⇒ DateTime
The date of when Apple has canceled this transaction.
-
#expires_date ⇒ DateTime
The date of a subscription’s expiration.
-
#initialize(attributes) ⇒ Receipt
constructor
Initializes a new instance which bases on a JSON result from Apple’s verification server.
-
#is_trial_period ⇒ Object
rubocop:disable Naming/PredicateName.
-
#item_id ⇒ String
The app’s item id of the product.
-
#original_purchase_date ⇒ DateTime
The original purchase date which might differ from the actual purchase date for restored products.
-
#original_transaction_id ⇒ String
The receipt’s original transaction id which might differ from the transaction id for restored products.
-
#product_id ⇒ String
The app’s identifier of the product (SKU).
-
#purchase_date ⇒ DateTime
The purchase date.
-
#quantity ⇒ Integer
The quantity of the product.
-
#transaction_id ⇒ String
The receipt’s transaction id.
-
#valid? ⇒ Boolean
In most cases a receipt is a valid transaction except when the transaction was canceled.
Constructor Details
#initialize(attributes) ⇒ Receipt
Initializes a new instance which bases on a JSON result from Apple’s verification server
13 14 15 |
# File 'lib/candy_check/app_store/receipt.rb', line 13 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Hash (readonly)
Returns the raw attributes returned from the server.
8 9 10 |
# File 'lib/candy_check/app_store/receipt.rb', line 8 def attributes @attributes end |
Instance Method Details
#app_version ⇒ String
The version number for the app
39 40 41 |
# File 'lib/candy_check/app_store/receipt.rb', line 39 def app_version read("bvrs") end |
#bundle_identifier ⇒ String
The app’s bundle identifier
45 46 47 |
# File 'lib/candy_check/app_store/receipt.rb', line 45 def bundle_identifier read("bid") end |
#cancellation_date ⇒ DateTime
The date of when Apple has canceled this transaction. From Apple’s documentation: “Treat a canceled receipt the same as if no purchase had ever been made.”
84 85 86 |
# File 'lib/candy_check/app_store/receipt.rb', line 84 def cancellation_date read_datetime_from_string("cancellation_date") end |
#expires_date ⇒ DateTime
The date of a subscription’s expiration
90 91 92 |
# File 'lib/candy_check/app_store/receipt.rb', line 90 def expires_date read_datetime_from_string("expires_date") end |
#is_trial_period ⇒ Object
rubocop:disable Naming/PredicateName
95 96 97 98 |
# File 'lib/candy_check/app_store/receipt.rb', line 95 def is_trial_period # rubocop:enable Naming/PredicateName read_bool("is_trial_period") end |
#item_id ⇒ String
The app’s item id of the product
57 58 59 |
# File 'lib/candy_check/app_store/receipt.rb', line 57 def item_id read("item_id") end |
#original_purchase_date ⇒ DateTime
The original purchase date which might differ from the actual purchase date for restored products
76 77 78 |
# File 'lib/candy_check/app_store/receipt.rb', line 76 def original_purchase_date read_datetime_from_string("original_purchase_date") end |
#original_transaction_id ⇒ String
The receipt’s original transaction id which might differ from the transaction id for restored products
33 34 35 |
# File 'lib/candy_check/app_store/receipt.rb', line 33 def original_transaction_id read("original_transaction_id") end |
#product_id ⇒ String
The app’s identifier of the product (SKU)
51 52 53 |
# File 'lib/candy_check/app_store/receipt.rb', line 51 def product_id read("product_id") end |
#purchase_date ⇒ DateTime
The purchase date
69 70 71 |
# File 'lib/candy_check/app_store/receipt.rb', line 69 def purchase_date read_datetime_from_string("purchase_date") end |
#quantity ⇒ Integer
The quantity of the product
63 64 65 |
# File 'lib/candy_check/app_store/receipt.rb', line 63 def quantity read_integer("quantity") end |
#transaction_id ⇒ String
The receipt’s transaction id
26 27 28 |
# File 'lib/candy_check/app_store/receipt.rb', line 26 def transaction_id read("transaction_id") end |
#valid? ⇒ Boolean
In most cases a receipt is a valid transaction except when the transaction was canceled.
20 21 22 |
# File 'lib/candy_check/app_store/receipt.rb', line 20 def valid? !has?("cancellation_date") end |