diff --git a/lib/resources/MessagingHostedNumberOrders.js b/lib/resources/MessagingHostedNumberOrders.js new file mode 100644 index 0000000..3f64ee5 --- /dev/null +++ b/lib/resources/MessagingHostedNumberOrders.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = require('../TelnyxResource').extend({ + path: 'messaging_hosted_number_orders', + includeBasic: ['list', 'retrieve', 'create'], +}); diff --git a/lib/resources/MessagingHostedNumbers.js b/lib/resources/MessagingHostedNumbers.js new file mode 100644 index 0000000..ff09a3d --- /dev/null +++ b/lib/resources/MessagingHostedNumbers.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = require('../TelnyxResource').extend({ + path: 'messaging_hosted_number_orders', + includeBasic: ['del'], +}); diff --git a/lib/telnyx.js b/lib/telnyx.js index 1008820..7093600 100644 --- a/lib/telnyx.js +++ b/lib/telnyx.js @@ -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'), diff --git a/test/resources/MessagingHostedNumberOrders.spec.js b/test/resources/MessagingHostedNumberOrders.spec.js new file mode 100644 index 0000000..57f96a4 --- /dev/null +++ b/test/resources/MessagingHostedNumberOrders.spec.js @@ -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); + }); +}); diff --git a/test/resources/MessagingHostedNumbers.spec.js b/test/resources/MessagingHostedNumbers.spec.js new file mode 100644 index 0000000..42e9e1a --- /dev/null +++ b/test/resources/MessagingHostedNumbers.spec.js @@ -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); + }); +}); +