arkecosystem-client 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 958be54c0939a1111806b826bb21b532e07a41e9707c36cef424128a00b1d319
4
- data.tar.gz: dbf364ac0a812da66ec70269d4d63c4241dea8704aa2d21dbede58c9bc941cfe
3
+ metadata.gz: 1f70ae77ecf8dd65bd260536c2ac968f3ecee9d25910354f0227c8a7f4a8fa7d
4
+ data.tar.gz: fb14606479f2acc86924a5d5d0b81adeff3f3df1b66ee640759d0551003dc5f7
5
5
  SHA512:
6
- metadata.gz: 16ead079fddf532ea8643a0e3bab41c193772848e429dfe7b2f6fb405603bf5581924f89dd52d1ffbb42be884babfdf2f7bfd43ac6cfb8a75c713914eed828e4
7
- data.tar.gz: d0cde8bda58261812840860ee16b4b02599f2a0f6241873e350196f14fd827da8b33ec38ca3d25ecd35bd0662b13b651a2f1b5d5b48be872c211b6ee7a8f4e40
6
+ metadata.gz: efa9ba94a614e0084f86a0f3def76195def5514180605ad95be0426b98075a538733f3613ea4bab440ef417aefa0a300775a8b3802215c8fa0005ac1477eae1d
7
+ data.tar.gz: 520f0956e51fbf3539606fcae091c71a643911cec5257de7e686336fdca05b1e6a62ec6d6deeba7ac5711bcc18b9f69b33ad23b4762750ef6218389f8a0e1778
@@ -0,0 +1,47 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Blocks API
7
+ class Blocks < Base
8
+ # Get all blocks.
9
+ #
10
+ # @param parameters [String]
11
+ #
12
+ # @return [Faraday::Response]
13
+ def all(parameters = {})
14
+ @client.get('blocks', parameters)
15
+ end
16
+
17
+ # Get the block by the given id.
18
+ #
19
+ # @param id [String]
20
+ #
21
+ # @return [Faraday::Response]
22
+ def show(id)
23
+ @client.get("blocks/#{id}")
24
+ end
25
+
26
+ # Get the transaction for the given block.
27
+ #
28
+ # @param id [String]
29
+ # @param parameters [Hash]
30
+ #
31
+ # @return [Faraday::Response]
32
+ def transactions(id, parameters = {})
33
+ @client.get("blocks/#{id}/transactions", parameters)
34
+ end
35
+
36
+ # Search all blocks.
37
+ #
38
+ # @param parameters [Hash]
39
+ #
40
+ # @return [Faraday::Response]
41
+ def search(parameters)
42
+ @client.post('blocks/search', parameters)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,48 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Delegates API
7
+ class Delegates < Base
8
+ # Get all delegates.
9
+ #
10
+ # @param parameters [Hash]
11
+ #
12
+ # @return [Faraday::Response]
13
+ def all(parameters = {})
14
+ @client.get('delegates', parameters)
15
+ end
16
+
17
+ # Get the delegate by the given id.
18
+ #
19
+ # @param id [String]
20
+ #
21
+ # @return [Faraday::Response]
22
+ def show(id)
23
+ @client.get("delegates/#{id}")
24
+ end
25
+
26
+ # Get the blocks for the given delegate.
27
+ #
28
+ # @param id [String]
29
+ # @param parameters [Hash]
30
+ #
31
+ # @return [Faraday::Response]
32
+ def blocks(id, parameters = {})
33
+ @client.get("delegates/#{id}/blocks", parameters)
34
+ end
35
+
36
+ # Get the votes for the given delegate.
37
+ #
38
+ # @param id [String]
39
+ # @param parameters [Hash]
40
+ #
41
+ # @return [Faraday::Response]
42
+ def voters(id, parameters = {})
43
+ @client.get("delegates/#{id}/voters", parameters)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,31 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Node API
7
+ class Node < Base
8
+ # Get the loader status.
9
+ #
10
+ # @return [Faraday::Response]
11
+ def status
12
+ @client.get('node/status')
13
+ end
14
+
15
+ # Get the loader syncing status.
16
+ #
17
+ # @return [Faraday::Response]
18
+ def syncing
19
+ @client.get('node/syncing')
20
+ end
21
+
22
+ # Get the loader configuration.
23
+ #
24
+ # @return [Faraday::Response]
25
+ def configuration
26
+ @client.get('node/configuration')
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Peers API
7
+ class Peers < Base
8
+ # Get all peers.
9
+ #
10
+ # @param parameters [Hash]
11
+ #
12
+ # @return [Faraday::Response]
13
+ def all(parameters = {})
14
+ @client.get('peers', parameters)
15
+ end
16
+
17
+ # Get the peer by the given ip.
18
+ #
19
+ # @param ip_addr [String]
20
+ #
21
+ # @return [Faraday::Response]
22
+ def show(ip_addr)
23
+ @client.get("peers/#{ip_addr}")
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,71 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Transactions API
7
+ class Transactions < Base
8
+ # Get all transactions.
9
+ #
10
+ # @param parameters [Hash]
11
+ #
12
+ # @return [Faraday::Response]
13
+ def all(parameters = {})
14
+ @client.get('transactions', parameters)
15
+ end
16
+
17
+ # Create new transactions.
18
+ #
19
+ # @param parameters [Hash]
20
+ #
21
+ # @return [Faraday::Response]
22
+ def create(parameters)
23
+ @client.post('transactions', parameters)
24
+ end
25
+
26
+ # Get the transaction by the given id.
27
+ #
28
+ # @param id [String]
29
+ #
30
+ # @return [Faraday::Response]
31
+ def show(id)
32
+ @client.get("transactions/#{id}")
33
+ end
34
+
35
+ # Get all unconfirmed transactions.
36
+ #
37
+ # @param parameters [Hash]
38
+ #
39
+ # @return [Faraday::Response]
40
+ def all_unconfirmed(parameters = {})
41
+ @client.get('transactions/unconfirmed', parameters)
42
+ end
43
+
44
+ # Get the unconfirmed transaction by the given id.
45
+ #
46
+ # @param id [String]
47
+ #
48
+ # @return [Faraday::Response]
49
+ def show_unconfirmed(id)
50
+ @client.get("transactions/unconfirmed/#{id}")
51
+ end
52
+
53
+ # Search all transactions.
54
+ #
55
+ # @param parameters [Hash]
56
+ #
57
+ # @return [Faraday::Response]
58
+ def search(parameters)
59
+ @client.post('transactions/search', parameters)
60
+ end
61
+
62
+ # Get a list of all transaction types.
63
+ #
64
+ # @return [Faraday::Response]
65
+ def types
66
+ @client.get('transactions/types')
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,28 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Votes API
7
+ class Votes < Base
8
+ # Get all votes.
9
+ #
10
+ # @param parameters [Hash]
11
+ #
12
+ # @return [Faraday::Response]
13
+ def all(parameters = {})
14
+ @client.get('votes', parameters)
15
+ end
16
+
17
+ # Get the vote by the given id.
18
+ #
19
+ # @param id [String]
20
+ #
21
+ # @return [Faraday::Response]
22
+ def show(id)
23
+ @client.get("votes/#{id}")
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,85 @@
1
+ require 'arkecosystem/client/api/base'
2
+
3
+ module ArkEcosystem
4
+ module Client
5
+ module API
6
+ # Methods for the Wallets API
7
+ class Wallets < Base
8
+ # Get all wallets.
9
+ #
10
+ # @param parameters [Hash]
11
+ #
12
+ # @return [Faraday::Response]
13
+ def all(parameters = {})
14
+ @client.get('wallets', parameters)
15
+ end
16
+
17
+ # Get all wallets sorted by balance.
18
+ #
19
+ # @param parameters [Hash]
20
+ #
21
+ # @return [Faraday::Response]
22
+ def top(parameters = {})
23
+ @client.get('wallets/top', parameters)
24
+ end
25
+
26
+ # Get the wallet by the given id.
27
+ #
28
+ # @param id [String]
29
+ #
30
+ # @return [Faraday::Response]
31
+ def show(id)
32
+ @client.get("wallets/#{id}")
33
+ end
34
+
35
+ # Get the transactions for the given wallet.
36
+ #
37
+ # @param id [String]
38
+ # @param parameters [Hash]
39
+ #
40
+ # @return [Faraday::Response]
41
+ def transactions(id, parameters = {})
42
+ @client.get("wallets/#{id}/transactions", parameters)
43
+ end
44
+
45
+ # Get the sent transactions for the given wallet.
46
+ #
47
+ # @param id [String]
48
+ # @param parameters [Hash]
49
+ #
50
+ # @return [Faraday::Response]
51
+ def sent_transactions(id, parameters = {})
52
+ @client.get("wallets/#{id}/transactions/sent", parameters)
53
+ end
54
+
55
+ # Get the received transactions for the given wallet.
56
+ #
57
+ # @param id [String]
58
+ # @param parameters [Hash]
59
+ #
60
+ # @return [Faraday::Response]
61
+ def received_transaction(id, parameters = {})
62
+ @client.get("wallets/#{id}/transactions/received", parameters)
63
+ end
64
+
65
+ # Get the votes for the given wallet.
66
+ #
67
+ # @param if [String]
68
+ #
69
+ # @return [Faraday::Response]
70
+ def votes(id)
71
+ @client.get("wallets/#{id}/votes")
72
+ end
73
+
74
+ # Search all wallets.
75
+ #
76
+ # @param parameters [Hash]
77
+ #
78
+ # @return [Faraday::Response]
79
+ def search(parameters)
80
+ @client.post('wallets/search', parameters)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,18 +1,11 @@
1
1
  require 'arkecosystem/client/http/client'
