class Bluepay::Response
bpdailyreport2 returns csv in body bp10emu returns 302, html body, details are in Location header stq returns query string in body
data
returns a unified merge of all the data sources, with tabular data under the key :rows as an array of OpenStruct instances
Constants
- LOCATION
Attributes
action[R]
response[R]
Public Class Methods
new(http)
click to toggle source
# File lib/bluepay/response.rb, line 14 def initialize(http) @response = http end
Public Instance Methods
body()
click to toggle source
# File lib/bluepay/response.rb, line 57 def body response.body end
body_csv()
click to toggle source
# File lib/bluepay/response.rb, line 34 def body_csv require 'csv' CSV.parse(response.body, headers: true) rescue Array.new end
body_params()
click to toggle source
# File lib/bluepay/response.rb, line 22 def body_params URI.decode_www_form(response.body).sort.to_h rescue {} end
body_rows()
click to toggle source
# File lib/bluepay/response.rb, line 39 def body_rows body_csv.each.map {|r| OpenStruct.new(r.to_h)} end
code()
click to toggle source
# File lib/bluepay/response.rb, line 53 def code response.code.to_i end
data()
click to toggle source
# File lib/bluepay/response.rb, line 43 def data params.to_h.merge( rows: body_rows ) end
headers()
click to toggle source
# File lib/bluepay/response.rb, line 61 def headers response.to_hash end
location_query_params()
click to toggle source
# File lib/bluepay/response.rb, line 18 def location_query_params URI.decode_www_form(URI(response['Location']).query).sort.to_h rescue {} end
params()
click to toggle source
# File lib/bluepay/response.rb, line 26 def params location_query_params.merge(body_params).inject({}) { |memo, kv| k, v = kv memo[k.to_s.downcase.to_sym] = v memo } end
to_h()
click to toggle source
# File lib/bluepay/response.rb, line 49 def to_h data end