Class: VmaApi::FailureResponse
- Inherits:
-
Object
- Object
- VmaApi::FailureResponse
- Defined in:
- lib/vma_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/vma_api/failure_response.rb', line 5 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
26 27 28 |
# File 'lib/vma_api/failure_response.rb', line 26 def body response.body end |
#error ⇒ Object
18 19 20 |
# File 'lib/vma_api/failure_response.rb', line 18 def error errors.first end |
#errors ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/vma_api/failure_response.rb', line 9 def errors if json? parsed_response = response.parse [PartnerApi::Errors::RequestError.new(code: parsed_response['code'], message: parsed_response['message'])] else [PartnerApi::Errors::RequestError.new(message: "Invalid Response: #{body}")] end end |
#headers ⇒ Object
30 31 32 |
# File 'lib/vma_api/failure_response.rb', line 30 def headers response.headers.to_h end |
#status ⇒ Object
22 23 24 |
# File 'lib/vma_api/failure_response.rb', line 22 def status response.status end |