Sha256: dca7b8376f0c9c5ea863e9d8ed46531f5efe3fd100b257b6e898b8d95e0d3160

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

module CandyCheck
  module PlayStore
    module ProductAcknowledgements
      # Verifies a purchase token against the PlayStore API

      class Acknowledgement
        # @return [String] the package_name which will be queried
        attr_reader :package_name
        # @return [String] the item id which will be queried
        attr_reader :product_id
        # @return [String] the token for authentication
        attr_reader :token

        # Initializes a new call to the API
        # @param package_name [String]
        # @param product_id [String]
        # @param token [String]
        def initialize(package_name:, product_id:, token:, authorization:)
          @package_name = package_name
          @product_id = product_id
          @token = token
          @authorization = authorization
        end

        def call!
          acknowledge!

          CandyCheck::PlayStore::ProductAcknowledgements::Response.new(
            result: @response[:result], error_data: @response[:error_data])
        end

        private

        def acknowledge!
          service = CandyCheck::PlayStore::AndroidPublisherService.new

          service.authorization = @authorization
          service.acknowledge_purchase_product(package_name, product_id, token) do |result, error_data|
            @response = { result: result, error_data: error_data }
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
candy_check-0.5.0 lib/candy_check/play_store/product_acknowledgements/acknowledgement.rb
candy_check-0.4.0 lib/candy_check/play_store/product_acknowledgements/acknowledgement.rb
candy_check-0.3.0 lib/candy_check/play_store/product_acknowledgements/acknowledgement.rb