Class: SolanaRpcRuby::Response

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(response) ⇒ Response

Initialize object with response body in json format.

Parameters:

  • response (Hash)

    hash with response from the API.



9
10
11
# File 'lib/solana_rpc_ruby/response.rb', line 9

def initialize(response)
  @response = response
end

Instance Method Details

#idInteger

Returns matching the request identifier.

Returns:

  • (Integer)

    matching the request identifier.



24
25
26
# File 'lib/solana_rpc_ruby/response.rb', line 24

def id
  @id ||= parsed_response['id']
end

#json_rpcString

Returns matching the request specification.

Returns:

  • (String)

    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_responseHash

Returns parsed response body.

Returns:

  • (Hash)

    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

#resultHash

Returns result in the hash.

Returns:

  • (Hash)

    result in the hash.



14
15
16
# File 'lib/solana_rpc_ruby/response.rb', line 14

def result
  @result ||= parsed_response['result']
end