Skip to content

Commit

Permalink
feat(resources): Balance (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Jul 10, 2020
1 parent 3d4b955 commit 46f89f9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/resources/Balance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var TelnyxResource = require('../TelnyxResource');

module.exports = TelnyxResource.extend({
path: 'balance',

retrieve: TelnyxResource.method({
method: 'GET',
})
});
3 changes: 2 additions & 1 deletion lib/telnyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ var resources = {
OtaUpdates: require('./resources/OtaUpdates'),
MobileOperatorNetworks: require('./resources/MobileOperatorNetworks'),
SimCardGroups: require('./resources/SimCardGroups'),
NumberLookup: require('./resources/NumberLookup')
NumberLookup: require('./resources/NumberLookup'),
Balance: require('./resources/Balance'),
};

Telnyx.TelnyxResource = require('./TelnyxResource');
Expand Down
19 changes: 19 additions & 0 deletions test/resources/Balance.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

var telnyx = require('../../testUtils').getTelnyxMock();
var expect = require('chai').expect;

describe('Balance Resource', function() {
describe('retrieve', function() {
it('Sends the correct request', function() {
return telnyx.balance.retrieve()
.then(function(response) {
expect(response.data).to.include({record_type: 'balance'});
expect(response.data).to.have.property('balance');
expect(response.data).to.have.property('available_credit');
expect(response.data).to.have.property('currency');
expect(response.data).to.have.property('credit_limit');
});
});
});
});

0 comments on commit 46f89f9

Please sign in to comment.