Skip to content

Commit

Permalink
Add resource hosted messaging (#62)
Browse files Browse the repository at this point in the history
* Adding resource and test cases

* Adding resource and test cases

* Delete MessaingHostedNumberOrders.js

Co-authored-by: Quagser <[email protected]>
Co-authored-by: d-telnyx <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2021
1 parent fddd459 commit abbc186
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/resources/MessagingHostedNumberOrders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = require('../TelnyxResource').extend({
path: 'messaging_hosted_number_orders',
includeBasic: ['list', 'retrieve', 'create'],
});
6 changes: 6 additions & 0 deletions lib/resources/MessagingHostedNumbers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = require('../TelnyxResource').extend({
path: 'messaging_hosted_number_orders',
includeBasic: ['del'],
});
2 changes: 2 additions & 0 deletions lib/telnyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var resources = {
AvailablePhoneNumbers: require('./resources/AvailablePhoneNumbers'),
Events: require('./resources/Events'),
Messages: require('./resources/Messages'),
MessagingHostedNumbers: require('./resources/MessagingHostedNumbers'),
MessagingHostedNumberOrders: require('./resources/MessagingHostedNumberOrders'),
MessagingPhoneNumbers: require('./resources/MessagingPhoneNumbers'),
MessagingProfiles: require('./resources/MessagingProfiles'),
MessagingSenderIds: require('./resources/MessagingSenderIds'),
Expand Down
62 changes: 62 additions & 0 deletions test/resources/MessagingHostedNumberOrders.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

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


describe('retrieve', function() {
function responseFn(response) {
expect(response.data).to.include({id: '123'});
}
it('Sends the correct request', function() {
return telnyx.messagingHostedNumberOrders.retrieve('123').then((response) => {
responseFn(response)
});
})
it('Sends the correct request [with specified auth]', function() {
return telnyx.messagingHostedNumberOrders.retrieve('123', TEST_AUTH_KEY)
.then(responseFn);
});
});
describe('create', function() {
function responseFn(response) {
expect(response.data).to.include({
record_type: 'messaging_hosted_number_order',
});
expect(response.data).to.have.property('status');
expect(response.data).to.have.property('id');
}
function responseFnNoBody(response) {
expect(response.data).to.have.property('id');
expect(response.data).to.have.property('requirements_met');
expect(response.data).to.include({record_type: 'messaging_hosted_number_order'});
}
it('Sends the correct request', function() {
return telnyx.messagingHostedNumberOrders.create({messaging_profile_id: '442191469269222625'})
.then(responseFn);
});
it('Sends the correct request [with specified auth]', function() {
return telnyx.messagingHostedNumberOrders.create({messaging_profile_id: '442191469269222625'}, TEST_AUTH_KEY)
.then(responseFn);
});
it('Sends the correct request [with specified auth and no body]', function() {
telnyx.messagingHostedNumberOrders.create(TEST_AUTH_KEY)
.then(responseFnNoBody);
});
});
describe('list', function() {
function responseFn(response) {
expect(response.data[0]).to.have.property('id');
expect(response.data[0]).to.include({record_type: 'messaging_hosted_number_order'});
}
it('Sends the correct request', function() {
return telnyx.messagingHostedNumberOrders.list()
.then(responseFn);
});
it('Sends the correct request [with specified auth]', function() {
return telnyx.messagingHostedNumberOrders.list(TEST_AUTH_KEY)
.then(responseFn);
});
});
20 changes: 20 additions & 0 deletions test/resources/MessagingHostedNumbers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

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

describe('del', function() {

function responseFn(response) {
if (response.data) {
expect(response.data).to.have.property('id');
expect(response.data).to.include({record_type: 'messaging_hosted_numbers'});
}
}
it('Sends the correct request [with specified auth]', function() {
return telnyx.messagingHostedNumbers.del('123')
.then(responseFn);
});
});

0 comments on commit abbc186

Please sign in to comment.