class Xeroizer::Report::Factory

Attributes

application[R]
report_type[R]
response_xml[R]

Public Class Methods

new(application, report_type) click to toggle source
# File lib/xeroizer/report/factory.rb, line 17
def initialize(application, report_type)
  @application = application
  @report_type = report_type
end

Public Instance Methods

api_controller_name() click to toggle source
# File lib/xeroizer/report/factory.rb, line 32
def api_controller_name
  "Reports/#{report_type}"
end
get(options = {}) click to toggle source

Retreive a report with the `options` as a hash containing valid query-string parameters to pass to the API.

# File lib/xeroizer/report/factory.rb, line 24
def get(options = {})
  @response_xml = options[:cache_file] ? File.read(options[:cache_file]) : http_get(options)
  response = Response.parse(response_xml, options) do | inner_response, elements |
    parse_reports(inner_response, elements)
  end
  response.response_items.first # there is is only one
end
klass() click to toggle source
# File lib/xeroizer/report/factory.rb, line 36
def klass
  begin
    @_klass_cache ||= Xeroizer::Report.const_get(report_type, false)
  rescue NameError # use default class
    Base
  end
end

Protected Instance Methods

parse_reports(response, elements) click to toggle source
# File lib/xeroizer/report/factory.rb, line 46
def parse_reports(response, elements)
  elements.each do | element |
    response.response_items << klass.build_from_node(element, self)
  end
end