2
- require 'arkecosystem/client/api/one/accounts'
3
- require 'arkecosystem/client/api/one/blocks'
4
- require 'arkecosystem/client/api/one/delegates'
5
- require 'arkecosystem/client/api/one/loader'
6
- require 'arkecosystem/client/api/one/peers'
7
- require 'arkecosystem/client/api/one/signatures'
8
- require 'arkecosystem/client/api/one/transactions'
9
- require 'arkecosystem/client/api/two/blocks'
10
- require 'arkecosystem/client/api/two/delegates'
11
- require 'arkecosystem/client/api/two/node'
12
- require 'arkecosystem/client/api/two/peers'
13
- require 'arkecosystem/client/api/two/transactions'
14
- require 'arkecosystem/client/api/two/votes'
15
- require 'arkecosystem/client/api/two/wallets'
2
+ require 'arkecosystem/client/api/blocks'
3
+ require 'arkecosystem/client/api/delegates'
4
+ require 'arkecosystem/client/api/node'
5
+ require 'arkecosystem/client/api/peers'
6
+ require 'arkecosystem/client/api/transactions'
7
+ require 'arkecosystem/client/api/votes'
8
+ require 'arkecosystem/client/api/wallets'
16
9
 
17
10
  module ArkEcosystem
18
11
  module Client
