http: get account.
This commit is contained in:
parent
70684d37c3
commit
bd9a41dcbe
@ -786,6 +786,18 @@ HTTPClient.prototype.getAccounts = function getAccounts(id, callback) {
|
||||
return this._get(path, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get wallet account.
|
||||
* @param {WalletID} id
|
||||
* @param {String} account
|
||||
* @param {Function} callback - Returns [Error, Array].
|
||||
*/
|
||||
|
||||
HTTPClient.prototype.getAccount = function getAccount(id, account, callback) {
|
||||
var path = '/wallet/' + id + '/account/' + account;
|
||||
return this._get(path, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create account.
|
||||
* @param {WalletID} id
|
||||
|
||||
@ -601,6 +601,19 @@ HTTPServer.prototype._init = function _init() {
|
||||
});
|
||||
});
|
||||
|
||||
// Get account
|
||||
this.get('/wallet/:id/account/:account', function(req, res, next, send) {
|
||||
req.wallet.getAccount(req.options.account, function(err, account) {
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
if (!account)
|
||||
return send(404);
|
||||
|
||||
send(200, account.toJSON());
|
||||
});
|
||||
});
|
||||
|
||||
// Create/get account
|
||||
this.post('/wallet/:id/account/:account?', function(req, res, next, send) {
|
||||
req.wallet.createAccount(req.options, function(err, account) {
|
||||
|
||||
@ -275,8 +275,8 @@ HTTPWallet.prototype.getAccounts = function getAccounts(callback) {
|
||||
* @see Wallet#getAccount
|
||||
*/
|
||||
|
||||
HTTPWallet.prototype.getAccount = function getAccount(options, callback) {
|
||||
return this.client.getAccount(this.id, options, callback);
|
||||
HTTPWallet.prototype.getAccount = function getAccount(account, callback) {
|
||||
return this.client.getAccount(this.id, account, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user