class Securetrading::Response

Attributes

httparty[R]

Public Class Methods

new(httparty) click to toggle source
# File lib/securetrading/response.rb, line 5
def initialize(httparty)
  @httparty = httparty
end

Public Instance Methods

data() click to toggle source
# File lib/securetrading/response.rb, line 9
def data
  rows.map { |row| Record.new(row) }
end
found() click to toggle source
# File lib/securetrading/response.rb, line 13
def found
  attributes_hash['found'].to_i
end

Private Instance Methods

additional_attributes() click to toggle source
# File lib/securetrading/response.rb, line 33
def additional_attributes
  if responseblock['type'] == 'ERROR'
    {}
  elsif responseblock['response']['type'] == 'TRANSACTIONQUERY'
    @attributes_hash.delete('response')
  else
    { 'record' => @attributes_hash.delete('response'), 'found' => '1' }
  end
end
attributes_hash() click to toggle source
# File lib/securetrading/response.rb, line 27
def attributes_hash
  return @attributes_hash if @attributes_hash.present?
  @attributes_hash = responseblock
  @attributes_hash.merge!(additional_attributes)
end
responseblock() click to toggle source
# File lib/securetrading/response.rb, line 43
def responseblock
  @responseblock ||= @httparty.parsed_response['responseblock']
end
rows() click to toggle source
# File lib/securetrading/response.rb, line 19
def rows
  case found
  when 0 then []
  when 1 then [record]
  else record
  end
end