Class: CandyCheck::AppStore::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candy_check/app_store/client.rb

Overview

Simple HTTP client to load the receipt’s data from Apple’s verification servers (either sandbox or production).

Constant Summary collapse

JSON_MIME_TYPE =

Mimetype for JSON objects

"application/json".freeze

Instance Method Summary collapse

Constructor Details

#initialize(endpoint_url) ⇒ Client

Initialize a new client bound to an endpoint

Parameters:

  • endpoint_url (String)


14
15
16
# File 'lib/candy_check/app_store/client.rb', line 14

def initialize(endpoint_url)
  @uri = URI(endpoint_url)
end

Instance Method Details

#verify(receipt_data, secret = nil) ⇒ Hash

Contacts the configured endpoint and requests the receipt’s data

Parameters:

  • receipt_data (String)

    base64 encoded data string from the app

  • secret (String) (defaults to: nil)

    the password for auto-renewable subscriptions

Returns:

  • (Hash)


22
23
24
25
26
# File 'lib/candy_check/app_store/client.rb', line 22

def verify(receipt_data, secret = nil)
  request  = build_request(build_request_parameters(receipt_data, secret))
  response = perform_request(request)
  MultiJson.load(response.body)
end