Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,25 @@ function Coinbase (options) {

post(url, options, callback);
};

/* GET /api/v1/accounts/ */
this.accounts = function (callback) {
var url = self.baseUrl + 'accounts';

log('get ' + url);

get(url, callback);
};

/* GET /api/v1/accounts/:account_id/balance */
this.accounts.balance = function (account_id,callback) {
var url = self.baseUrl + 'accounts/'+account_id+'/balance';

log('get ' + url);

get(url, callback);
};

this.buttons = {};
/* POST https://coinbase.com/api/v1/buttons */
this.buttons.create = function (param, callback) {
Expand Down
25 changes: 25 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var Coinbase = require('../lib/index');

if (!process.env.COINBASE_API_KEY) throw new Error('You must specify a COINBASE_API_KEY environment variable to run tests');
if (!process.env.COINBASE_API_SECRET) throw new Error('You must specify a COINBASE_API_SECRET environment variable to run tests');
if (!process.env.COINBASE_ACCOUNT_ID) throw new Error('You must specify a COINBASE_ACCOUNT_ID environment variable to run tests');

var coinbase = new Coinbase({
APIKey: process.env.COINBASE_API_KEY,
Expand Down Expand Up @@ -75,6 +76,30 @@ describe('coinbase.account.generateReceiveAddress', function () {
});
});
});
describe('coinbase.accounts', function () {
it('should return the user\'s accounts', function (done) {
coinbase.accounts(function (err, data) {
if (err) return done(err);
log('data: ' + util.inspect(data, null, 5));
data.should.have.property('accounts');
data.should.have.property('total_count');
data.should.have.property('num_pages');
data.should.have.property('current_page');
done();
});
});
});
describe('coinbase.accounts.balance', function () {
it('should return the user\'s account balance', function (done) {
coinbase.accounts.balance(process.env.COINBASE_ACCOUNT_ID, function (err, data) {
if (err) return done(err);
log('data: ' + util.inspect(data, null, 5));
data.should.have.property('amount');
data.should.have.property('currency');
done();
});
});
});
describe('coinbase.button', function () {
it('should generate a new button', function (done) {
var param = {
Expand Down