Class: Venice::Client
- Inherits:
-
Object
- Object
- Venice::Client
- Defined in:
- lib/venice/client.rb
Instance Attribute Summary collapse
-
#shared_secret ⇒ Object
writeonly
Sets the attribute shared_secret.
-
#verification_url ⇒ Object
Returns the value of attribute verification_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #verify!(data, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
27 28 29 |
# File 'lib/venice/client.rb', line 27 def initialize @verification_url = ENV['IAP_VERIFICATION_ENDPOINT'] end |
Instance Attribute Details
#shared_secret=(value) ⇒ Object (writeonly)
Sets the attribute shared_secret
11 12 13 |
# File 'lib/venice/client.rb', line 11 def shared_secret=(value) @shared_secret = value end |
#verification_url ⇒ Object
Returns the value of attribute verification_url.
10 11 12 |
# File 'lib/venice/client.rb', line 10 def verification_url @verification_url end |
Class Method Details
.development ⇒ Object
14 15 16 17 18 |
# File 'lib/venice/client.rb', line 14 def development client = self.new client.verification_url = ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT client end |
.production ⇒ Object
20 21 22 23 24 |
# File 'lib/venice/client.rb', line 20 def production client = self.new client.verification_url = ITUNES_PRODUCTION_RECEIPT_VERIFICATION_ENDPOINT client end |
Instance Method Details
#verify!(data, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/venice/client.rb', line 31 def verify!(data, = {}) @verification_url ||= ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT @shared_secret = [:shared_secret] json = (data) status, receipt_attributes = json['status'].to_i, json['receipt'] case status when 0, 21006 attributes = (receipt_attributes || {}).merge({ 'latest_receipt' => json['latest_receipt'], 'latest_receipt_info' => json['latest_receipt_info'], }) Receipt.new(attributes) else raise Receipt::VerificationError.new(status, receipt_attributes) end end |