class SolanaRpcRuby::Response

Response class parses response from the API to the more convenient format.

Public Class Methods

new(response) click to toggle source

Initialize object with response body in json format.

@param response [Hash] hash with response from the API.

# File lib/solana_rpc_ruby/response.rb, line 9
def initialize(response)
  @response = response
end

Public Instance Methods

id() click to toggle source

@return [Integer] matching the request identifier.

# File lib/solana_rpc_ruby/response.rb, line 24
def id
  @id ||= parsed_response['id']
end
json_rpc() click to toggle source

@return [String] matching the request specification.

# File lib/solana_rpc_ruby/response.rb, line 19
def json_rpc
  @json_rpc ||= parsed_response['jsonrpc']
end
parsed_response() click to toggle source

@return [Hash] parsed response body.

# File lib/solana_rpc_ruby/response.rb, line 29
def parsed_response
  @parsed_response ||= JSON.parse(@response.body)
end
result() click to toggle source

@return [Hash] result in the hash.

# File lib/solana_rpc_ruby/response.rb, line 14
def result
  @result ||= parsed_response['result']
end