cobinhood 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb26b0d6d0be6237f3973bb89693d6eebb5c600f33e5b0b383e20495ea6a5308
4
- data.tar.gz: 31cb040867b0e5433942268c607433366e17d8bf4da25b59ac8a918d53927e54
3
+ metadata.gz: 4d802d8a32ec4913646aa40dd06e2e9cf0cc3e5350ff14de57b2ca0e589b910e
4
+ data.tar.gz: 88e9cd0cde28ea6f14386622dc799f7765b066085accd8da4642fbaf4fe0f2b3
5
5
  SHA512:
6
- metadata.gz: 856cf4554b437e3e08de2eb2210931c3c43b1057fac494cf386604f09fd9f454ed43588be47f3f278b2e59ea2105d2777262bff164664f5063c2dbbc23072993
7
- data.tar.gz: 627f64273a4ff84f24a4e380794f96c6748057b77edb0128c1aba737ffb89cdea8175d2976aa9cc28888572f2186598ef2677cb0bd85dd631612da986d598164
6
+ metadata.gz: 5551cdcf8bafc74a093adec6003a7f1216c995ba5a2b256323dce210c2c2d8ae6067cb5f3ecb105444c096666a78c1b6895e9940fb1a4aec9f6819341c7221c0
7
+ data.tar.gz: 87c233c3f517e0d7b7e68df968321371811ce1d9cd21e5930baf1f3472897567c34bc934d80cfd38af416f9324c83134b2e332a31b65ebddcb795d231996f080
data/README.md CHANGED
@@ -62,7 +62,7 @@ Create a new instance of the REST Client:
62
62
  client = Cobinhood::Client::REST.new
63
63
 
64
64
  # Otherwise provide an api_key as keyword arguments
