Class: CandyCheck::PlayStore::Client
- Inherits:
-
Object
- Object
- CandyCheck::PlayStore::Client
- Defined in:
- lib/candy_check/play_store/client.rb
Overview
A client which uses the official Google API SDK to authenticate and request product information from Google’s API.
Defined Under Namespace
Classes: DiscoveryError
Constant Summary collapse
- API_URL =
API endpoint
'https://accounts.google.com/o/oauth2/token'.freeze
- API_SCOPE =
API scope for Android services
'https://www.googleapis.com/auth/androidpublisher'.freeze
- API_DISCOVER =
API discovery namespace
'androidpublisher'.freeze
- API_VERSION =
API version
'v2'.freeze
Instance Method Summary collapse
-
#boot! ⇒ Object
Boots a client by discovering the API’s services and then authorizes by fetching an access token.
-
#initialize(config) ⇒ Client
constructor
Initializes a client using a configuration.
-
#verify(package, product_id, token) ⇒ Hash
Calls the remote API to load the product information for a specific combination of parameter which should be loaded from the client.
-
#verify_subscription(package, subscription_id, token) ⇒ Hash
Calls the remote API to load the product information for a specific combination of parameter which should be loaded from the client.
Constructor Details
#initialize(config) ⇒ Client
Initializes a client using a configuration.
28 29 30 |
# File 'lib/candy_check/play_store/client.rb', line 28 def initialize(config) @config = config end |
Instance Method Details
#boot! ⇒ Object
Boots a client by discovering the API’s services and then authorizes by fetching an access token. If the config has a cache_file the client tries to load discovery
35 36 37 38 39 40 41 42 43 |
# File 'lib/candy_check/play_store/client.rb', line 35 def boot! @api_client = Google::APIClient.new( application_name: config.application_name, application_version: config.application_version, user_agent: user_agent ) discover! end |
#verify(package, product_id, token) ⇒ Hash
Calls the remote API to load the product information for a specific combination of parameter which should be loaded from the client.
51 52 53 54 55 56 57 58 |
# File 'lib/candy_check/play_store/client.rb', line 51 def verify(package, product_id, token) parameters = { 'packageName' => package, 'productId' => product_id, 'token' => token } execute(parameters, rpc.purchases.products.get) end |
#verify_subscription(package, subscription_id, token) ⇒ Hash
Calls the remote API to load the product information for a specific combination of parameter which should be loaded from the client.
66 67 68 69 70 71 72 73 |
# File 'lib/candy_check/play_store/client.rb', line 66 def verify_subscription(package, subscription_id, token) parameters = { 'packageName' => package, 'subscriptionId' => subscription_id, 'token' => token } execute(parameters, rpc.purchases.subscriptions.get) end |