Class: CandyCheck::PlayStore::ProductPurchases::ProductVerification

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

Overview

Verifies a purchase token against the PlayStore API The call return either a ProductPurchase or a VerificationFailure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_name:, product_id:, token:, authorization:) ⇒ ProductVerification

Initializes a new call to the API

Parameters:

  • package_name (String)
  • product_id (String)
  • token (String)

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

def initialize(package_name:, product_id:, token:, authorization:)
  @package_name = package_name
  @product_id = product_id
  @token = token
  @authorization = authorization
end

Instance Attribute Details

#package_nameString (readonly)

Returns the package_name which will be queried.

Returns:

  • (String)

    the package_name which will be queried


8
9
10
# File 'lib/candy_check/play_store/product_purchases/product_verification.rb', line 8

def package_name
  @package_name
end

#product_idString (readonly)

Returns the item id which will be queried.

Returns:

  • (String)

    the item id which will be queried


10
11
12
# File 'lib/candy_check/play_store/product_purchases/product_verification.rb', line 10

def product_id
  @product_id
end

#tokenString (readonly)

Returns the token for authentication.

Returns:

  • (String)

    the token for authentication


12
13
14
# File 'lib/candy_check/play_store/product_purchases/product_verification.rb', line 12

def token
  @token
end

Instance Method Details

#call!ProductPurchase, VerificationFailure

Performs the verification against the remote server

Returns:


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

def call!
  verify!
  if valid?
    CandyCheck::PlayStore::ProductPurchases::ProductPurchase.new(@response[:result])
  else
    CandyCheck::PlayStore::VerificationFailure.new(@response[:error])
  end
end