Class: SolanaRpcRuby::Response
- Inherits:
-
Object
- Object
- SolanaRpcRuby::Response
- Defined in:
- lib/solana_rpc_ruby/response.rb
Overview
Response class parses response from the API to the more convenient format.
Instance Method Summary collapse
-
#id ⇒ Integer
Matching the request identifier.
-
#initialize(response) ⇒ Response
constructor
Initialize object with response body in json format.
-
#json_rpc ⇒ String
Matching the request specification.
-
#parsed_response ⇒ Hash
Parsed response body.
-
#result ⇒ Hash
Result in the hash.
Constructor Details
#initialize(response) ⇒ Response
Initialize object with response body in json format.
9 10 11 |
# File 'lib/solana_rpc_ruby/response.rb', line 9 def initialize(response) @response = response end |
Instance Method Details
#id ⇒ Integer
Returns matching the request identifier.
24 25 26 |
# File 'lib/solana_rpc_ruby/response.rb', line 24 def id @id ||= parsed_response['id'] end |
#json_rpc ⇒ String
Returns matching the request specification.
19 20 21 |
# File 'lib/solana_rpc_ruby/response.rb', line 19 def json_rpc @json_rpc ||= parsed_response['jsonrpc'] end |
#parsed_response ⇒ Hash
Returns parsed response body.
29 30 31 |
# File 'lib/solana_rpc_ruby/response.rb', line 29 def parsed_response @parsed_response ||= JSON.parse(@response.body) end |
#result ⇒ Hash
Returns result in the hash.
14 15 16 |
# File 'lib/solana_rpc_ruby/response.rb', line 14 def result @result ||= parsed_response['result'] end |