Class: Carousel::Response
- Inherits:
-
Object
- Object
- Carousel::Response
- Defined in:
- lib/carousel/response.rb
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(raw_response, type) ⇒ Response
constructor
A new instance of Response.
- #message ⇒ Object
- #parse_response(xml_response) ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(raw_response, type) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/carousel/response.rb', line 6 def initialize(raw_response, type) @raw_response = raw_response @response = parse_response(raw_response) @type = type end |
Instance Attribute Details
#raw_response ⇒ Object
Returns the value of attribute raw_response.
4 5 6 |
# File 'lib/carousel/response.rb', line 4 def raw_response @raw_response end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/carousel/response.rb', line 4 def response @response end |
Instance Method Details
#failure? ⇒ Boolean
12 13 14 |
# File 'lib/carousel/response.rb', line 12 def failure? !success? end |
#message ⇒ Object
28 29 30 |
# File 'lib/carousel/response.rb', line 28 def @response["order"][0]["details"][0] end |
#parse_response(xml_response) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/carousel/response.rb', line 32 def parse_response(xml_response) return nil if xml_response.nil? parsed = XmlSimple.xml_in(xml_response) @kind = parsed.first[0] parsed end |
#status ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/carousel/response.rb', line 20 def status if @kind == "stock" @response.first["status"] else @response[@kind][0]["status"][0] end end |
#success? ⇒ Boolean
16 17 18 |
# File 'lib/carousel/response.rb', line 16 def success? status == "OK" end |