Class: FreshBooks::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/freshbooks/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_raw) ⇒ Response

Returns a new instance of Response.



6
7
8
9
# File 'lib/freshbooks/response.rb', line 6

def initialize(xml_raw)
  @raw_response = xml_raw
  @doc = REXML::Document.new(xml_raw)
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



3
4
5
# File 'lib/freshbooks/response.rb', line 3

def doc
  @doc
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



4
5
6
# File 'lib/freshbooks/response.rb', line 4

def raw_response
  @raw_response
end

Instance Method Details

#elementsObject



11
12
13
# File 'lib/freshbooks/response.rb', line 11

def elements
  @doc.root.elements
end

#error_msgObject



23
24
25
# File 'lib/freshbooks/response.rb', line 23

def error_msg
  return @doc.root.elements['error'].text
end

#fail?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/freshbooks/response.rb', line 19

def fail?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/freshbooks/response.rb', line 15

def success?
  @doc.root.attributes['status'] == 'ok'
end