Class: Stellae::Response
- Inherits:
-
Object
- Object
- Stellae::Response
- Defined in:
- lib/stellae/response.rb
Constant Summary collapse
- CODES =
{ "0001" => "success", "0002" => "Bad login information", "0003" => "Login points to multiple databases", "0005" => "Invalid order type must be OO or CM", "0006" => "Error creating order header", "0007" => "Bad UPC/EAN13", "0008" => "Duplicate order – order number exists in database", "0009" => "Problem with line item import" }
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#result ⇒ Object
Returns the value of attribute result.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #build_response(raw_response) ⇒ Object
- #error ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(raw_response, type) ⇒ Response
constructor
A new instance of Response.
- #parse_response(xml_response) ⇒ Object
- #raw_status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(raw_response, type) ⇒ Response
Returns a new instance of Response.
17 18 19 20 |
# File 'lib/stellae/response.rb', line 17 def initialize(raw_response, type) build_response(raw_response) @type = type end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
15 16 17 |
# File 'lib/stellae/response.rb', line 15 def response @response end |
#result ⇒ Object
Returns the value of attribute result.
15 16 17 |
# File 'lib/stellae/response.rb', line 15 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
15 16 17 |
# File 'lib/stellae/response.rb', line 15 def status @status end |
Instance Method Details
#build_response(raw_response) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/stellae/response.rb', line 22 def build_response(raw_response) @response ||= { raw: raw_response, parsed: parse_response(raw_response) } end |
#error ⇒ Object
29 30 31 |
# File 'lib/stellae/response.rb', line 29 def error "Stellae::Error - #{status}" end |
#failure? ⇒ Boolean
33 34 35 |
# File 'lib/stellae/response.rb', line 33 def failure? !success? end |
#parse_response(xml_response) ⇒ Object
53 54 55 56 |
# File 'lib/stellae/response.rb', line 53 def parse_response(xml_response) return nil if xml_response.empty? XmlSimple.xml_in(xml_response) end |
#raw_status ⇒ Object
41 42 43 |
# File 'lib/stellae/response.rb', line 41 def raw_status result['status'][0] end |
#success? ⇒ Boolean
49 50 51 |
# File 'lib/stellae/response.rb', line 49 def success? status == 'success' end |