class RubyPsigate::Response

Constants

ACCOUNT_SUCCESS_CODES

Public Class Methods

new(xml_response) click to toggle source
# File lib/ruby_psigate/response.rb, line 61
def initialize(xml_response)
  @xml_response = Crack::XML.parse(xml_response)
end

Public Instance Methods

response() click to toggle source
# File lib/ruby_psigate/response.rb, line 65
def response
  @xml_response["Response"]
end
success?() click to toggle source
# File lib/ruby_psigate/response.rb, line 69
def success?
  return false unless @xml_response
  ACCOUNT_SUCCESS_CODES.include?(self.returncode)
end

Private Instance Methods

find_value_in_hash(input_key, hash) click to toggle source
# File lib/ruby_psigate/response.rb, line 83
def find_value_in_hash(input_key, hash)
  result = nil
  hash.each_pair do |key, value|
    if value.is_a? Hash
      result = find_value_in_hash(input_key, value)
    else
      key = key.downcase.to_sym
      result = value if input_key == key
    end
    
    break unless result.nil?
  end
  result
end
method_missing(name, *args, &block) click to toggle source
# File lib/ruby_psigate/response.rb, line 76
def method_missing(name, *args, &block)
  @result = nil
  name = name.downcase.to_sym
  @result = find_value_in_hash(name, response)
  @result
end