Class: Bitcoin::HttpConnection

Inherits:
Client
  • Object
show all
Defined in:
lib/elchapo/bitcoin/http_connection.rb

Constant Summary

Constants inherited from Client

Client::RPC_COMMANDS

Instance Attribute Summary

Attributes inherited from Client

#command, #default_account, #id

Instance Method Summary collapse

Methods inherited from Client

#get_id, #reset_id, #send_command

Constructor Details

#initialize(host, user:, pass:) ⇒ HttpConnection

Returns a new instance of HttpConnection.



7
8
9
10
11
12
13
14
# File 'lib/elchapo/bitcoin/http_connection.rb', line 7

def initialize(host, user:, pass:)
  super()
  @user = user
  @pass = pass
  @url = host

  @header = {'Content-Type' => 'application/json'}
end

Instance Method Details

#send_single(payload) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/elchapo/bitcoin/http_connection.rb', line 16

def send_single(payload)
  resp = RestClient::Request.execute(
    user: @user,
    password: @pass,
    method: :post,
    url: @url,
    payload: payload,
    headers: @header
  )
  return resp
end