Class: CandyCheck::PlayStore::Verification

Inherits:
Object
  • Object
show all
Defined in:
lib/candy_check/play_store/verification.rb

Overview

Verifies a purchase token against the Google API The call return either an Receipt or an VerificationFailure

Direct Known Subclasses

SubscriptionVerification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, package, product_id, token) ⇒ Verification

Initializes a new call to the API

Parameters:

  • client (Client)

    a shared client instance

  • package (String)
  • product_id (String)
  • token (String)


18
19
20
21
22
23
# File 'lib/candy_check/play_store/verification.rb', line 18

def initialize(client, package, product_id, token)
  @client = client
  @package = package
  @product_id = product_id
  @token = token
end

Instance Attribute Details

#packageString (readonly)

Returns the package which will be queried.

Returns:

  • (String)

    the package which will be queried



7
8
9
# File 'lib/candy_check/play_store/verification.rb', line 7

def package
  @package
end

#product_idString (readonly)

Returns the item id which will be queried.

Returns:

  • (String)

    the item id which will be queried



9
10
11
# File 'lib/candy_check/play_store/verification.rb', line 9

def product_id
  @product_id
end

#tokenString (readonly)

Returns the token for authentication.

Returns:

  • (String)

    the token for authentication



11
12
13
# File 'lib/candy_check/play_store/verification.rb', line 11

def token
  @token
end

Instance Method Details

#call!Receipt, VerificationFailure

Performs the verification against the remote server

Returns:



28
29
30
31
32
33
34
35
# File 'lib/candy_check/play_store/verification.rb', line 28

def call!
  verify!
  if valid?
    Receipt.new(@response)
  else
    VerificationFailure.new(@response['error'])
  end
end