Class: Mambu::Response
- Inherits:
-
Object
- Object
- Mambu::Response
- Defined in:
- lib/mambu/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_status ⇒ Object
readonly
Returns the value of attribute error_status.
-
#faraday_response ⇒ Object
readonly
Returns the value of attribute faraday_response.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
Instance Method Summary collapse
- #error ⇒ Object
- #error? ⇒ Boolean
- #error_message ⇒ Object
-
#initialize(faraday_response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(faraday_response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 12 |
# File 'lib/mambu/response.rb', line 5 def initialize(faraday_response) @faraday_response = faraday_response @http_status = faraday_response.status @body = parse_body(faraday_response.body) return self if success? @error_code = @body[:return_code] @error_status = @body[:return_status] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/mambu/response.rb', line 3 def body @body end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
3 4 5 |
# File 'lib/mambu/response.rb', line 3 def error_code @error_code end |
#error_status ⇒ Object (readonly)
Returns the value of attribute error_status.
3 4 5 |
# File 'lib/mambu/response.rb', line 3 def error_status @error_status end |
#faraday_response ⇒ Object (readonly)
Returns the value of attribute faraday_response.
3 4 5 |
# File 'lib/mambu/response.rb', line 3 def faraday_response @faraday_response end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
3 4 5 |
# File 'lib/mambu/response.rb', line 3 def http_status @http_status end |
Instance Method Details
#error ⇒ Object
26 27 28 29 |
# File 'lib/mambu/response.rb', line 26 def error return nil if success? Mambu::Error.new(, error_code, error_status) end |
#error? ⇒ Boolean
18 19 20 |
# File 'lib/mambu/response.rb', line 18 def error? !success? end |
#error_message ⇒ Object
22 23 24 |
# File 'lib/mambu/response.rb', line 22 def error_status.humanize end |
#success? ⇒ Boolean
14 15 16 |
# File 'lib/mambu/response.rb', line 14 def success? @faraday_response.success? end |