Skip to content

Commit fd40db2

Browse files
authored
Merge pull request #15 from PersephonyAPI/issue/14
Remove callConnectUrl and statusCallbackUrl from api.calls#create
2 parents c4cfe2b + ca234e7 commit fd40db2

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,18 @@ The Persephony Javascript SDK will allow you to easily use the Persephony API in
1515
`yarn add @persephony/sdk`
1616

1717
## Testing your Installation
18-
Test the SDK is working by sending yourself a phone call.
18+
Test the SDK is working by sending yourself a text message.
1919

2020
```javascript
2121
var persephonySDK = require('@persephony/sdk')
2222
var persy = persephonySDK('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'your_auth_token')
2323
var to = 'your_phone_number'
2424
var from = 'a_persephony_phone_number_in_your_account'
2525

26-
persy.api.calls.create(to, from, {callConnectUrl:'https://www.persephony.com/testApp/voice'})
26+
persy.api.messages.create(from, to, 'Welcome to Persephony!')
2727
```
2828

29-
When you run this code you should get a phone call. On answering the call, you should hear a short message ("Thanks for using Persephony!"). This indicates that you've successfully setup your SDK.
30-
31-
`https://www.persephony.com/testApp/voice` contains a small Persephony application. When a request is made to its `/voice` endpoint, it will respond with the following PerCL script, which produces the message you heard.
32-
33-
```json
34-
[{"Say": {"text": "Thanks for using Persephony!"}}]
35-
```
29+
When you run this code you should get a text message. This indicates that you've successfully setup your SDK.
3630

3731
## Documentation
3832
The [Persephony documentation ](https://www.persephony.com/docs) has guides on [getting started](https://www.persephony.com/docs/getting-started) with Persephony, as well as the [API reference](https://www.persephony.com/docs/api), [PerCL reference](https://www.persephony.com/docs/percl), and several useful [tutorials.](https://www.persephony.com/docs/tutorials)

docs/source/api/calls.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ getNextPage(nextPageUri)
4242
:returns: {Promise<oobject>} Returns a promise that resolves to the next page of calls
4343
:throws: Will throw an error on a filed response.
4444

45-
create(to, from, options)
45+
create(to, from, applicationId, options)
4646
^^^^^^^^^^^^^^^^^^^^^^^^^^
4747

4848
Create a new call through the Persephony API.
4949

5050
:to: {string} The number to call out to (DNIS). This can be any valid phone number formatted in E.164 format in Persephony's service area.
5151
:from: {string} The number to call from (ANI). This must be a number purchased from Persephony or a verified phone number owned by the user.
52-
:options: {object} Additional properties to set the behavior of the call to be placed. Must include either :code:`callConnectUrl` or :code:`applicationId`.
52+
:applicationId: {string} The id of the application Persephony should use to handle the phone call.
53+
:[options]: {object} Additional properties to set the behavior of the call to be placed.
5354

5455
:returns: {Promise<object>} returns a promise that resolves to the newly placed call.
5556
:throws: Will throw an error on a failed response.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@persephony/sdk",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "The SDK for the Persephony API",
55
"homepage":"https://www.persephony.com",
66
"bugs":{

src/api/calls/calls.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ function calls (accountId, authToken) {
8686
*
8787
* @param {string} to - The number to call out to (DNIS). This can be any valid phone number formatted in #.164 format in Persephony's service area.
8888
* @param {string} from - The number to call from (ANI). This must be a number purchased from Persephony or a verified phone number owned by the user.
89-
* @param {object} options - Additional properties to set the behavior of the call to be placed. Must include either {@code callConnectUrl} or {@code applicationId}.
89+
* @param {string} applicationId - The Id of the application Persephony should use to handle this phone call.
90+
* @param {object} [options] - Additional properties to set the behavior of the call to be placed.
9091
* @returns {Promise<object>} call - Resolves to the newly placed call
9192
* @throws will throw an error on a failed response
9293
*/
93-
function create (to, from, options) {
94-
return commonPoster(rootUrl, assign({to: to, from: from}, options), 'Could not create call')
94+
function create (to, from, applicationId, options) {
95+
return commonPoster(rootUrl, assign({to: to, from:from, applicationId:applicationId}, options), 'Could not create call')
9596
}
9697

9798
return {

src/api/calls/calls.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,11 @@ describe('calls', function () {
156156
var to = '+14534534345'
157157
var from = '+143453464345'
158158
var applicationId = 'AP2341353452345234523452345234623452346'
159-
var callConnectUrl = 'http://url.com'
160-
var options = {applicationId: applicationId, callConnectUrl: callConnectUrl, statusCallbackUrl: 'http://url.com', sendDigits: '1234#', ifMachine: 'redirect', ifMachineUrl: 'http://redirect.com', timeout: 45}
161-
var expectedBody = {to: to, from: from, applicationId: applicationId, callConnectUrl: callConnectUrl, statusCallbackUrl: options.statusCallbackUrl, sendDigits: options.sendDigits, ifMachine: options.ifMachine, ifMachineUrl: options.ifMachineUrl, timeout: options.timeout}
159+
var options = {sendDigits: '1234#', ifMachine: 'redirect', ifMachineUrl: 'http://redirect.com', timeout: 45}
160+
var expectedBody = {to: to, from: from, applicationId: applicationId, sendDigits: options.sendDigits, ifMachine: options.ifMachine, ifMachineUrl: options.ifMachineUrl, timeout: options.timeout}
162161

163162
expect.assertions(1)
164-
return calls(accountId, authToken).create(to, from, options).then(function () {
163+
return calls(accountId, authToken).create(to, from, applicationId, options).then(function () {
165164
expect(postMock).toHaveBeenCalledWith(accountId, authToken, '/Accounts/' + accountId + '/Calls', expectedBody)
166165
})
167166
})

0 commit comments

Comments
 (0)