jnbt/candy_check

View on GitHub
lib/candy_check/play_store/verification_failure.rb

Summary

Maintainability
A
0 mins
Test Coverage
module CandyCheck
  module PlayStore
    # Represents a failing call against the Google API server
    class VerificationFailure
      include Utils::AttributeReader

      # @return [Hash] the raw attributes returned from the server
      attr_reader :error

      # Initializes a new instance which bases on a JSON result
      # from Google API servers
      # @param error [Hash]
      def initialize(error)
        @error = error
      end

      # The code of the failure
      # @return [Integer]
      def code
        Integer(error.status_code)
      rescue StandardError
        -1
      end

      # The message of the failure
      # @return [String]
      def message
        error.message || "Unknown error"
      end
    end
  end
end