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'- API_SCOPE =
API scope for Android services
'https://www.googleapis.com/auth/androidpublisher'- API_DISCOVER =
API discovery namespace
'androidpublisher'- API_VERSION =
API version
'v2'
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.
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) self.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 |
# File 'lib/candy_check/play_store/client.rb', line 35 def boot! self.api_client = Google::APIClient.new( application_name: config.application_name, application_version: config.application_version ) 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/candy_check/play_store/client.rb', line 50 def verify(package, product_id, token) api_client.execute( api_method: rpc.purchases.products.get, parameters: { 'packageName' => package, 'productId' => product_id, 'token' => token } ).data.to_hash end |