abucoins 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 8841f5b469f8cbf16d6c2aaf9ffcb6478af0ceb3
4
- data.tar.gz: 9be6658eca93a5ebb3bb86b8c922c29b07724d9e
3
+ metadata.gz: 156916d312b8573e0e95159e4118cadfe7453616
4
+ data.tar.gz: 3c0fa66ec527af7393afd54f4cf6f897158f47b6
5
5
  SHA512:
6
- metadata.gz: 0ab086964bb5ac78a63b0578788781b99a94c4ca218cdfe0ef2f39b254c93c90bde43f9e1c5fb151c37a440529d2a70f6ba1d1d9fec23b884f5e0e00f7dd1737
7
- data.tar.gz: e31d4cc95cff5710070b2da7f5cbe3f57fa4bbbddcfb3fe467f106d46c89024bef42d695ce2fa42d70662d44546865f01466c1948bfd0e02168a5d7b0732dfb4
6
+ metadata.gz: 544aa29696f4e817689dce2b246a1b23af764f17b22bd2dd4180865ab5adab41f152807e5c271ecfdb1f9c0a67190fb8bbcfc8bf65c17d71e97a8d7222464f1c
7
+ data.tar.gz: cc14015ff49f5f36ae7ab8785ad47bbca9bf1dd5fca0ec70913a695a609a0dd6556037f59abe767d5874e5291651e410ee0b2a64eaf65246ad1fc8d042412f1f
@@ -20,14 +20,18 @@ module Abucoins
20
20
  get('/products')
21
21
  end
22
22
 
23
- def orders
24
- get('/orders')
23
+ def orders(args = {})
24
+ get('/orders', params: args)
25
25
  end
26
26
 
27
27
  def order(id)
28
28
  get("/orders/#{id}")
29
29
  end
30
30
 
31
+ def fills
32
+ get('/fills')
33
+ end
34
+
31
35
  def create_order(side:, hidden: false, time_in_force: nil, size:, price:, product_id:, type: 'limit', cancel_after: nil, post_only: nil)
32
36
  opts = {
33
37
  side: side,
@@ -40,7 +44,11 @@ module Abucoins
40
44
  opts[:time_in_force] = time_in_force unless time_in_force.nil?
41
45
  opts[:cancel_after] = cancel_after unless cancel_after.nil?
42
46
  opts[:post_only] = post_only unless post_only.nil?
43
- post('/orders', opts)
47
+ order = post('/orders', opts)
48
+
49
+ raise Abucoins::CreateOrderException.new(order['error'] || order['message']) unless order['id']
50
+
51
+ order
44
52
  end
45
53
 
46
54
  def cancel_order(id)
@@ -60,8 +68,11 @@ module Abucoins
60
68
  Base64.encode64(hmac)
61
69
  end
62
70
 
63
- def get(path, opts={})
64
- response = RestClient.get("#{@url}#{path}", auth_headers(path, 'GET'))
71
+ def get(path, opts = {})
72
+ uri = URI.parse("#{@url}#{path}")
73
+ uri.query = URI.encode_www_form(opts[:params]) if opts[:params]
74
+
75
+ response = RestClient.get(uri.to_s, auth_headers(uri.request_uri, 'GET'))
65
76
 
66
77
  if !opts[:skip_json]
67
78
  JSON.parse(response.body)
@@ -70,7 +81,7 @@ module Abucoins
70
81
  end
71
82
  end
72
83
 
73
- def post(path, payload, opts={})
84
+ def post(path, payload, opts = {})
74
85
  data = JSON.unparse(payload)
75
86
  response = RestClient.post("#{@url}#{path}", data, auth_headers(path, 'POST', data))
76
87
 
@@ -81,7 +92,7 @@ module Abucoins
81
92
  end
82
93
  end
83
94
 
84
- def delete(path, opts={})
95
+ def delete(path, opts = {})
85
96
  response = RestClient.delete("#{@url}#{path}", auth_headers(path, 'DELETE'))
86
97
 
87
98
  if !opts[:skip_json]
@@ -91,7 +102,7 @@ module Abucoins
91
102
  end
92
103
  end
93
104
 
94
- def auth_headers(path, method, body='')
105
+ def auth_headers(path, method, body = '')
95
106
  timestamp = Time.now.utc.to_i
96
107
  sign = signature(timestamp, method, path, body)
97
108
 
@@ -0,0 +1,3 @@
1
+ module Abucoins
2
+ class CreateOrderException < RuntimeError; end
3
+ end
@@ -2,5 +2,5 @@
2
2
  # Primary module for this gem.
3
3
  module Abucoins
4
4
  # Current Abucoins version.
5
- VERSION = '0.1.0'.freeze
5
+ VERSION = '0.2.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abucoins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Fernandez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -270,6 +270,7 @@ files:
270
270
  - lib/.rubocop.yml
271
271
  - lib/abucoins.rb
272
272
  - lib/abucoins/abucoins.rb
273
+ - lib/abucoins/exceptions.rb
273
274
  - lib/abucoins/version.rb
274
275
  - spec/.rubocop.yml
275
276
  - spec/ruby_gem_spec.rb