Class: Silverpop::Response
- Inherits:
-
Object
- Object
- Silverpop::Response
- Defined in:
- lib/silverpop/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#response ⇒ Object
Returns the value of attribute response.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #parse(response) ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/silverpop/response.rb', line 7 def initialize(response) self.parse(response) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/silverpop/response.rb', line 5 def body @body end |
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/silverpop/response.rb', line 5 def errors @errors end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/silverpop/response.rb', line 5 def response @response end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/silverpop/response.rb', line 5 def status @status end |
Instance Method Details
#inspect ⇒ Object
24 25 26 |
# File 'lib/silverpop/response.rb', line 24 def inspect "#<Silverpop::Response status:#{self.status} response=#{self.response.inspect}>" end |
#parse(response) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/silverpop/response.rb', line 11 def parse(response) Silverpop.logger.debug "*** RESPONSE:\n#{response}\n" self.body = REXML::Document.new(response) self.response = { :status => self.body.root.elements['STATUS'][0].value, :error_code => (self.body.root.elements['ERROR_CODE'][0].value rescue nil), :error_string => (self.body.root.elements['ERROR_STRING'][0].value rescue nil) } self.status = self.response[:status].to_i self.errors ||= [] self.errors << {:code => self.response[:error_code], :message => self.response[:error_string]} end |