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.


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

def initialize(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

Instance Method Details

#elementsObject


9
10
11
# File 'lib/freshbooks/response.rb', line 9

def elements
  @doc.root.elements
end

#error_msgObject


21
22
23
# File 'lib/freshbooks/response.rb', line 21

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

#fail?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/freshbooks/response.rb', line 17

def fail?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)

13
14
15
# File 'lib/freshbooks/response.rb', line 13

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