Sha256: 00d2e89ff0366dafa204914d6131583178063bc92f290d1d9528b561ead38fbf

Contents?: true

Size: 814 Bytes

Versions: 11

Compression:

Stored size: 814 Bytes

Contents

module SolanaRpcRuby
  ##
  # Response class parses response from the API to the more convenient format.
  #  
  class Response
    # Initialize object with response body in json format.
    # 
    # @param response [Hash] hash with response from the API.
    def initialize(response)
      @response = response
    end

    # @return [Hash] result in the hash.
    def result
      @result ||= parsed_response['result']
    end

    # @return [String] matching the request specification.
    def json_rpc
      @json_rpc ||= parsed_response['jsonrpc']
    end

    # @return [Integer] matching the request identifier.
    def id
      @id ||= parsed_response['id']
    end

    # @return [Hash] parsed response body.
    def parsed_response
      @parsed_response ||= JSON.parse(@response.body)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
solana_rpc_ruby-1.3.1 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.3.0 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.2.0 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.1.4 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.1.3 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.1.2 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.1.1 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.1.0 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.0.1 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.0.0 lib/solana_rpc_ruby/response.rb
solana_rpc_ruby-1.0.0.pre lib/solana_rpc_ruby/response.rb