Class: FreshBooks::Response
- Inherits:
-
Object
- Object
- FreshBooks::Response
- Defined in:
- lib/freshbooks/response.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
- #elements ⇒ Object
- #error_msg ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(xml_raw) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
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
#doc ⇒ Object
Returns the value of attribute doc.
3 4 5 |
# File 'lib/freshbooks/response.rb', line 3 def doc @doc end |
#raw_response ⇒ Object (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
#elements ⇒ Object
11 12 13 |
# File 'lib/freshbooks/response.rb', line 11 def elements @doc.root.elements end |
#error_msg ⇒ Object
23 24 25 |
# File 'lib/freshbooks/response.rb', line 23 def error_msg return @doc.root.elements['error'].text end |
#fail? ⇒ Boolean
19 20 21 |
# File 'lib/freshbooks/response.rb', line 19 def fail? !success? end |
#success? ⇒ Boolean
15 16 17 |
# File 'lib/freshbooks/response.rb', line 15 def success? @doc.root.attributes['status'] == 'ok' end |