Class: QuorumSdk::Client
- Inherits:
-
Object
- Object
- QuorumSdk::Client
- Defined in:
- lib/quorum_sdk/client.rb
Overview
HTTP Client wrapper
Instance Attribute Summary collapse
-
#domains ⇒ Object
readonly
Returns the value of attribute domains.
Instance Method Summary collapse
- #get(path, **params) ⇒ Object
-
#initialize(chain_url, jwt = nil) ⇒ Client
constructor
A new instance of Client.
- #post(path, **body) ⇒ Object
Constructor Details
#initialize(chain_url, jwt = nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/quorum_sdk/client.rb', line 8 def initialize(chain_url, jwt = nil) chain_url = case chain_url when Array chain_url.first when String chain_url end uri = Addressable::URI.parse chain_url url = Addressable::URI.new(scheme: uri.scheme, host: uri.host, port: uri.port).to_s jwt ||= uri.query_values['jwt'] @conn = Faraday.new( url:, headers: { Authorization: "Bearer #{jwt}" } ) do |f| f.request :json f.response :json f.response :logger end end |
Instance Attribute Details
#domains ⇒ Object (readonly)
Returns the value of attribute domains.
6 7 8 |
# File 'lib/quorum_sdk/client.rb', line 6 def domains @domains end |
Instance Method Details
#get(path, **params) ⇒ Object
36 37 38 |
# File 'lib/quorum_sdk/client.rb', line 36 def get(path, **params) @conn.get path, **params end |
#post(path, **body) ⇒ Object
32 33 34 |
# File 'lib/quorum_sdk/client.rb', line 32 def post(path, **body) @conn.post path, body.to_json end |