Class: XeroGateway::Report

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

Defined Under Namespace

Classes: Cell, Row

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.



16
17
18
19
20
21
22
23
24
# File 'lib/xero_gateway/report.rb', line 16

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

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

Instance Attribute Details

#bodyObject Also known as: rows

Returns the value of attribute body.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def body
  @body
end

#column_namesObject

Returns the value of attribute column_names.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def column_names
  @column_names
end

#errorsObject (readonly)

Returns the value of attribute errors.



10
11
12
# File 'lib/xero_gateway/report.rb', line 10

def errors
  @errors
end

#report_dateObject

Returns the value of attribute report_date.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def report_date
  @report_date
end

#report_idObject

Returns the value of attribute report_id.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def report_id
  @report_id
end

#report_nameObject

Returns the value of attribute report_name.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def report_name
  @report_name
end

#report_titlesObject

Returns the value of attribute report_titles.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def report_titles
  @report_titles
end

#report_typeObject

Returns the value of attribute report_type.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def report_type
  @report_type
end

#updated_atObject

Returns the value of attribute updated_at.



11
12
13
# File 'lib/xero_gateway/report.rb', line 11

def updated_at
  @updated_at
end

Class Method Details

.from_xml(report_element) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xero_gateway/report.rb', line 28

def 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 |row|
          report.body << row
        end
    end
  end
  report
end