From d93f1929a20bf9b2f441a37f79d0772d0edee1a5 Mon Sep 17 00:00:00 2001 From: Tim Hawbaker Date: Fri, 3 Nov 2017 15:02:00 -0700 Subject: [PATCH] remove use of deprecated /transfers route --- README.md | 14 +++++++++----- lib/clients/authenticated.js | 21 ++++++++++----------- package.json | 2 +- tests/authenticated.spec.js | 8 ++++---- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ba68bd3d..66136e52 100644 --- a/README.md +++ b/README.md @@ -387,28 +387,32 @@ authedClient.closePosition(params, callback); ```js // Deposit to your Exchange USD account from your Coinbase USD account. const depositParamsUSD = { - 'amount': '100.00', // USD, + 'amount': '100.00', + 'currency': 'USD', 'coinbase_account_id': '60680c98bfe96c2601f27e9c', // USD Coinbase Account ID }; authedClient.deposit(depositParamsUSD, callback); // Withdraw from your Exchange USD account to your Coinbase USD account. const withdrawParamsUSD = { - 'amount': '100.00', // USD, + 'amount': '100.00', + 'currency': 'USD', 'coinbase_account_id': '60680c98bfe96c2601f27e9c', // USD Coinbase Account ID }; authedClient.withdraw(withdrawParamsUSD, callback); // Deposit to your Exchange BTC account from your Coinbase BTC account. const depositParamsBTC = { - 'amount': '2.0', // BTC, + 'amount': '2.0', + 'currency': 'BTC', 'coinbase_account_id': '536a541fa9393bb3c7000023', // BTC Coinbase Account ID }; authedClient.deposit(depositParamsBTC, callback); // Withdraw from your Exchange BTC account to your Coinbase BTC account. const withdrawParamsBTC = { - 'amount': '2.0', // BTC, + 'amount': '2.0', + 'currency': 'BTC', 'coinbase_account_id': '536a541fa9393bb3c7000023', // BTC Coinbase Account ID }; authedClient.withdraw(withdrawParamsBTC, callback); @@ -419,7 +423,7 @@ const withdrawAddressParams = { 'currency': 'BTC', 'crypto_address': '15USXR6S4DhSWVHUxXRCuTkD1SA6qAdy' } -authedClient.withdraw(withdrawAddressParams, callback); +authedClient.withdrawCrypto(withdrawAddressParams, callback); ``` * [`getTrailingVolume`](https://docs.gdax.com/#user-account) diff --git a/lib/clients/authenticated.js b/lib/clients/authenticated.js index 0699e82e..dffd8fb4 100644 --- a/lib/clients/authenticated.js +++ b/lib/clients/authenticated.js @@ -239,23 +239,22 @@ class AuthenticatedClient extends PublicClient { } deposit(params, callback) { - params.type = 'deposit'; - return this._transferFunds(params, callback); + this._requireParams(params, ['amount', 'currency', 'coinbase_account_id']); + return this.post(['deposits/coinbase-account'], { body: params }, callback); } withdraw(params, callback) { - params.type = 'withdraw'; - return this._transferFunds(params, callback); + this._requireParams(params, ['amount', 'currency', 'coinbase_account_id']); + return this.post( + ['withdrawals/coinbase-account'], + { body: params }, + callback + ); } withdrawCrypto(body, callback) { - this._requireParams(body, ['amount', 'currency', 'crypto_address']) - return this.post(['withdrawals/crypto'], { body }, callback) - } - - _transferFunds(params, callback) { - this._requireParams(params, ['type', 'amount', 'coinbase_account_id']); - return this.post(['transfers'], { body: params }, callback); + this._requireParams(body, ['amount', 'currency', 'crypto_address']); + return this.post(['withdrawals/crypto'], { body }, callback); } _requireParams(params, required) { diff --git a/package.json b/package.json index 0111b2ee..e0a1b426 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gdax", - "version": "0.4.4", + "version": "0.5.0", "author": "Coinbase", "bugs": "https://github.com/coinbase/gdax-node/issues", "contributors": [ diff --git a/tests/authenticated.spec.js b/tests/authenticated.spec.js index 6ceb5a6c..d063cfed 100644 --- a/tests/authenticated.spec.js +++ b/tests/authenticated.spec.js @@ -672,14 +672,14 @@ suite('AuthenticatedClient', () => { test('.deposit()', done => { const transfer = { amount: 10480, + currency: 'USD', coinbase_account_id: 'test-id', }; const expectedTransfer = transfer; - expectedTransfer.type = 'deposit'; nock(EXCHANGE_API_URL) - .post('/transfers', expectedTransfer) + .post('/deposits/coinbase-account', expectedTransfer) .times(2) .reply(200, {}); @@ -702,14 +702,14 @@ suite('AuthenticatedClient', () => { test('.withdraw()', done => { const transfer = { amount: 10480, + currency: 'USD', coinbase_account_id: 'test-id', }; const expectedTransfer = transfer; - expectedTransfer.type = 'withdraw'; nock(EXCHANGE_API_URL) - .post('/transfers', expectedTransfer) + .post('/withdrawals/coinbase-account', expectedTransfer) .times(2) .reply(200, {});