Skip to content

Commit be4c810

Browse files
committed
* fix getBalance() to take asset` parameter as string or array
* fix parameters for `move()`
1 parent 59dc698 commit be4c810

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

lib/luno.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ function Luno (keyId, keySecret, options) {
4343
this.port = options.port || 443
4444
this.ca = options.ca
4545
this.pair = options.pair || 'XBTZAR'
46-
if (options.base_account_id && options.counter_account_id) {
47-
this.base_account_id = options.base_account_id
48-
this.counter_account_id = options.counter_account_id
49-
}
5046

5147
this._requestMts = []
5248
this._requestsRefresh = this._requestsRefresh.bind(this)
@@ -235,8 +231,14 @@ Luno.prototype.getMove = function (options, callback) {
235231
return this._request('GET', `/api/1/move`, options, callback)
236232
}
237233

238-
Luno.prototype.move = function (options, callback) {
239-
return this._request('POST', `/api/1/move`, options, callback)
234+
Luno.prototype.move = function (amount, debit_account_id, credit_account_id, options, callback) {
235+
let [params, cb] = defaults({
236+
amount,
237+
debit_account_id,
238+
credit_account_id,
239+
}, options, callback)
240+
241+
return this._request('POST', `/api/1/move`, params, cb)
240242
}
241243

242244
Luno.prototype.listMoves = function (options, callback) {
@@ -319,14 +321,6 @@ Luno.prototype.postLimitOrder = function (type, volume, price, options, callback
319321
pair: this.pair,
320322
}, options, callback)
321323

322-
if (this.base_account_id && !params.base_account_id) {
323-
params.base_account_id = this.base_account_id
324-
}
325-
326-
if (this.counter_account_id && !params.counter_account_id) {
327-
params.counter_account_id = this.counter_account_id
328-
}
329-
330324
return this._request('POST', '/api/1/postorder', params, cb)
331325
}
332326

@@ -345,14 +339,6 @@ Luno.prototype.postMarketOrder = function (type, volume, options, callback) {
345339
pair: this.pair,
346340
}, options, callback)
347341

348-
if (this.base_account_id && !params.base_account_id) {
349-
params.base_account_id = this.base_account_id
350-
}
351-
352-
if (this.counter_account_id && !params.counter_account_id) {
353-
params.counter_account_id = this.counter_account_id
354-
}
355-
356342
return this._request('POST', '/api/1/marketorder', params, cb)
357343
}
358344

@@ -378,8 +364,16 @@ Luno.prototype.getOrderV3 = function (options, callback) {
378364
return this._request('GET', '/api/exchange/3/order', params, cb)
379365
}
380366

381-
Luno.prototype.getBalance = function (assets = [], callback) {
382-
let params = assets.length > 0 ? { assets } : null
367+
Luno.prototype.getBalance = function (asset, callback) {
368+
let params = null
369+
if (typeof asset === 'string') {
370+
params = { assets: [asset] }
371+
}
372+
373+
if (Array.isArray(asset)) {
374+
params = { assets: asset }
375+
}
376+
383377
return this._request('GET', `/api/1/balance`, params, callback)
384378
}
385379

0 commit comments

Comments
 (0)