lib/blockchain-node/client.rb in blockchain-node-0.0.3 vs lib/blockchain-node/client.rb in blockchain-node-0.0.4

- old
+ new

@@ -2,24 +2,28 @@ class Client @@_auth_token AuthToken = Struct.new(:token, :expires_at) - attr_reader :node_id + attr_accessor :node_id attr_accessor :configuration - def initialize(node_id) + def initialize(node_id = nil) @node_id = node_id # allow a different configuration per client instance @configuration = BlockchainNode::Configuration.new end # convenience method to get nodes index def nodes request.get(path: node_index_path, auth_token: auth_token) end + def details + request.get(path: nodes_path, auth_token: auth_token) + end + def auth_token @@_auth_token ||= get_new_auth_token @@_auth_token = get_new_auth_token if auth_token_expired? @@_auth_token.token end @@ -59,9 +63,10 @@ def node_index_path "/api/nodes" end def nodes_path + raise Errors::ClientNotConfigured.new("Client Needs to be initialized with a node id.") unless @node_id "/api/nodes/#{@node_id}" end end end