Class: Fleakr::Api::Response
- Inherits:
-
Object
- Object
- Fleakr::Api::Response
- Defined in:
- lib/fleakr/api/response.rb
Overview
Response
Response objects contain Hpricot documents that are traversed and parsed by the model objects. This class is never called directly but is instantiated during the request cycle (see: Fleakr::Api::MethodRequest.with_response!)
Instance Method Summary collapse
-
#body ⇒ Object
Return a document-based representation of the XML contained in the API response.
-
#error ⇒ Object
Access the API error if one exists.
-
#error? ⇒ Boolean
Did the response from the API contain errors?.
-
#initialize(response_xml) ⇒ Response
constructor
Creates a new response from a raw XML string returned from a Request.
Constructor Details
#initialize(response_xml) ⇒ Response
Creates a new response from a raw XML string returned from a Request
13 14 15 |
# File 'lib/fleakr/api/response.rb', line 13 def initialize(response_xml) @response_xml = response_xml end |
Instance Method Details
#body ⇒ Object
Return a document-based representation of the XML contained in the API response. This is an Hpricot document object
19 20 21 |
# File 'lib/fleakr/api/response.rb', line 19 def body @body ||= Hpricot.XML(@response_xml) end |
#error ⇒ Object
Access the API error if one exists
29 30 31 |
# File 'lib/fleakr/api/response.rb', line 29 def error Fleakr::Objects::Error.new(self.body) if self.error? end |
#error? ⇒ Boolean
Did the response from the API contain errors?
24 25 26 |
# File 'lib/fleakr/api/response.rb', line 24 def error? (self.body/'rsp').attr('stat') != 'ok' end |