http: get account.

This commit is contained in:
Christopher Jeffrey 2016-08-16 13:39:14 -07:00
parent 70684d37c3
commit bd9a41dcbe
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 27 additions and 2 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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);
};
/**