65
- client = Cobinhood::Client::REST.new api_key: 'x'
65
+ client = Cobinhood::Client::REST.new api_key: 'your.api_key'
66
66
  ```
67
67
 
68
68
  ALTERNATIVELY, set your API key in exported environment variable:
@@ -134,117 +134,170 @@ of the endpoint's URL and alias method follows the title/name given in Cobinhood
134
134
  where there would otherwise be name clashes/overloading.
135
135
 
136
136
  #### System Endpoints
137
-
138
- name: time
137
+ ----
138
+ ```ruby
139
+ time
140
+ ```
139
141
  * required params: none
140
-
141
- name: info
142
+ ----
143
+ ```ruby
144
+ info
145
+ ```
142
146
  * required params: none
143
147
 
144
148
  #### Market Endpoints
145
-
146
- name: currencies
147
- alias: get_all_currencies
149
+ ----
150
+ ```ruby
151
+ currencies
152
+ ```
153
+ * alias: get_all_currencies
148
154
  * required params: none
149
-
150
- name: trading_pairs
151
- alias: get_all_trading_pairs
155
+ ----
156
+ ```ruby
157
+ trading_pairs
158
+ ```
159
+ * alias: get_all_trading_pairs
152
160
  * required params: none
153
-
154
- name: order_book trading_pair_id
155
- alias: get_order_book
161
+ ----
162
+ ```ruby
163
+ order_book trading_pair_id
164
+ ```
165
+ * alias: get_order_book
156
166
  * required params: trading_pair_id
157
-
158
- name: precisions trading_pair_id
159
- alias: get_order_book_precisions
167
+ ----
168
+ ```ruby
169
+ precisions trading_pair_id
170
+ ```
171
+ * alias: get_order_book_precisions
160
172
  * required params: trading_pair_id
161
-
162
- name: stats
173
+ ----
174
+ ```ruby
175
+ stats
176
+ ```
163
177
  * required params: none
164
-
165
- name: tickers trading_pair_id
166
- alias: get_ticker
178
+ ----
179
+ ```ruby
180
+ tickers trading_pair_id
181
+ ```
182
+ * alias: get_ticker
167
183
  * required params: none
168
-
169
- alias : :market_trades
170
- name: market_trades trading_pair_id
171
- alias: get_recent_trades
184
+ ----
185
+ ```ruby
186
+ market_trades trading_pair_id
187
+ ```
188
+ * alias: get_recent_trades
172
189
  * required params: none
173
190
 
174
191
  #### Chart Endpoints
175
-
176
- name: candles trading_pair_id, options={}
192
+ ----
193
+ ```ruby
194
+ candles trading_pair_id, options={}
195
+ ```
177
196
  * required params: trading_pair_id, timeframe
178
197
 
179
198
  #### Trading Endpoints
180
-
181
- name: order order_id
182
- alias: get_order
199
+ ----
200
+ ```ruby
201
+ order order_id
202
+ ```
203
+ * alias: get_order
183
204
  * required params: order_id
184
-
185
- name: order_trades order_id
186
- alias: get_trades_of_an_order
205
+ ----
206
+ ```ruby
207
+ order_trades order_id
208
+ ```
209
+ * alias: get_trades_of_an_order
187
210
  * required params: order_id
188
-
189
- name: orders
190
- alias: get_all_orders
211
+ ----
212
+ ```ruby
213
+ orders
214
+ ```
215
+ * alias: get_all_orders
191
216
  * required params: none
192
-
193
- name: place_order trading_pair_id, options={}
217
+ ----
218
+ ```ruby
219
+ place_order trading_pair_id, options={}
220
+ ```
194
221
  * required params: side, type, size, price (except market orders)
195
-
196
- name: modify_order order_id, options={}
222
+ ----
223
+ ```ruby
224
+ modify_order order_id, options={}
225
+ ```
197
226
  * required params: order_id, size, price
198
-
199
- name: cancel_order order_id
227
+ ----
228
+ ```ruby
229
+ cancel_order order_id
230
+ ```
200
231
  * required params: order_id
201
-
202
- name: order_history trading_pair_id=nil, options={}
203
- alias: get_order_history
232
+ ----
233
+ ```ruby
234
+ order_history trading_pair_id=nil, options={}
235
+ ```
236
+ * alias: get_order_history
204
237
  * required params: none
205
-
206
- name: get_trade trade_id
207
- alias: trade
238
+ ----
239
+ ```ruby
240
+ get_trade trade_id
241
+ ```
242
+ * alias: trade
208
243
  * required params: trade_id
209
-
210
- name: trades trading_pair_id, options={}
244
+ ----
245
+ ```ruby
246
+ trades trading_pair_id, options={}
247
+ ```
211
248
  * required params: trading_pair_id
212
249
 
213
250
  #### Wallet Endpoints
214
-
215
- name: balances
216
- alias: get_wallet_balances
251
+ ----
252
+ ```ruby
253
+ balances
254
+ ```
255
+ * alias: get_wallet_balances
217
256
  * required params: none
218
-
219
- name: ledger
220
- alias: get_ledger_entries
257
+ ----
258
+ ```ruby
259
+ ledger
260
+ ```
261
+ * alias: get_ledger_entries
221
262
  * required params: none
222
-
223
- name: deposit_addresses
224
- alias: get_deposit_addresses
263
+ ----
264
+ ```ruby
265
+ deposit_addresses
266
+ ```
267
+ * alias: get_deposit_addresses
225
268
  * required params: none
226
-
227
- name: withdrawal_addresses
228
- alias: get_withdrawal_addresses
269
+ ----
270
+ ```ruby
271
+ withdrawal_addresses
272
+ ```
273
+ * alias: get_withdrawal_addresses
229
274
  * required params: none
230
-
231
- name: withdrawal withdrawal_id
232
- alias: get_withdrawal
275
+ ----
276
+ ```ruby
277
+ withdrawal withdrawal_id
278
+ ```
279
+ * alias: get_withdrawal
233
280
  * required params: withdrawal_id
234
-
235
- name: withdrawals
236
- alias: get_all_withdrawals
281
+ ----
282
+ ```ruby
283
+ withdrawals
284
+ ```
285
+ * alias: get_all_withdrawals
237
286
  * required params: none
238
-
239
- name: deposit deposit_id
240
- alias: get_deposit
287
+ ----
288
+ ```ruby
289
+ deposit deposit_id
290
+ ```
291
+ * alias: get_deposit
241
292
  * required params: deposit_id
242
-
243
- name: deposits
244
- alias: get_all_deposits
293
+ ----
294
+ ```ruby
295
+ deposits
296
+ ```
297
+ * alias: get_all_deposits
245
298
  * required params: none
246
299
 
247
- #### WebSocket Client
300
+ ### WebSocket Client
248
301
 
249
302
  * COMING SOON!
250
303
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'faraday'
2
3
  require 'faraday_middleware'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'rest/api_endpoints'
2
3
  require_relative 'rest/nonce_request_middleware'
3
4
  require_relative 'rest/auth_request_middleware'
@@ -9,10 +10,10 @@ require_relative 'rest/trading_api'
9
10
  require_relative 'rest/wallet_api'
10
11
 
11
12
  module Cobinhood
12
- MissingParamError = Class.new(Exception)
13
- InvalidParamError = Class.new(Exception)
14
- MissingApiKeyError = Class.new(Exception)
15
- ClientError = Class.new(Exception)
13
+ MissingParamError = Class.new(StandardError)
14
+ InvalidParamError = Class.new(StandardError)
15
+ MissingApiKeyError = Class.new(StandardError)
16
+ ClientError = Class.new(StandardError)
16
17
 
17
18
  module Client
18
19
  # Public: Client with methods mirroring the Cobinhood REST APIs
@@ -62,7 +63,7 @@ module Cobinhood
62
63
  def public_client adapter
63
64
  Faraday.new(url: BASE_URL) do |conn|
64
65
  conn.request :json
65
- conn.response :json, content_type: /\bjson$/
66
+ conn.response :json, content_type: /\bjson\z/
66
67
  conn.use NonceRequestMiddleware
67
68
  conn.adapter adapter
68
69
  end
@@ -71,7 +72,7 @@ module Cobinhood
71
72
  def auth_client api_key, adapter
72
73
  Faraday.new(url: BASE_URL) do |conn|
73
74
  conn.request :json
74
- conn.response :json, content_type: /\bjson$/
75
+ conn.response :json, content_type: /\bjson\z/
75
76
  conn.use NonceRequestMiddleware
76
77
  conn.use AuthRequestMiddleware, api_key
77
78
  conn.adapter adapter
@@ -91,13 +92,13 @@ module Cobinhood
91
92
  # Each endpoint will have their own required and optional
92
93
  # params.
93
94
  def request api, method, endpoint, options = {}
94
- response = @library[api].send(method) do |req|
95
+ response = @library[api].public_send(method) do |req|
95
96
 
96
97
  # substitute path parameters and remove from options hash
97
98
  endpoint_url = API_ENDPOINTS[api][endpoint].dup
98
99
  options.each do |option, value|
99
- path_param = Regexp.new(":#{option}")
100
- if endpoint_url =~ path_param
100
+ path_param = /":#{option}"/
101
+ if endpoint_url match? path_param
101
102
  options.delete(option)
102
103
  endpoint_url.gsub!(path_param, value)
103
104
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
3
  module Client
3
4
  class REST
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
3
  class AuthRequestMiddleware < Faraday::Middleware
3
4
  def initialize app, api_key
4
5
  super(app)
5
- @api_key = api_key
6
+ @api_key = api_key.to_s
6
7
  end
7
8
 
8
9
  def call env
9
- raise Cobinhood::MissingApiKeyError.new('API KEY not provided') if @api_key.to_s == ''
10
+ raise Cobinhood::MissingApiKeyError.new('API KEY not provided') if @api_key.empty?
10
11
  env[:request_headers]["authorization"] = @api_key
11
12
  @app.call(env)
12
13
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
3
  module Client
3
4
  class REST
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
3
  module Client
3
4
  class REST
@@ -7,22 +8,22 @@ module Cobinhood
7
8
  def currencies
8
9
  request :market, :get, :currencies
9
10
  end
10
- alias :get_all_currencies :currencies
11
+ alias get_all_currencies currencies
11
12
 
12
13
  def trading_pairs
13
14
  request :market, :get, :trading_pairs
14
15
  end
15
- alias :get_all_trading_pairs :trading_pairs
16
+ alias get_all_trading_pairs trading_pairs
16
17
 
17
18
  def order_book trading_pair_id
18
19
  request :market, :get, :order_book, trading_pair_id: trading_pair_id
19
20
  end
20
- alias :get_order_book :order_book
21
+ alias get_order_book order_book
21
22
 
22
23
  def precisions trading_pair_id
23
24
  request :market, :get, :precisions, trading_pair_id: trading_pair_id
24
25
  end
25
- alias :get_order_book_precisions :precisions
26
+ alias get_order_book_precisions precisions
26
27
 
27
28
  def stats
28
29
  request :market, :get, :stats
@@ -31,12 +32,12 @@ module Cobinhood
31
32
  def tickers trading_pair_id
32
33
  request :market, :get, :tickers, trading_pair_id: trading_pair_id
33
34
  end
34
- alias :get_ticker :tickers
35
+ alias get_ticker tickers
35
36
 
36
37
  def market_trades trading_pair_id
37
38
  request :market, :get, :trades, trading_pair_id: trading_pair_id
38
39
  end
39
- alias :get_recent_trades :market_trades
40
+ alias get_recent_trades market_trades
40
41
  end
41
42
  end
42
43
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'date'
2
3
 
3
4
  module Cobinhood
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
3
  module Client
3
4
  class REST
@@ -7,17 +8,17 @@ module Cobinhood
7
8
  def order order_id
8
9
  request :trading, :get, :order, order_id: order_id
9
10
  end
10
- alias :get_order :order
11
+ alias get_order order
11
12
 
12
13
  def order_trades order_id
13
14
  request :trading, :get, :order_trades, order_id: order_id
14
15
  end
15
- alias :get_trades_of_an_order :order_trades
16
+ alias get_trades_of_an_order order_trades
16
17
 
17
18
  def orders
18
19
  request :trading, :get, :orders
19
20
  end
20
- alias :get_all_orders :orders
21
+ alias get_all_orders orders
21
22
 
22
23
  def place_order trading_pair_id, options={}
23
24
  assert_required_param options, :side, sides
@@ -41,12 +42,12 @@ module Cobinhood
41
42
  options.merge!(trading_pair_id: trading_pair_id) unless trading_pair_id.nil?
42
43
  request :trading, :get, :order_history, options
43
44
  end
44
- alias :get_order_history :order_history
45
+ alias get_order_history order_history
45
46
 
46
47
  def get_trade trade_id
47
48
  request :trading, :get, :get_trade, options.merge(trade_id: trade_id)
48
49
  end
49
- alias :trade :get_trade
50
+ alias trade get_trade
50
51
 
51
52
  def trades trading_pair_id, options={}
52
53
  request :trading, :get, :trades, options.merge(trading_pair_id: trading_pair_id)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
3
  module Client
3
4
  class REST
@@ -7,42 +8,42 @@ module Cobinhood
7
8
  def balances
8
9
  request :wallet, :get, :balances
9
10
  end
10
- alias :get_wallet_balances :balances
11
+ alias get_wallet_balances balances
11
12
 
12
13
  def ledger
13
14
  request :wallet, :get, :ledger
14
15
  end
15
- alias :get_ledger_entries :ledger
16
+ alias get_ledger_entries ledger
16
17
 
17
18
  def deposit_addresses
18
19
  request :wallet, :get, :deposit_addresses
19
20
  end
20
- alias :get_deposit_addresses :deposit_addresses
21
+ alias get_deposit_addresses deposit_addresses
21
22
 
22
23
  def withdrawal_addresses
23
24
  request :wallet, :get, :withdrawal_addresses
24
25
  end
25
- alias :get_withdrawal_addresses :withdrawal_addresses
26
+ alias get_withdrawal_addresses withdrawal_addresses
26
27
 
27
28
  def withdrawal withdrawal_id
28
29
  request :wallet, :get, :withdrawal, withdrawal_id: withdrawal_id
29
30
  end
30
- alias :get_withdrawal :withdrawal
31
+ alias get_withdrawal withdrawal
31
32
 
32
33
  def withdrawals
33
34
  request :wallet, :get, :withdrawals
34
35
  end
35
- alias :get_all_withdrawals :withdrawals
36
+ alias get_all_withdrawals withdrawals
36
37
 
37
38
  def deposit deposit_id
38
39
  request :wallet, :get, :deposit, deposit_id: deposit_id
39
40
  end
40
- alias :get_deposit :deposit
41
+ alias get_deposit deposit
41
42
 
42
43
  def deposits
43
44
  request :wallet, :get, :deposits
44
45
  end
45
- alias :get_all_deposits :deposits
46
+ alias get_all_deposits deposits
46
47
  end
47
48
  end
48
49
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cobinhood
2
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobinhood
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-28 00:00:00.000000000 Z
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler