Sha256: 4aa4da880981ec1c7d6a94c016139d110c16986b027632564025c54d3ebc0dfb
Contents?: true
Size: 1.48 KB
Versions: 8
Compression:
Stored size: 1.48 KB
Contents
require 'xeroizer/application_http_proxy' require 'xeroizer/report/base' require 'xeroizer/report/aged_receivables_by_contact' module Xeroizer module Report class Factory extend ActiveSupport::Memoizable include ApplicationHttpProxy attr_reader :application attr_reader :report_type public def initialize(application, report_type) @application = application @report_type = report_type end # Retreive a report with the `options` as a hash containing # valid query-string parameters to pass to the API. def get(options = {}) response_xml = options[:cache_file] ? File.read(options[:cache_file]) : http_get(options) response = Response.parse(response_xml, options) do | response, elements | parse_reports(response, elements) end response.response_items.first # there is is only one end def api_controller_name "Reports/#{report_type}" end def klass begin Xeroizer::Report.const_get(report_type) rescue NameError => ex # use default class Base end end memoize :klass protected def parse_reports(response, elements) elements.each do | element | response.response_items << klass.build_from_node(element, self) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems