class Banano::Client
Constants
- DEFAULT_TIMEOUT
- LOCAL_ENDPOINT
Attributes
timeout[RW]
uri[RW]
Public Class Methods
new(uri: LOCAL_ENDPOINT, timeout: DEFAULT_TIMEOUT)
click to toggle source
# File lib/banano/client.rb, line 13 def initialize(uri: LOCAL_ENDPOINT, timeout: DEFAULT_TIMEOUT) @conn = Faraday.new(uri) do |builder| builder.adapter Faraday.default_adapter builder.request :url_encoded builder.options[:open_timeout] = 5 builder.options[:timeout] = timeout builder.headers['Content-Type'] = 'application/json' builder.headers['User-Agent'] = 'Banano RPC Client' builder.response :json, content_type: 'application/json' end end
Public Instance Methods
rpc_call(action:, params: {})
click to toggle source
# File lib/banano/client.rb, line 25 def rpc_call(action:, params: {}) data = {action: action}.merge(params) response = @conn.post do |req| req.body = JSON.dump(data) end Util.symbolize_keys(response.body) end