Class: XeroGateway::Report

Inherits:
Object
  • Object
show all
Includes:
Dates, Money
Defined in:
lib/xero_gateway/report.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dates

included

Methods included from Money

included

Constructor Details

#initialize(params = {}) ⇒ Report

Returns a new instance of Report.



10
11
12
13
14
15
16
17
18
# File 'lib/xero_gateway/report.rb', line 10

def initialize(params={})
  @errors         ||= []
  @report_titles  ||= []
  @body           ||= []

  params.each do |k,v|
    self.send("#{k}=", v)
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def body
  @body
end

#column_namesObject

Returns the value of attribute column_names.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def column_names
  @column_names
end

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/xero_gateway/report.rb', line 6

def errors
  @errors
end

#report_dateObject

Returns the value of attribute report_date.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def report_date
  @report_date
end

#report_idObject

Returns the value of attribute report_id.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def report_id
  @report_id
end

#report_nameObject

Returns the value of attribute report_name.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def report_name
  @report_name
end

#report_titlesObject

Returns the value of attribute report_titles.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def report_titles
  @report_titles
end

#report_typeObject

Returns the value of attribute report_type.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def report_type
  @report_type
end

#updated_atObject

Returns the value of attribute updated_at.



7
8
9
# File 'lib/xero_gateway/report.rb', line 7

def updated_at
  @updated_at
end

Class Method Details

.from_xml(report_element) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/xero_gateway/report.rb', line 20

def self.from_xml(report_element)
  report = Report.new
  report_element.children.each do | element |
    case element.name
      when 'ReportID'         then report.report_id = element.text
      when 'ReportName'       then report.report_name = element.text
      when 'ReportType'       then report.report_type = element.text
      when 'ReportTitles'
        each_title(element) do |title|
          report.report_titles << title
        end
      when 'ReportDate'       then report.report_date = Date.parse(element.text)
      when 'UpdatedDateUTC'   then report.updated_at = parse_date_time_utc(element.text)
      when 'Rows'
        report.column_names   ||= find_body_column_names(element)
        each_row_content(element) do |content_hash|
          report.body << OpenStruct.new(content_hash)
        end
    end
  end
  report
end