Skip to content

Commit

Permalink
add support to Sim Cards Enable/Disable method
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Jul 22, 2020
1 parent 24fef8e commit 7ae4c72
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
20 changes: 18 additions & 2 deletions lib/resources/SimCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,31 @@ function transformResponseData(response, telnyx) {

activate: telnyxMethod({
method: 'POST',
path: '/{sim_card_id}/actions/activate',
path: '/{sim_card_id}/actions/enable',
urlParams: ['sim_card_id'],
paramsValues: [response.data.id],
paramsNames: ['id'],
}),

deactivate: telnyxMethod({
method: 'POST',
path: '/{sim_card_id}/actions/deactivate',
path: '/{sim_card_id}/actions/disable',
urlParams: ['sim_card_id'],
paramsValues: [response.data.id],
paramsNames: ['id'],
}),

enable: telnyxMethod({
method: 'POST',
path: '/{sim_card_id}/actions/enable',
urlParams: ['sim_card_id'],
paramsValues: [response.data.id],
paramsNames: ['id'],
}),

disable: telnyxMethod({
method: 'POST',
path: '/{sim_card_id}/actions/disable',
urlParams: ['sim_card_id'],
paramsValues: [response.data.id],
paramsNames: ['id'],
Expand Down
2 changes: 0 additions & 2 deletions test/resources/NumberReservations.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

'use strict';

var utils = require('../../testUtils');
Expand Down
2 changes: 0 additions & 2 deletions test/resources/PhoneNumberInboundChannels.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe('Phone Numbers Inbound Channels', function() {
describe('update', function() {
function responseFn(response) {
if (response.data) {
// eslint-disable-next-line no-console
console.log('response', response);
expect(response.data).to.include({channels: 7});
expect(response.data).to.include({record_type: 'inbound_channels'});
}
Expand Down
19 changes: 9 additions & 10 deletions test/resources/SimCards.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ var TEST_AUTH_KEY =
'KEY187557EC22404DB39975C43ACE661A58_9QdDI7XD5bvyahtaWx1YQo';

describe('SimCards Resource', function () {
const simCardUpdateData = {
tags: ['personal'],
};


describe('retrieve', function () {
function responseFn(response) {
expect(response.data).to.have.property('id');
Expand Down Expand Up @@ -43,10 +48,6 @@ describe('SimCards Resource', function () {
});

describe('update', function () {
const simCardData = {
status: 'inactive',
};

function responseFn(response) {
expect(response.data).to.have.property('id');
expect(response.data).to.have.property('status');
Expand All @@ -55,12 +56,12 @@ describe('SimCards Resource', function () {
}

it('Sends the correct request', function () {
return telnyx.simCards.update('123', simCardData).then(responseFn);
return telnyx.simCards.update('123', simCardUpdateData).then(responseFn);
});

it('Sends the correct request [with specified auth]', function () {
return telnyx.simCards
.update('123', simCardData, TEST_AUTH_KEY)
.update('123', simCardUpdateData, TEST_AUTH_KEY)
.then(responseFn);
});
});
Expand All @@ -78,7 +79,7 @@ describe('SimCards Resource', function () {
it('Sends the correct request', function () {
return telnyx.simCards.retrieve('123').then(function (response) {
const simCard = response.data;
return simCard.save({status: 'inactive'}).then(responseFn);
return simCard.save(simCardUpdateData).then(responseFn);
});
});
});
Expand All @@ -101,7 +102,7 @@ describe('SimCards Resource', function () {
});
});

['activate', 'deactivate'].forEach(function (command) {
['activate', 'deactivate', 'enable', 'disable'].forEach(function (command) {
function responseFn(response) {
expect(response.data.record_type).to.be.eq('sim_card');
}
Expand Down Expand Up @@ -153,8 +154,6 @@ describe('SimCards Resource', function () {

describe('setNetworkPreferences', function () {
function responseFn(response) {
// eslint-disable-next-line no-console
console.log(response);
expect(response.data.record_type).to.be.eq(
'sim_card_network_preferences'
);
Expand Down

0 comments on commit 7ae4c72

Please sign in to comment.