-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
phone numbers inbound channels endpoint
- Loading branch information
1 parent
863ecb2
commit ee083cb
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
var TelnyxResource = require('../TelnyxResource'); | ||
var utils = require('../utils'); | ||
var telnyxMethod = TelnyxResource.method; | ||
|
||
function transformResponseData(response, telnyx) { | ||
return utils.addResourceToResponseData( | ||
response, | ||
telnyx, | ||
'phoneNumbersInboundChannels', | ||
{ | ||
update: telnyxMethod({ | ||
method: 'PATCH', | ||
path: '', | ||
urlParams: ['channels'], | ||
paramsValues: [response.data.id], | ||
paramsNames: ['channels'], | ||
}), | ||
} | ||
); | ||
} | ||
|
||
module.exports = require('../TelnyxResource').extend({ | ||
path: 'phone_numbers/inbound_channels', | ||
|
||
retrieve: telnyxMethod({ | ||
method: 'GET', | ||
path: '', | ||
urlParams: [], | ||
|
||
transformResponseData: transformResponseData, | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
var utils = require('../../testUtils'); | ||
var telnyx = utils.getTelnyxMock(); | ||
var expect = require('chai').expect; | ||
|
||
var TEST_AUTH_KEY = utils.getUserTelnyxKey(); | ||
|
||
describe('Phone Numbers Inbound Channels', function() { | ||
describe('retrieve', function() { | ||
function responseFn(response) { | ||
expect(response.data).to.include({ | ||
record_type: 'inbound_channels', | ||
}); | ||
} | ||
|
||
it('Sends the correct request', function() { | ||
return telnyx.phoneNumbersInboundChannels.retrieve() | ||
.then(responseFn); | ||
}); | ||
|
||
it('Sends the correct request [with specified auth]', function() { | ||
return telnyx.phoneNumbersInboundChannels.retrieve(TEST_AUTH_KEY) | ||
.then(responseFn) | ||
}); | ||
}); | ||
|
||
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'}); | ||
} | ||
} | ||
|
||
it('Sends the correct request', function() { | ||
return telnyx.phoneNumbersInboundChannels.update({channels: 8}) | ||
.then(responseFn); | ||
}); | ||
it('Sends the correct request [with specified auth]', function() { | ||
return telnyx.phoneNumbersInboundChannels.update({channels: 8}, TEST_AUTH_KEY) | ||
.then(responseFn); | ||
}); | ||
}) | ||
|
||
}); |