Class: SolscanApiRuby::Client::Response
- Inherits:
-
Object
- Object
- SolscanApiRuby::Client::Response
- Includes:
- HttpCodes
- Defined in:
- lib/solscan_api_ruby/client/response.rb
Overview
Response class parses response from the API to the more convenient format.
Constant Summary
Constants included from HttpCodes
HttpCodes::HTTP_BAD_REQUEST_CODE, HttpCodes::HTTP_FORBIDDEN_CODE, HttpCodes::HTTP_INTERNAL_SERVER_ERROR, HttpCodes::HTTP_NOT_FOUND_CODE, HttpCodes::HTTP_OK_CODE, HttpCodes::HTTP_UNAUTHORIZED_CODE, HttpCodes::HTTP_UNPROCESSABLE_ENTITY_CODE
Instance Method Summary collapse
-
#body ⇒ Hash
Parsed response body.
-
#headers ⇒ Hash
Response headers.
-
#initialize(response) ⇒ Response
constructor
Initialize object with response body in json format.
-
#status ⇒ Integer
Response status.
-
#successfull? ⇒ Boolean
Response success.
Constructor Details
#initialize(response) ⇒ Response
Initialize object with response body in json format.
15 16 17 |
# File 'lib/solscan_api_ruby/client/response.rb', line 15 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Hash
Returns parsed response body.
20 21 22 23 24 25 |
# File 'lib/solscan_api_ruby/client/response.rb', line 20 def body @body ||= Oj.load(@response.body) rescue Oj::ParseError @response.body end |
#headers ⇒ Hash
Returns response headers.
28 29 30 |
# File 'lib/solscan_api_ruby/client/response.rb', line 28 def headers @response.headers end |
#status ⇒ Integer
Returns response status.
33 34 35 |
# File 'lib/solscan_api_ruby/client/response.rb', line 33 def status @response.status end |
#successfull? ⇒ Boolean
Returns response success.
38 39 40 |
# File 'lib/solscan_api_ruby/client/response.rb', line 38 def successfull? @response.success? end |