Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Commit

Permalink
remove use of deprecated /transfers route
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Hawbaker committed Nov 3, 2017
1 parent 546f88a commit d93f192
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
21 changes: 10 additions & 11 deletions lib/clients/authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
8 changes: 4 additions & 4 deletions tests/authenticated.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});

Expand All @@ -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, {});

Expand Down

0 comments on commit d93f192

Please sign in to comment.