@@ -27,10 +20,8 @@ module ArkEcosystem
27
20
  # @return [ArkEcosystem::Client::Connection]
28
21
  def initialize(config, client = nil)
29
22
  @host = config[:host]
30
- @version = config[:version]
31
23
 
32
24
  raise ArgumentError, 'No API host is provided.' if @host.nil?
33
- raise ArgumentError, 'No API version is provided.' if @version.nil?
34
25
 
35
26
  if client.nil? # rubocop:disable Style/ConditionalAssignment
36
27
  @client = ArkEcosystem::Client::HTTP::Client.new(config)
@@ -39,132 +30,53 @@ module ArkEcosystem
39
30
  end
40
31
  end
41
32
 
42
- # Return the Accounts API resource.
43
- #
44
- # @return [Object]
45
- def accounts
46
- case @version
47
- when 1
48
- @accounts ||= ArkEcosystem::Client::API::One::Accounts.new(@client)
49
- else
50
- raise NotImplementedError
51
- end
52
- end
53
-
54
33
  # Return the Blocks API resource.
55
34
  #
56
35
  # @return [Object]
57
36
  def blocks
58
- case @version
59
- when 1
60
- @blocks ||= ArkEcosystem::Client::API::One::Blocks.new(@client)
61
- when 2
62
- @blocks ||= ArkEcosystem::Client::API::Two::Blocks.new(@client)
63
- else
64
- raise NotImplementedError
65
- end
37
+ @blocks ||= ArkEcosystem::Client::API::Blocks.new(@client)
66
38
  end
