Class: ItunesReceiptValidator::Remote
- Inherits:
-
Object
- Object
- ItunesReceiptValidator::Remote
- Defined in:
- lib/itunes_receipt_validator/remote.rb
Overview
ItunesReceiptValidator::Receipt
Constant Summary collapse
- PRODUCTION_ENDPOINT =
'https://buy.itunes.apple.com/verifyReceipt'.freeze
- SANDBOX_ENDPOINT =
'https://sandbox.itunes.apple.com/verifyReceipt'.freeze
Instance Attribute Summary collapse
-
#receipt ⇒ Object
readonly
Returns the value of attribute receipt.
-
#request_method ⇒ Object
Returns the value of attribute request_method.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#shared_secret ⇒ Object
Returns the value of attribute shared_secret.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(receipt) {|_self| ... } ⇒ Remote
constructor
A new instance of Remote.
- #json ⇒ Object
- #status ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(receipt) {|_self| ... } ⇒ Remote
Returns a new instance of Remote.
17 18 19 20 21 22 23 |
# File 'lib/itunes_receipt_validator/remote.rb', line 17 def initialize(receipt) @receipt = receipt @request_method = lambda do |url, headers, body| default_request_method(url, headers, body) end yield self end |
Instance Attribute Details
#receipt ⇒ Object (readonly)
Returns the value of attribute receipt.
14 15 16 |
# File 'lib/itunes_receipt_validator/remote.rb', line 14 def receipt @receipt end |
#request_method ⇒ Object
Returns the value of attribute request_method.
15 16 17 |
# File 'lib/itunes_receipt_validator/remote.rb', line 15 def request_method @request_method end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
15 16 17 |
# File 'lib/itunes_receipt_validator/remote.rb', line 15 def sandbox @sandbox end |
#shared_secret ⇒ Object
Returns the value of attribute shared_secret.
15 16 17 |
# File 'lib/itunes_receipt_validator/remote.rb', line 15 def shared_secret @shared_secret end |
Instance Method Details
#expired? ⇒ Boolean
33 34 35 |
# File 'lib/itunes_receipt_validator/remote.rb', line 33 def expired? status == 21_006 end |
#json ⇒ Object
37 38 39 |
# File 'lib/itunes_receipt_validator/remote.rb', line 37 def json @json ||= JSON.parse(response.body, symbolize_names: true) end |
#status ⇒ Object
25 26 27 |
# File 'lib/itunes_receipt_validator/remote.rb', line 25 def status json[:status].to_i end |
#valid? ⇒ Boolean
29 30 31 |
# File 'lib/itunes_receipt_validator/remote.rb', line 29 def valid? status == 0 end |