Class: Trx::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/trx/http_client.rb

Constant Summary collapse

MAINNET_HOST =
"https://api.trongrid.io"
SHASTA_HOST =
"https://api.shasta.trongrid.io"
NILE_HOST =
"https://nile.trongrid.io"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host = nil, timeout: 10, trongrig_token: nil, headers: {}, raise_error: true) ⇒ HttpClient

Returns a new instance of HttpClient.



9
10
11
12
13
14
15
# File 'lib/trx/http_client.rb', line 9

def initialize(host = nil, timeout: 10, trongrig_token: nil, headers: {}, raise_error: true)
  @host = host
  @timeout = timeout
  @trongrig_token = trongrig_token
  @headers = headers
  @raise_error = raise_error
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/trx/http_client.rb', line 3

def headers
  @headers
end

#hostObject (readonly)

Returns the value of attribute host.



3
4
5
# File 'lib/trx/http_client.rb', line 3

def host
  @host
end

#raise_errorObject (readonly)

Returns the value of attribute raise_error.



3
4
5
# File 'lib/trx/http_client.rb', line 3

def raise_error
  @raise_error
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



3
4
5
# File 'lib/trx/http_client.rb', line 3

def timeout
  @timeout
end

#trongrig_tokenObject (readonly)

Returns the value of attribute trongrig_token.



3
4
5
# File 'lib/trx/http_client.rb', line 3

def trongrig_token
  @trongrig_token
end

Instance Method Details

#perform_command(command, params, method: :post) ⇒ Object



17
18
19
# File 'lib/trx/http_client.rb', line 17

def perform_command(command, params, method: :post)
  connection.public_send(method, command, params).body
end