Skip to content

Commit

Permalink
Merge 31c2e50 into f84da18
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa authored Dec 17, 2019
2 parents f84da18 + 31c2e50 commit b18b26d
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cache:
env:
global:
# If changing this number, please also look it at tests config.
- TELNYX_MOCK_VERSION=0.6.0
- TELNYX_MOCK_VERSION=0.7.0

before_install:
# Unpack and start telnyx-mock so that the test suite can talk to it
Expand Down
15 changes: 15 additions & 0 deletions lib/resources/NumberOrderDocuments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

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

module.exports = TelnyxResource.extend({
path: 'number_order_documents',
includeBasic: ['list', 'retrieve', 'update'],

upload: telnyxMethod({
method: 'POST',
methodType: 'create',
}),
});

9 changes: 9 additions & 0 deletions lib/resources/PhoneNumberRegulatoryRequirements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

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

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

includeBasic: ['list'],
});
9 changes: 9 additions & 0 deletions lib/resources/RegulatoryRequirements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

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

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

includeBasic: ['list', 'retrieve'],
});
3 changes: 3 additions & 0 deletions lib/telnyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ var resources = {
IpConnections: require('./resources/IpConnections'),
FqdnConnections: require('./resources/FqdnConnections'),
CredentialConnections: require('./resources/CredentialConnections'),
RegulatoryRequirements: require('./resources/RegulatoryRequirements'),
PhoneNumberRegulatoryRequirements: require('./resources/PhoneNumberRegulatoryRequirements'),
NumberOrderDocuments: require('./resources/NumberOrderDocuments'),
Actions: require('./resources/Actions'),
};

Expand Down
97 changes: 97 additions & 0 deletions test/resources/NumberOrderDocuments.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
'use strict';

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

var TEST_AUTH_KEY = 'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';

describe('NumberOrderDocuments Resource', function() {
describe('retrieve', function() {
function responseFn(response) {
expect(response.data).to.include({
id: '387d1e31-a218-4375-8151-103f2d5e2d2c',
record_type: 'number_order_document'
});
expect(response.data).to.have.property('file_id');
expect(response.data).to.have.property('requirements_id');
expect(response.data).to.have.property('requirement_type');
}

it('Sends the correct request', function() {
return telnyx.numberOrderDocuments.retrieve('387d1e31-a218-4375-8151-103f2d5e2d2c')
.then(responseFn);
});

it('Sends the correct request [with specified auth]', function() {
return telnyx.numberOrderDocuments.retrieve(
'387d1e31-a218-4375-8151-103f2d5e2d2c', 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('file_id');
expect(response.data[0]).to.have.property('requirements_id');
expect(response.data[0]).to.have.property('requirement_type');
expect(response.data[0]).to.include({record_type: 'number_order_document'});
}

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

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

describe('update', function() {
it('Sends the correct request', function() {
return telnyx.numberOrderDocuments.update(
'387d1e31-a218-4375-8151-103f2d5e2d2c',
{file_id: '1e3c5822-0362-4702-8e46-5a129f0d3976'}
)
.then(function(response) {
expect(response.data).to.include({
record_type: 'number_order_document',
});
expect(response.data).to.have.property('file_id');
expect(response.data).to.have.property('requirements_id');
expect(response.data).to.have.property('requirement_type');
});
});
});

describe('upload', function() {
function responseFn(response) {
expect(response.data).to.include({
record_type: 'number_order_document',
});
expect(response.data).to.have.property('file_id');
expect(response.data).to.have.property('requirements_id');
expect(response.data).to.have.property('requirement_type');
}

it('Sends the correct request', function() {
return telnyx.numberOrderDocuments.upload({
requirements_id: '36aaf27d-986b-493c-bd1b-de16af2e4292'
})
.then(responseFn);
});

it('Sends the correct request [with specified auth]', function() {
return telnyx.numberOrderDocuments.upload(
{
requirements_id: '36aaf27d-986b-493c-bd1b-de16af2e4292'
},
TEST_AUTH_KEY
)
.then(responseFn);
});
});
});
30 changes: 30 additions & 0 deletions test/resources/PhoneNumbersRegulatoryRequirements.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

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

var TEST_AUTH_KEY = 'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';

describe('PhoneNumberRegulatoryRequirements Resource', function() {
describe('list', function() {
function responseFn(response) {
expect(response.data[0]).to.have.property('phone_number');
expect(response.data[0]).to.have.property('regulatory_group_id');
expect(response.data[0]).to.have.property('regulatory_requirements');
expect(response.data[0]).to.include({record_type: 'phone_number_regulatory_group'});
expect(response.data[0].regulatory_requirements[0]).to.have.property('requirement_type');
expect(response.data[0].regulatory_requirements[0]).to.have.property('label');
expect(response.data[0].regulatory_requirements[0]).to.have.property('field_type');
}

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

it('Sends the correct request [with specified auth]', function() {
return telnyx.phoneNumberRegulatoryRequirements.list(TEST_AUTH_KEY)
.then(responseFn);
});
});
});
44 changes: 44 additions & 0 deletions test/resources/RegulatoryRequirements.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

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

var TEST_AUTH_KEY = 'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';

describe('RegulatoryRequirements Resource', function() {
describe('retrieve', function() {
function responseFn(response) {
expect(response.data).to.have.property('requirement_type');
expect(response.data).to.have.property('label');
expect(response.data).to.have.property('description');
}

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

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

describe('list', function() {
function responseFn(response) {
expect(response.data[0]).to.have.property('requirement_type');
expect(response.data[0]).to.have.property('label');
expect(response.data[0]).to.have.property('description');
}

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

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

0 comments on commit b18b26d

Please sign in to comment.