class PayCertify::Gateway::Response

Constants

APPROVED

Attributes

original_body[RW]
status[RW]

Public Class Methods

new(response) click to toggle source
Calls superclass method
# File lib/paycertify/gateway/response.rb, line 9
def initialize(response)
  self.status = response.status
  self.original_body = Hash.from_xml(response.body)

  super(convert_hash_keys(original_body))
end

Private Instance Methods

convert_hash_keys(value) click to toggle source
# File lib/paycertify/gateway/response.rb, line 21
def convert_hash_keys(value)
  case value
    when Array
      value.map { |v| convert_hash_keys(v) }
      # or `value.map(&method(:convert_hash_keys))`
    when Hash
      Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
    else
      value
   end
end
underscore_key(k) click to toggle source
# File lib/paycertify/gateway/response.rb, line 17
def underscore_key(k)
  k.to_s.underscore.to_sym
end