Class: Itunes::Receipt::Service
- Inherits:
-
Object
- Object
- Itunes::Receipt::Service
- Defined in:
- lib/itunes/receipt/service.rb
Constant Summary collapse
- TEST_HOST =
'sandbox.itunes.apple.com'- PRODUCTION_HOST =
'buy.itunes.apple.com'
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize(host: PRODUCTION_HOST, password: nil) ⇒ Service
constructor
A new instance of Service.
- #validate(receipt_data: nil) ⇒ Object
Constructor Details
#initialize(host: PRODUCTION_HOST, password: nil) ⇒ Service
Returns a new instance of Service.
11 12 13 14 15 |
# File 'lib/itunes/receipt/service.rb', line 11 def initialize host: PRODUCTION_HOST, password: nil @host = host @password = password @connection = Excon.new("https://#{host}") end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
9 10 11 |
# File 'lib/itunes/receipt/service.rb', line 9 def connection @connection end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/itunes/receipt/service.rb', line 9 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
9 10 11 |
# File 'lib/itunes/receipt/service.rb', line 9 def password @password end |
Instance Method Details
#validate(receipt_data: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/itunes/receipt/service.rb', line 17 def validate receipt_data: nil request = { 'receipt-data' => receipt_data, 'password' => password } response = connection.post(path: '/verifyReceipt', body: request.to_json) Itunes::Receipt::Response.new(response: response, request: request) end |