Class: Trx::HttpClient
- Inherits:
-
Object
- Object
- Trx::HttpClient
- 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
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#raise_error ⇒ Object
readonly
Returns the value of attribute raise_error.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#trongrig_token ⇒ Object
readonly
Returns the value of attribute trongrig_token.
Instance Method Summary collapse
-
#initialize(host = nil, timeout: 10, trongrig_token: nil, headers: {}, raise_error: true) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #perform_command(command, params, method: :post) ⇒ Object
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
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/trx/http_client.rb', line 3 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/trx/http_client.rb', line 3 def host @host end |
#raise_error ⇒ Object (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 |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/trx/http_client.rb', line 3 def timeout @timeout end |
#trongrig_token ⇒ Object (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 |