Class: ArkEcosystem::Client::Connection
- Inherits:
-
Object
- Object
- ArkEcosystem::Client::Connection
- Defined in:
- lib/arkecosystem/client/connection.rb
Overview
The connection used to communicate with the API.
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#accounts ⇒ Object
Return the Accounts API resource.
-
#blocks ⇒ Object
Return the Blocks API resource.
-
#delegates ⇒ Object
Return the Delegates API resource.
-
#initialize(config, client = nil) ⇒ ArkEcosystem::Client::Connection
constructor
Create a new connection instance.
-
#loader ⇒ Object
Return the Loader API resource.
-
#node ⇒ Object
Return the Node API resource.
-
#peers ⇒ Object
Return the Peers API resource.
-
#signatures ⇒ Object
Return the Signatures API resource.
-
#transactions ⇒ Object
Return the Transactions API resource.
-
#votes ⇒ Object
Return the Vptes API resource.
-
#wallets ⇒ Object
Return the Wallets API resource.
Constructor Details
#initialize(config, client = nil) ⇒ ArkEcosystem::Client::Connection
Create a new connection instance.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/arkecosystem/client/connection.rb', line 28 def initialize(config, client = nil) @host = config[:host] @version = config[:version] raise ArgumentError, 'No API host is provided.' if @host.nil? raise ArgumentError, 'No API version is provided.' if @version.nil? if client.nil? # rubocop:disable Style/ConditionalAssignment @client = ArkEcosystem::Client::HTTP::Client.new(config) else @client = client.new(config) end end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
21 22 23 |
# File 'lib/arkecosystem/client/connection.rb', line 21 def client @client end |
Instance Method Details
#accounts ⇒ Object
Return the Accounts API resource.
45 46 47 48 49 50 51 52 |
# File 'lib/arkecosystem/client/connection.rb', line 45 def accounts case @version when 1 @accounts ||= ArkEcosystem::Client::API::One::Accounts.new(@client) else raise NotImplementedError end end |
#blocks ⇒ Object
Return the Blocks API resource.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/arkecosystem/client/connection.rb', line 57 def blocks case @version when 1 @blocks ||= ArkEcosystem::Client::API::One::Blocks.new(@client) when 2 @blocks ||= ArkEcosystem::Client::API::Two::Blocks.new(@client) else raise NotImplementedError end end |
#delegates ⇒ Object
Return the Delegates API resource.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/arkecosystem/client/connection.rb', line 71 def delegates case @version when 1 @delegates ||= ArkEcosystem::Client::API::One::Delegates.new(@client) when 2 @delegates ||= ArkEcosystem::Client::API::Two::Delegates.new(@client) else raise NotImplementedError end end |
#loader ⇒ Object
Return the Loader API resource.
85 86 87 88 89 90 91 92 |
# File 'lib/arkecosystem/client/connection.rb', line 85 def loader case @version when 1 @loader ||= ArkEcosystem::Client::API::One::Loader.new(@client) else raise NotImplementedError end end |
#node ⇒ Object
Return the Node API resource.
97 98 99 100 101 102 103 104 |
# File 'lib/arkecosystem/client/connection.rb', line 97 def node case @version when 2 @node ||= ArkEcosystem::Client::API::Two::Node.new(@client) else raise NotImplementedError end end |
#peers ⇒ Object
Return the Peers API resource.
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/arkecosystem/client/connection.rb', line 109 def peers case @version when 1 @peers ||= ArkEcosystem::Client::API::One::Peers.new(@client) when 2 @peers ||= ArkEcosystem::Client::API::Two::Peers.new(@client) else raise NotImplementedError end end |
#signatures ⇒ Object
Return the Signatures API resource.
123 124 125 126 127 128 129 130 |
# File 'lib/arkecosystem/client/connection.rb', line 123 def signatures case @version when 1 @signatures ||= ArkEcosystem::Client::API::One::Signatures.new(@client) # rubocop:disable Metrics/LineLength else raise NotImplementedError end end |
#transactions ⇒ Object
Return the Transactions API resource.
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/arkecosystem/client/connection.rb', line 135 def transactions case @version when 1 @transactions ||= ArkEcosystem::Client::API::One::Transactions.new(@client) # rubocop:disable Metrics/LineLength when 2 @transactions ||= ArkEcosystem::Client::API::Two::Transactions.new(@client) # rubocop:disable Metrics/LineLength else raise NotImplementedError end end |