Class: Sevendigital::ApiResponse
- Inherits:
-
Object
- Object
- Sevendigital::ApiResponse
- Defined in:
- lib/sevendigital/model/api_response.rb
Overview
Holds the complete API response
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
-
#headers ⇒ Object
Returns the value of attribute headers.
Class Method Summary collapse
Instance Method Summary collapse
- #_dump(depth) ⇒ Object
- #content_xml ⇒ Object
- #item_xml(element_name) ⇒ Object
-
#ok? ⇒ Boolean
True if no API error has been returned.
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/sevendigital/model/api_response.rb', line 6 def content @content end |
#error_code ⇒ Object
Returns the value of attribute error_code.
6 7 8 |
# File 'lib/sevendigital/model/api_response.rb', line 6 def error_code @error_code end |
#error_message ⇒ Object
Returns the value of attribute error_message.
6 7 8 |
# File 'lib/sevendigital/model/api_response.rb', line 6 def @error_message end |
#headers ⇒ Object
Returns the value of attribute headers.
6 7 8 |
# File 'lib/sevendigital/model/api_response.rb', line 6 def headers @headers end |
Class Method Details
._load(properties) ⇒ Object
25 26 27 28 29 |
# File 'lib/sevendigital/model/api_response.rb', line 25 def self._load(properties) response = ApiResponse.new response.error_code, response., response.headers, response.content = Marshal.load(properties) response end |
Instance Method Details
#_dump(depth) ⇒ Object
21 22 23 |
# File 'lib/sevendigital/model/api_response.rb', line 21 def _dump(depth) Marshal.dump([@error_code, @error_message, @headers, @content]) end |
#content_xml ⇒ Object
13 14 15 |
# File 'lib/sevendigital/model/api_response.rb', line 13 def content_xml @content_xml ||= Nokogiri::XML(@content) end |
#item_xml(element_name) ⇒ Object
17 18 19 |
# File 'lib/sevendigital/model/api_response.rb', line 17 def item_xml(element_name) content_xml.at_xpath("./response/#{element_name}") end |
#ok? ⇒ Boolean
True if no API error has been returned
9 10 11 |
# File 'lib/sevendigital/model/api_response.rb', line 9 def ok? (@error_code == 0 && !@content.nil?) end |