class MerchantESolutions::Report
Attributes
options[RW]
records[R]
request[R]
Public Class Methods
new(params = {})
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 7 def initialize(params = {}) self.options = parse_params(params) @request = Request.new(request_params) parse_records(request.body) end
Public Instance Methods
report_specific_params()
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 23 def report_specific_params options end
request_params()
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 13 def request_params { dsReportId: report_id, reportType: report_type, includeTridentTranId: true, includePurchaseId: true, includeClientRefNum: true }.merge(report_specific_params) end
Private Instance Methods
parse_out_date(params, type)
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 58 def parse_out_date(params, type) key = "#{type}_date" if date = params.delete(key) || params.delete(key.to_sym) params.merge!({ "#{type}Date.day" => date.day, "#{type}Date.month" => (date.month - 1), "#{type}Date.year" => date.year, }) end end
parse_params(params)
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 51 def parse_params(params) parse_out_date(params, "begin") parse_out_date(params, "end") params end
parse_records(request)
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 44 def parse_records(request) @records = [] CSV.parse(request, headers: true) do |csv| records << record_class.new(csv) end end
record_class()
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 40 def record_class raise "Implement in instances of sub-class" end
report_id()
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 32 def report_id raise "Implement in instances of sub-class" end
report_type()
click to toggle source
# File lib/merchant_e_solutions/report.rb, line 36 def report_type raise "Implement in instances of sub-class" end