67
39
 
68
40
  # Return the Delegates API resource.
69
41
  #
70
42
  # @return [Object]
71
43
  def delegates
72
- case @version
73
- when 1
74
- @delegates ||= ArkEcosystem::Client::API::One::Delegates.new(@client)
75
- when 2
76
- @delegates ||= ArkEcosystem::Client::API::Two::Delegates.new(@client)
77
- else
78
- raise NotImplementedError
79
- end
80
- end
81
-
82
- # Return the Loader API resource.
83
- #
84
- # @return [Object]
85
- def loader
86
- case @version
87
- when 1
88
- @loader ||= ArkEcosystem::Client::API::One::Loader.new(@client)
89
- else
90
- raise NotImplementedError
91
- end
44
+ @delegates ||= ArkEcosystem::Client::API::Delegates.new(@client)
92
45
  end
93
46
 
94
47
  # Return the Node API resource.
95
48
  #
96
49
  # @return [Object]
97
50
  def node
98
- case @version
99
- when 2
100
- @node ||= ArkEcosystem::Client::API::Two::Node.new(@client)
101
- else
102
- raise NotImplementedError
103
- end
51
+ @node ||= ArkEcosystem::Client::API::Node.new(@client)
104
52
  end
105
53
 
106
54
  # Return the Peers API resource.
107
55
  #
108
56
  # @return [Object]
109
57
  def peers
110
- case @version
111
- when 1
112
- @peers ||= ArkEcosystem::Client::API::One::Peers.new(@client)
113
- when 2
114
- @peers ||= ArkEcosystem::Client::API::Two::Peers.new(@client)
115
- else
116
- raise NotImplementedError
117
- end
118
- end
119
-
120
- # Return the Signatures API resource.
121
- #
122
- # @return [Object]
123
- def signatures
124
- case @version
125
- when 1
126
- @signatures ||= ArkEcosystem::Client::API::One::Signatures.new(@client) # rubocop:disable Metrics/LineLength
127
- else
128
- raise NotImplementedError
129
- end
58
+ @peers ||= ArkEcosystem::Client::API::Peers.new(@client)
130
59
  end
131
60
 
132
61
  # Return the Transactions API resource.
133
62
  #
134
63
  # @return [Object]
135
64
  def transactions
136
- case @version
137
- when 1
138
- @transactions ||= ArkEcosystem::Client::API::One::Transactions.new(@client) # rubocop:disable Metrics/LineLength
139
- when 2
140
- @transactions ||= ArkEcosystem::Client::API::Two::Transactions.new(@client) # rubocop:disable Metrics/LineLength
141
- else
142
- raise NotImplementedError
143
- end
65
+ @transactions ||= ArkEcosystem::Client::API::Transactions.new(@client) # rubocop:disable Metrics/LineLength
144
66
  end
145
67
 
146
- # Return the Vptes API resource.
68
+ # Return the Votes API resource.
147
69
  #
148
70
  # @return [Object]
149
71
  def votes
150
- case @version
151
- when 2
152
- @votes ||= ArkEcosystem::Client::API::Two::Votes.new(@client)
153
- else
154
- raise NotImplementedError
155
- end
72
+ @votes ||= ArkEcosystem::Client::API::Votes.new(@client)
156
73
  end
157
74
 
158
75
  # Return the Wallets API resource.
159
76
  #
160
77
  # @return [Object]
161
78
  def wallets
162
- case @version
163
- when 2
164
- @wallets ||= ArkEcosystem::Client::API::Two::Wallets.new(@client)
165
- else
166
- raise NotImplementedError
167
- end
79
+ @wallets ||= ArkEcosystem::Client::API::Wallets.new(@client)
168
80
  end
169
81
  end
170
82
  end