lib/quoinex/quoinex.rb in quoinex-0.1.4 vs lib/quoinex/quoinex.rb in quoinex-0.2.0
- old
+ new
@@ -8,16 +8,20 @@
class API
attr_reader :key,
:secret,
:url
- def initialize(key:, secret:, url: 'https://api.quoine.com/')
+ def initialize(key:, secret:, url: 'https://api.quoine.com')
@key = key
@secret = secret
@url = url
end
+ def crypto_accounts
+ get('/crypto_accounts')
+ end
+
def balances
get('/accounts/balance')
end
def order(id)
@@ -26,32 +30,29 @@
def orders
get('/orders')
end
- def cancel_order(id)
- status = put("/orders/#{id}/cancel")
- return status
+ def products
+ get('/products')
+ end
- if status['responseStatus'] && status['responseStatus']['errorCode']
- error = status['responseStatus']['message']
- error ||= status['responseStatus']
- raise Quoinex::CancelOrderException.new(error)
- end
-
- status
+ def cancel_order(id)
+ put("/orders/#{id}/cancel")
rescue => e
raise Quoinex::CancelOrderException.new(e.message)
end
def create_order(side:, size:, price:, product_id:)
opts = {
- order_type: :limit,
- product_id: product_id,
- side: side,
- quantity: size.to_f.to_s,
- price: price.to_f.to_s,
+ order: {
+ order_type: :limit,
+ product_id: product_id,
+ side: side,
+ quantity: size.to_f.to_s,
+ price: price.to_f.to_s,
+ }
}
order = post('/orders', opts)
if !order['id']
error ||= order
@@ -98,10 +99,10 @@
response.body
end
end
def put(path, opts = {})
- response = RestClient.put("#{@url}#{path}", auth_headers(path))
+ response = RestClient.put("#{@url}#{path}", nil, auth_headers(path))
if !opts[:skip_json]
JSON.parse(response.body)
else
response.body