Class: FabApi::FailureResponse
- Inherits:
-
Object
- Object
- FabApi::FailureResponse
- Defined in:
- lib/fab_api/failure_response.rb
Instance Method Summary collapse
- #body ⇒ Object
- #error ⇒ Object
- #errors ⇒ Object
- #headers ⇒ Object
-
#initialize(response) ⇒ FailureResponse
constructor
A new instance of FailureResponse.
- #status ⇒ Object
Constructor Details
#initialize(response) ⇒ FailureResponse
Returns a new instance of FailureResponse.
5 6 7 |
# File 'lib/fab_api/failure_response.rb', line 5 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
27 28 29 |
# File 'lib/fab_api/failure_response.rb', line 27 def body response.body end |
#error ⇒ Object
19 20 21 |
# File 'lib/fab_api/failure_response.rb', line 19 def error errors.first end |
#errors ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/fab_api/failure_response.rb', line 9 def errors if response.status.success? response.parse['responseStatus']['errorDetails'].map do |error| PartnerApi::Errors::RequestError.new(code: error['errorCode'], message: error['errorDesc']) end else [PartnerApi::Errors::RequestError.new(message: "Invalid Response: #{body}")] end end |
#headers ⇒ Object
31 32 33 |
# File 'lib/fab_api/failure_response.rb', line 31 def headers response.headers.to_h end |
#status ⇒ Object
23 24 25 |
# File 'lib/fab_api/failure_response.rb', line 23 def status response.status end |