class GpWebpay::Http::HttpResponse

Constants

GP_TO_ATTRS_MAPPER

Public Class Methods

from_hash(hash, merchant_number) click to toggle source
# File lib/gp_webpay/http/http_response.rb, line 23
def self.from_hash(hash, merchant_number)
  params = GP_TO_ATTRS_MAPPER.each_with_object({}) do |(k, v), result|
    value = hash[k.to_s] || hash[k.to_sym]
    result[v] = value if value
  end

  params[:add_info] = Hash.from_xml(hash['ADDINFO']) if hash['ADDINFO']

  new(original_response: hash, result_text: params[:result_text], token: params[:token], status: nil,
      pr_code: params[:pr_code], sr_code: params[:sr_code], params: params, merchant_number: merchant_number)
end

Public Instance Methods

valid?() click to toggle source
# File lib/gp_webpay/http/http_response.rb, line 35
def valid?
  GpWebpay::Http::ValidateResult.call(original_response, config)
end