Skip to content

Commit

Permalink
add Connections Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Jan 30, 2020
1 parent 92b4ee0 commit b52ec44
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/resources/Connections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

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

module.exports = TelnyxResource.extend({
path: 'connections',
includeBasic: ['list', 'retrieve'],
});
1 change: 1 addition & 0 deletions lib/telnyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var resources = {
BillingGroups: require('./resources/BillingGroups'),
Ips: require('./resources/Ips'),
Fqdns: require('./resources/Fqdns'),
Connections: require('./resources/Connections'),
IpConnections: require('./resources/IpConnections'),
FqdnConnections: require('./resources/FqdnConnections'),
CredentialConnections: require('./resources/CredentialConnections'),
Expand Down
41 changes: 41 additions & 0 deletions test/resources/Connections.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

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

var TEST_AUTH_KEY = 'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';

describe('Connections Resource', function() {
describe('retrieve', function() {
function responseFn(response) {
expect(response.data).to.include({id: '123'});
}

it('Sends the correct request', function() {
return telnyx.connections.retrieve('123').then(responseFn);
})

it('Sends the correct request [with specified auth]', function() {
return telnyx.connections.retrieve('123', TEST_AUTH_KEY)
.then(responseFn);
});
});

describe('list', function() {
function responseFn(response) {
expect(response.data[0]).to.have.property('id');
expect(response.data[0]).to.have.property('connection_name');
expect(response.data[0]).to.include({record_type: 'ip_connection'});
}

it('Sends the correct request', function() {
return telnyx.connections.list()
.then(responseFn);
});

it('Sends the correct request [with specified auth]', function() {
return telnyx.connections.list(TEST_AUTH_KEY)
.then(responseFn);
});
});
});

0 comments on commit b52ec44

Please sign in to comment.