Permalink
Browse files

Use v1 API for order listing

  • Loading branch information...
1 parent 5a27d25 commit fcafcf4ab51a59007f3bd24a9cf436b2b99779e1 @demonbane demonbane committed Mar 24, 2013
Showing with 9 additions and 9 deletions.
  1. 0 bin/btc
  2. +2 −2 lib/mtgox/client.rb
  3. +2 −2 lib/mtgox/order.rb
  4. +1 −1 spec/fixtures/orders.json
  5. +4 −4 spec/mtgox/client_spec.rb
View
0 bin/btc 100644 → 100755
No changes.
View
@@ -16,7 +16,7 @@ class Client
include MtGox::Connection
include MtGox::Request
- ORDER_TYPES = {sell: 1, buy: 2}
+ ORDER_TYPES = {sell: "ask", buy: "bid"}
INT_MULTIPLIERS = {btc: 100000000, usd: 100000, jpy: 1000}
# Fetch a deposit address
@@ -143,7 +143,7 @@ def balance
# @example
# MtGox.orders
def orders
- parse_orders(post('/api/0/getOrders.php', {})['orders'])
+ parse_orders(post('/api/1/generic/private/orders', {})['return'])
end
# Fetch your open buys
View
@@ -7,8 +7,8 @@ class Order < Offer
def initialize(order={})
self.id = order['oid']
self.date = Time.at(order['date'].to_i)
- self.amount = order['amount'].to_f
- self.price = order['price'].to_f
+ self.amount = order['amount']['value'].to_f
+ self.price = order['price']['value'].to_f
end
end
end
@@ -1 +1 @@
-{"usds":199.9959,"btcs":0.859,"orders":[{"oid":"bddd042c-e837-4a88-a92e-3b7c05e483df","currency":"USD","item":"BTC","type":2,"amount":3,"price":5,"status":1,"dark":0,"date":1309198768,"priority":"1309198768104500"},{"oid":"3b0f10d7-251d-4a1b-ad6d-4f03877b85d1","currency":"USD","item":"BTC","type":2,"amount":0.1,"price":6,"status":1,"dark":0,"date":1309198830,"priority":"1309198830086400"},{"oid":"490a214f-9a30-449f-acb8-780f9046502f","currency":"USD","item":"BTC","type":2,"amount":0.2,"price":7,"status":1,"dark":0,"date":1309198838,"priority":"1309198838630500"},{"oid":"a20329fe-c0d5-4378-b204-79a7800d41e7","currency":"USD","item":"BTC","type":1,"amount":0.2,"price":99,"status":1,"dark":0,"date":1309198820,"priority":"1309198820706100"},{"oid":"7eac0bb4-b07c-42c2-936a-bb0a33ab2f64","currency":"USD","item":"BTC","type":1,"amount":0.659,"price":100,"status":1,"dark":0,"date":1309198722,"priority":"1309198722477200"},{"oid":"c35abb5b-42fc-43be-ad4e-60bfed184440","currency":"USD","item":"BTC","type":1,"amount":0.2,"price":100,"status":0,"dark":0,"date":1309198722,"priority":"1309198722477200"},{"oid":"e24b7470-ea06-4c78-b5d0-0ab12826b626","currency":"USD","item":"BTC","type":1,"amount":0.1,"price":101,"status":0,"dark":0,"date":1309198807,"priority":"1309198807803300"}]}
+{"result":"success","return":[{"oid":"490a214f-9a30-449f-acb8-780f9046502f","currency":"USD","item":"BTC","type":"bid","amount":{"value":"0.20000000","value_int":"20000000","display":"0.20000000\u00a0BTC","display_short":"0.20\u00a0BTC","currency":"BTC"},"effective_amount":{"value":"0.20000000","value_int":"20000000","display":"0.20000000\u00a0BTC","display_short":"0.20\u00a0BTC","currency":"BTC"},"price":{"value":"7.00000","value_int":"700000","display":"$7.00000","display_short":"$7.00","currency":"USD"},"status":"open","date":1309198838,"priority":"1364116780853497","actions":[]},{"oid":"a20329fe-c0d5-4378-b204-79a7800d41e7","currency":"USD","item":"BTC","type":"ask","amount":{"value":"0.20000000","value_int":"20000000","display":"0.20000000\u00a0BTC","display_short":"0.20\u00a0BTC","currency":"BTC"},"effective_amount":{"value":"0.20000000","value_int":"20000000","display":"0.20000000\u00a0BTC","display_short":"0.20\u00a0BTC","currency":"BTC"},"price":{"value":"99.00000","value_int":"9900000","display":"$99.00000","display_short":"$99.00","currency":"USD"},"status":"open","date":1309198820,"priority":"1364118432445268","actions":[]}]}
@@ -158,15 +158,15 @@
describe "order methods" do
before :each do
- stub_post('/api/0/getOrders.php').
+ stub_post('/api/1/generic/private/orders').
with(body: test_body, headers: test_headers).
to_return(status: 200, body: fixture('orders.json'))
end
describe "#buys" do
it "should fetch orders" do
buys = @client.buys
- a_post("/api/0/getOrders.php").
+ a_post("/api/1/generic/private/orders").
with(body: test_body, headers: test_headers).
should have_been_made
buys.last.price.should == 7
@@ -177,7 +177,7 @@
describe "#sells" do
it "should fetch sells" do
sells = @client.sells
- a_post("/api/0/getOrders.php").
+ a_post("/api/1/generic/private/orders").
with(body: test_body, headers: test_headers).
should have_been_made
sells.last.price.should == 99.0
@@ -188,7 +188,7 @@
describe "#orders" do
it "should fetch both buys and sells, with only one call" do
orders = @client.orders
- a_post("/api/0/getOrders.php").
+ a_post("/api/1/generic/private/orders").
with(body: test_body, headers: test_headers).
should have_been_made
orders[:buys].last.price.should == 7.0

0 comments on commit fcafcf4

Please sign in to comment.