Class: Sevendigital::ApiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/sevendigital/model/api_response.rb

Overview

Holds the complete API response

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/sevendigital/model/api_response.rb', line 6

def content
  @content
end

#error_codeObject

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_messageObject

Returns the value of attribute error_message.



6
7
8
# File 'lib/sevendigital/model/api_response.rb', line 6

def error_message
  @error_message
end

#headersObject

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.error_message, 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_xmlObject



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

Returns:

  • (Boolean)


9
10
11
# File 'lib/sevendigital/model/api_response.rb', line 9

def ok?
  (@error_code == 0 && !@content.nil?)
end