Class: Ios::Receipt::Receipt
- Inherits:
-
Object
- Object
- Ios::Receipt::Receipt
- Defined in:
- lib/ios/receipt/receipt.rb
Instance Attribute Summary collapse
-
#app_item_id ⇒ Object
readonly
Returns the value of attribute app_item_id.
-
#cancellation_date ⇒ Object
readonly
Returns the value of attribute cancellation_date.
-
#expires_date ⇒ Object
readonly
Returns the value of attribute expires_date.
-
#is_trial_period ⇒ Object
readonly
Returns the value of attribute is_trial_period.
-
#original_purchase_date ⇒ Object
readonly
Returns the value of attribute original_purchase_date.
-
#original_transaction_id ⇒ Object
readonly
Returns the value of attribute original_transaction_id.
-
#product_id ⇒ Object
readonly
Returns the value of attribute product_id.
-
#purchase_date ⇒ Object
readonly
Returns the value of attribute purchase_date.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
-
#version_external_identifier ⇒ Object
readonly
Returns the value of attribute version_external_identifier.
-
#web_order_line_item_id ⇒ Object
readonly
Returns the value of attribute web_order_line_item_id.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #cancelled? ⇒ Boolean
- #expired? ⇒ Boolean
- #in_trial? ⇒ Boolean
-
#initialize(receipt_hash) ⇒ Receipt
constructor
A new instance of Receipt.
- #once_off? ⇒ Boolean
- #recurring? ⇒ Boolean
Constructor Details
#initialize(receipt_hash) ⇒ Receipt
Returns a new instance of Receipt.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ios/receipt/receipt.rb', line 6 def initialize(receipt_hash) @quantity = receipt_hash['quantity'] @product_id = receipt_hash['product_id'] @original_transaction_id = receipt_hash['original_transaction_id'] @transaction_id = receipt_hash['transaction_id'] @original_purchase_date = parse_time receipt_hash['original_purchase_date'] @purchase_date = parse_time receipt_hash['purchase_date'] @expires_date = parse_time receipt_hash['expires_date'] @cancellation_date = parse_time receipt_hash['cancellation_date'] @app_item_id = receipt_hash['app_item_id'] @version_external_identifier = receipt_hash['version_external_identifier'] @web_order_line_item_id = receipt_hash['web_order_line_item_id'] @is_trial_period = receipt_hash['is_trial_period'] == 'true' end |
Instance Attribute Details
#app_item_id ⇒ Object (readonly)
Returns the value of attribute app_item_id.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def app_item_id @app_item_id end |
#cancellation_date ⇒ Object (readonly)
Returns the value of attribute cancellation_date.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def cancellation_date @cancellation_date end |
#expires_date ⇒ Object (readonly)
Returns the value of attribute expires_date.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def expires_date @expires_date end |
#is_trial_period ⇒ Object (readonly)
Returns the value of attribute is_trial_period.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def is_trial_period @is_trial_period end |
#original_purchase_date ⇒ Object (readonly)
Returns the value of attribute original_purchase_date.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def original_purchase_date @original_purchase_date end |
#original_transaction_id ⇒ Object (readonly)
Returns the value of attribute original_transaction_id.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def original_transaction_id @original_transaction_id end |
#product_id ⇒ Object (readonly)
Returns the value of attribute product_id.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def product_id @product_id end |
#purchase_date ⇒ Object (readonly)
Returns the value of attribute purchase_date.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def purchase_date @purchase_date end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def quantity @quantity end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def transaction_id @transaction_id end |
#version_external_identifier ⇒ Object (readonly)
Returns the value of attribute version_external_identifier.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def version_external_identifier @version_external_identifier end |
#web_order_line_item_id ⇒ Object (readonly)
Returns the value of attribute web_order_line_item_id.
2 3 4 |
# File 'lib/ios/receipt/receipt.rb', line 2 def web_order_line_item_id @web_order_line_item_id end |
Instance Method Details
#active? ⇒ Boolean
29 30 31 |
# File 'lib/ios/receipt/receipt.rb', line 29 def active? !cancelled? && !expired? end |
#cancelled? ⇒ Boolean
38 39 40 |
# File 'lib/ios/receipt/receipt.rb', line 38 def cancelled? !@cancellation_date.nil? end |
#expired? ⇒ Boolean
33 34 35 36 |
# File 'lib/ios/receipt/receipt.rb', line 33 def expired? return false unless recurring? !!(@expires_date && @expires_date < Time.now) end |
#in_trial? ⇒ Boolean
42 43 44 |
# File 'lib/ios/receipt/receipt.rb', line 42 def in_trial? @is_trial_period end |
#once_off? ⇒ Boolean
21 22 23 |
# File 'lib/ios/receipt/receipt.rb', line 21 def once_off? @expires_date.nil? end |
#recurring? ⇒ Boolean
25 26 27 |
# File 'lib/ios/receipt/receipt.rb', line 25 def recurring? !once_off? end |