Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Merge branch '4.0.0-rc' to main #883

Merged
merged 123 commits into from Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
b375d43
chore: Defaults lazyloading to true (#752)
claudiachua May 19, 2022
052f351
test: migrate to jest for unit tests (#756) (#756)
Jun 2, 2022
9aa1880
test: drop nyc (#757)
Jun 2, 2022
124fa79
feat: generate Twilio.ts file (#754)
Jun 13, 2022
014ac43
feat: generate the subdomain base classes (#769)
Jun 29, 2022
34f61d1
feat: migrate subdomain shortcuts (#752) (#770)
Jun 29, 2022
7871cb7
fix: useragent regrex unit test for RC branch (#774)
claudiachua Jul 13, 2022
0abcabf
chore: refactor exports for top-level domains (#773)
Jul 13, 2022
b4aa058
fix: correct the docker tag syntax for RCs
Jul 27, 2022
39e1c30
fix: add tsconfig and enable export assignment (#776)
Aug 2, 2022
05f55b2
Remove deprecated ConversationGrant
claudiachua Sep 8, 2022
f55e666
Remove deprecated IpMessagingGrant
claudiachua Sep 8, 2022
d413093
chore!: Remove Obsolete Client (#789)
claudiachua Sep 12, 2022
9145df2
chore!: Remove twiml deprecated methods (#788)
claudiachua Sep 13, 2022
7245ef7
chore: drop node versions < 14 (#791)
Sep 16, 2022
242eefd
feat: add support for node 18 (#794)
Sep 22, 2022
5858d38
test: upgrading nock for typescript support (#793)
Sep 23, 2022
0407d2e
chore: replace q with native promises (#796)
Hunga1 Sep 27, 2022
341f720
feat: Build pagination functions (#797)
claudiachua Oct 5, 2022
8bd7e7b
chore: sync with changes to main (#801)
Oct 12, 2022
cc83893
test: Include cluster test (#804)
claudiachua Oct 25, 2022
1ffd30a
Revert "test: Include cluster test (#804)" (#806)
claudiachua Oct 25, 2022
32ec77e
test: Include cluster test again (#807)
claudiachua Oct 25, 2022
ad59b30
chore: yeet lodash (#805)
Oct 26, 2022
7787750
chore: upgrade target to es2020 (#808)
Oct 26, 2022
fc329d6
fix: include babel-config and global install twilio for internal test…
Oct 28, 2022
16d1957
chore: generate latest with twilio-oai-generator (#803)
Oct 28, 2022
d93290e
fix: correct the subdomain names with multiple parts (#811)
Oct 28, 2022
fbab61a
fix: add missing top-level account products (#812)
Oct 31, 2022
b63847a
chore: update sorting
Oct 31, 2022
acf397d
fix: refactor for support of param names with dots (#813)
Nov 1, 2022
6451254
sync with latest release
Nov 1, 2022
6969d88
fix: support nested instance resources using the pathType (#814)
Nov 1, 2022
a2fa0f4
chore: add oauth subdomain
Nov 1, 2022
640a50a
fix: update userInfo filename casing
Nov 2, 2022
4cce57c
fix: serialize objects properly (#815)
Nov 2, 2022
65eddb6
fix: update casing for some mounts and properties (#816)
Nov 3, 2022
d7318d5
chore: pre-work for supporting multi-params
Nov 3, 2022
e50f014
chore: pre-work for supporting nested types
Nov 3, 2022
47d78a3
fix: properly serialize various parameters (#817)
Nov 4, 2022
91dbf22
fix: add missing resource names
Nov 4, 2022
89f0e29
fix: properly handle 'parent params' (#818)
Nov 4, 2022
c7d8bf2
fix: correct import syntax
Nov 4, 2022
2c423aa
chore: make everything prettier (#819)
Nov 7, 2022
f1b1e75
docs: prep for RC release
Nov 7, 2022
290397d
fix: use proper parent resource when prefix not matched (#820)
Nov 7, 2022
a948dc4
misc: publish under 'rc' tag
Nov 8, 2022
f89f179
docs: add commands to install release candidates
Nov 8, 2022
430fe8e
chore: sync up the latest TwiML changes
Nov 8, 2022
428dd5b
docs: add 4.0.0-rc upgrade guide (#822)
Nov 10, 2022
dcfc930
Update UPGRADE.md
Nov 10, 2022
fca75cc
Update UPGRADE.md
Nov 10, 2022
556dcce
chore: sync up with latest changes
Nov 10, 2022
42868dd
docs: update the year in the license
Nov 14, 2022
d015190
fix: correct the GoodData naming
Nov 16, 2022
eacb9b1
chore: sync with latest changes
Nov 16, 2022
174faed
misc: removed unused dependencies (#826)
Hunga1 Nov 18, 2022
3452c03
fix: properly generate response models when there are no instance ope…
Nov 23, 2022
e18440d
fix: give more descriptive error for accountSid init issues (#828)
Nov 28, 2022
4afdc76
docs: add client initialization section (#829)
Nov 28, 2022
e2204f2
docs: fix descriptions with special characters
Nov 29, 2022
4137da8
fix: remove unused models (#830)
Nov 29, 2022
b3dda12
fix: update Sip casing
Nov 29, 2022
3aaf199
[Librarian] Regenerated @ 262cdcd92a729094d792ceac9c0d3fcf895fea3d
twilio-dx Nov 30, 2022
ac1599a
Release 4.0.0-rc.1
twilio-dx Nov 30, 2022
10a9df3
fix: add prepublish step for compiling (#831)
Nov 30, 2022
d2d44d7
[Librarian] Regenerated @ 262cdcd92a729094d792ceac9c0d3fcf895fea3d
twilio-dx Nov 30, 2022
5b1a64c
Release 4.0.0-rc.2
twilio-dx Nov 30, 2022
3ca7396
fix: drop shortcuts for removed preview product
Dec 2, 2022
31420e3
feat: add path param validator (#834)
Dec 5, 2022
2241492
fix: update non-parent path param handling and instance properties (#…
Dec 5, 2022
aed7fda
fix: validate non-string path params (#835)
Dec 6, 2022
d7ae42a
feat: add path param validator (#836)
Dec 6, 2022
4de3300
fix: add response model for UserDefinedMessageSubscription (#837)
Dec 7, 2022
ee02e03
[Librarian] Regenerated @ 964f1611ab7481d828261f49551385a276499e30
twilio-dx Dec 14, 2022
c4d51d0
Release 4.0.0-rc.3
twilio-dx Dec 14, 2022
1466d2e
chore: Convert TwiML to typescript (#838)
claudiachua Dec 14, 2022
8345f7e
chore: rewrite hand-crafted JS files into TS files (#840)
Hunga1 Dec 15, 2022
4dcccb9
chore: removed page namespace from imports and references (#841)
Hunga1 Dec 15, 2022
a9cca90
fix: resolve page payload types (#842)
Dec 15, 2022
522d897
chore: upgrade jsonwebtoken from 8.5.1 to 9.0.0 (#847)
twilio-product-security Dec 27, 2022
0d3fd32
fix: correct many of the v2010 date property types (#843)
Dec 27, 2022
7c2d9b2
chore: touch up request validator (#849)
Dec 28, 2022
4997b21
[Librarian] Regenerated @ 51c4a5ce16a1ee0be09195af47a2ecef0f394be6
twilio-dx Dec 28, 2022
b7a2b71
Release 4.0.0-rc.4
twilio-dx Dec 28, 2022
5e93c13
chore: upgrade GitHub Actions dependencies (#851)
Dec 28, 2022
1ea326a
fix: stringify non-string path param response properties (#854)
Dec 29, 2022
ff81118
chore: add rc branch to test&deploy workflow (#858)
Dec 30, 2022
e445d22
chore: tighten up some of the types (#859)
Dec 30, 2022
799f162
docs: updated the year in the license
Jan 3, 2023
d106139
feat: Include comment in node twiml XML (#856)
claudiachua Jan 3, 2023
1508e52
fix: update SMS messaging parse error (#855)
mariomui Jan 3, 2023
b65a0af
Changes to twilio.ts file for TSDoc (#862)
rakatyal Jan 4, 2023
e8330cb
fix: done only gets called one in each (#861)
mattcole19 Jan 4, 2023
bd2ecf8
feat: add types to Twilio client (#863)
Jan 4, 2023
4f2fa0d
fix: rename the interfaces file for compilation (#868)
Jan 4, 2023
32eb740
TSDoc changes for twiml generated files (#864)
rakatyal Jan 4, 2023
d4a107e
feat: Moving to Typedoc and handcrafted changes (#865)
rakatyal Jan 4, 2023
ea2a89c
TSDoc changes for generated apis (#866)
rakatyal Jan 4, 2023
e7c3545
fix: refactor the instance implementation (#860)
Jan 4, 2023
a71071b
fix: correct the lazy-load typing in the Twilio client (#870)
Jan 4, 2023
eb36bf8
fix: set the correct item type for the transform function (#871)
Jan 5, 2023
92eaef5
chore: set strict mode in tsconfig (#853)
Jan 5, 2023
40ed6a5
chore: Remove signature overloading (#872)
claudiachua Jan 5, 2023
d0f5f2e
[DI-2443] chore: Use Record type (#873)
claudiachua Jan 5, 2023
43ca35f
Making AccessToken Identity required (#875)
rakatyal Jan 6, 2023
727d146
fix: don't support callback as first arg when params are required (#876)
Jan 6, 2023
fec67f4
chore: cleanup CA bundle setting of request client (#877)
Jan 6, 2023
797127e
fix: Handle errors thrown in user callbacks in each (#869)
Hunga1 Jan 6, 2023
51f5ecd
Adding upgrade guide entry for AccessToken change (#880)
rakatyal Jan 10, 2023
ceb1138
fix: resolve tsc errs in handcrafted code (#878)
Jan 11, 2023
1b2b965
[Librarian] Regenerated @ 82775d167bff9b55d1399fe288c2934a02411e8c
twilio-dx Jan 11, 2023
4e19a3e
Release 4.0.0-rc.5
twilio-dx Jan 11, 2023
f9ebda9
docs: update upgrade guide with all v4 changes (#882)
Jan 11, 2023
9ecae5d
feat!: Merge branch '4.0.0-rc' to main
Jan 11, 2023
f3974d7
sync with latest
Jan 11, 2023
efbb061
add missing shortcuts
Jan 11, 2023
2ff6c0e
feat: support passing twiml instances to twiml property (#879)
mattcole19 Jan 12, 2023
e9d30fb
Merge branch '4.0.0-rc' into rc-to-main
Jan 12, 2023
1ee1ddc
sync TwiML changes
Jan 12, 2023
5b22f39
feat: Add auto-retry with exponential backoff (#886)
Hunga1 Jan 13, 2023
dbc581c
Merge branch '4.0.0-rc' into rc-to-main
Jan 13, 2023
176e134
upgrade dev dependencies
Jan 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc.json
Expand Up @@ -117,7 +117,7 @@
],
"quotes": [
2,
"single"
"double"
],
"indent": [
2,
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test-and-deploy.yml
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
node: [ 6, 8, 10, 12, 14, 16, lts/* ]
node: [ 14, 16, 18, lts/* ]
steps:
- name: Checkout twilio-node
uses: actions/checkout@v3
Expand All @@ -33,6 +33,16 @@ jobs:
- name: Run Unit Tests
run: npm run ci

- name: Run Cluster Tests
if: (!github.event.pull_request.head.repo.fork)
env:
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_API_KEY: ${{ secrets.TWILIO_CLUSTER_TEST_API_KEY}}
TWILIO_API_SECRET: ${{ secrets.TWILIO_CLUSTER_TEST_API_KEY_SECRET }}
TWILIO_FROM_NUMBER: ${{ secrets.TWILIO_FROM_NUMBER }}
TWILIO_TO_NUMBER: ${{ secrets.TWILIO_TO_NUMBER }}
run: npm run cluster

- name: SonarCloud Scan
if: ${{ (github.event_name == 'pull_request' || github.ref_type == 'branch') && matrix.node == 'lts/*' && !github.event.pull_request.head.repo.fork }}
uses: SonarSource/sonarcloud-github-action@master
Expand Down
9 changes: 6 additions & 3 deletions .gitignore
@@ -1,4 +1,4 @@
### Logs ###
### Logs ###
logs
*.log

Expand All @@ -14,13 +14,13 @@ pids
node_modules

### Test coverage ###
spec/coverage
coverage

### Custom ignores ###
config.js
.idea

### jsdoc dir ###
### typedoc dir ###
docs

### ide / editors ###
Expand All @@ -29,3 +29,6 @@ docs
### Libraries don't need locks files ###
yarn.lock
package-lock.json

**/.openapi-generator*
dist
2 changes: 1 addition & 1 deletion .jshintrc
Expand Up @@ -44,7 +44,7 @@
"newcap": true,

// Enforce use of single quotation marks for strings.
"quotmark": "single",
"quotmark": "double",

// Enforce placing 'use strict' at the top function scope
"strict": true,
Expand Down
8 changes: 8 additions & 0 deletions .prettierignore
@@ -0,0 +1,8 @@
.github
coverage
dist
docs

babel.config.js
*.md
*.json
8 changes: 5 additions & 3 deletions Dockerfile
@@ -1,4 +1,4 @@
FROM node:12.17
FROM node:14

RUN mkdir /twilio
WORKDIR /twilio
Expand All @@ -8,7 +8,9 @@ ENV NODE_PATH /usr/local/lib/node_modules
COPY lib ./lib
COPY spec ./spec
COPY examples ./examples
COPY index.js .
COPY package* ./
COPY index.ts package.json babel.config.js tsconfig.json ./

RUN npm config set unsafe-perm true # Needed to run prepublish as root.

RUN npm install . --include=dev
RUN npm install -g .
15 changes: 7 additions & 8 deletions Makefile
@@ -1,25 +1,24 @@
.PHONY: test-install install test test-docker docs clean
.PHONY: test-install install test test-docker docs clean prettier

test-install:
npm install --only=dev

install:
@node --version || (echo "Node is not installed, please install Node >= 0.12"; exit 1);
@node --version || (echo "Node is not installed, please install Node >= 14"; exit 1);
rm -f package-lock.json
npm install

test:
npm test

test-docker:
docker build -t twilio/twilio-node .
docker run twilio/twilio-node npm run ci

docs:
npm run jsdoc
npm run typedoc

clean:
rm -rf node_modules
rm -rf node_modules dist

prettier:
npm run prettier

API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5)
CURRENT_TAG=$(shell expr "${GITHUB_TAG}" : ".*-rc.*" >/dev/null && echo "rc" || echo "latest")
Expand Down
2 changes: 2 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Expand Up @@ -12,6 +12,8 @@ Please enter each Issue number you are resolving in your PR after one of the fol
e.g.
Fixes #1
Closes #2

Note: If you made changes to the Request Validation logic, please run `npm run webhook-test` locally and ensure all test cases pass
-->

# Fixes #
Expand Down
44 changes: 32 additions & 12 deletions README.md
Expand Up @@ -19,25 +19,16 @@ The Node library documentation can be found [here][libdocs].

This library supports the following Node.js implementations:

* Node.js 6
* Node.js 8
* Node.js 10
* Node.js 12
* Node.js 14
* Node.js 16
* Node.js 18

TypeScript is supported for TypeScript version 2.9 and above.

## Installation

`npm install twilio` or `yarn add twilio`

### Installing Release Candidates

Or, if you're wanting to install the latest release candidate use:

`npm install twilio@rc` or `yarn add twilio@rc`

## Sample Usage

Check out these [code examples](examples) in JavaScript and TypeScript to get up and running quickly.
Expand All @@ -48,15 +39,44 @@ Check out these [code examples](examples) in JavaScript and TypeScript to get up

If your environment requires SSL decryption, you can set the path to CA bundle in the env var `TWILIO_CA_BUNDLE`.

### Client Initialization
If you invoke any V2010 operations without specifying an account SID, `twilio-node` will automatically use the `TWILIO_ACCOUNT_SID` value that the client was initialized with. This is useful for when you'd like to, for example, fetch resources for your main account but also your subaccount. See below:

```javascript
var accountSid = process.env.TWILIO_ACCOUNT_SID; // Your Account SID from www.twilio.com/console
var authToken = process.env.TWILIO_AUTH_TOKEN; // Your Auth Token from www.twilio.com/console
var subaccountSid = process.env.TWILIO_ACCOUNT_SUBACCOUNT_SID; // Your Subaccount SID from www.twilio.com/console

const client = require('twilio')(accountSid, authToken);
const mainAccountCalls = client.api.v2010.account.calls.list; // SID not specified, so defaults to accountSid
const subaccountCalls = client.api.v2010.account(subaccountSid).calls.list // SID specified as subaccountSid
```

### Lazy Loading

`twilio-node` supports lazy loading required modules for faster loading time. Lazy loading is disabled by default. To enable lazy loading, simply instantiate the Twilio client with the `lazyLoading` flag set to `true`:
`twilio-node` supports lazy loading required modules for faster loading time. Lazy loading is enabled by default. To disable lazy loading, simply instantiate the Twilio client with the `lazyLoading` flag set to `false`:
```javascript
var accountSid = process.env.TWILIO_ACCOUNT_SID; // Your Account SID from www.twilio.com/console
var authToken = process.env.TWILIO_AUTH_TOKEN; // Your Auth Token from www.twilio.com/console

const client = require('twilio')(accountSid, authToken, {
lazyLoading: false
});
```

### Enable Auto-Retry with Exponential Backoff

`twilio-node` supports automatic retry with exponential backoff when API requests receive an [Error 429 response](https://support.twilio.com/hc/en-us/articles/360044308153-Twilio-API-response-Error-429-Too-Many-Requests-). This retry with exponential backoff feature is disabled by default. To enable this feature, instantiate the Twilio client with the `autoRetry` flag set to `true`.

Optionally, the maximum number of retries performed by this feature can be set with the `maxRetries` flag. The default maximum number of retries is `3`.

```javascript
var accountSid = process.env.TWILIO_ACCOUNT_SID; // Your Account SID from www.twilio.com/console
var authToken = process.env.TWILIO_AUTH_TOKEN; // Your Auth Token from www.twilio.com/console

const client = require('twilio')(accountSid, authToken, {
lazyLoading: true
autoRetry: true,
maxRetries: 3
});
```

Expand Down
54 changes: 52 additions & 2 deletions UPGRADE.md
@@ -1,6 +1,56 @@
Upgrade Guide
# Upgrade Guide

After 3.0.0 all MINOR and MAJOR version bumps will have upgrade notes posted here.
_All `MAJOR` version bumps will have upgrade notes posted here._

[2023-01-25] 3.x.x to 4.x.x
-----------------------------

* Supported Node.js versions updated
* Upgrade to Node.js >= 14
* Dropped support for Node.js < 14 ([#791](https://github.com/twilio/twilio-node/pull/791))
* Added support for Node.js 18 ([#794](https://github.com/twilio/twilio-node/pull/794))
* Lazy loading enabled by default ([#752](https://github.com/twilio/twilio-node/pull/752))
* Required Twilio modules now lazy load by default
* See the [README](README.md) for how to disable lazy loading
* Type changes from `object` to `Record` ([#873](https://github.com/twilio/twilio-node/pull/873))
* Certain response properties now use the `Record` type with `string` keys
* Including the `subresourceUris` property for v2010 APIs and the `links` properties for non-v2010 APIs
* Creating an AccessToken requires an `identity` in the options ([#875](https://github.com/twilio/twilio-node/pull/875))
* JWT token building deprecations
* `ConversationsGrant` has been deprecated in favor of `VoiceGrant` ([#783](https://github.com/twilio/twilio-node/pull/783))
* `IpMessagingGrant` has been removed ([#784](https://github.com/twilio/twilio-node/pull/784))
* TwiML function deprecations ([#788](https://github.com/twilio/twilio-node/pull/788))
* `Refer.referSip()` replaced by `Refer.sip()`
* `ssmlBreak()` replaced by `break_()`
* `ssmlEmphasis()` replaced by `emphasis()`
* `ssmlLang()` replaced by `lang()`
* `ssmlP()` replaced by `p()`
* `ssmlPhoneme()` replaced by `phoneme()`
* `ssmlProsody()` replaced by `prosody()`
* `ssmlS()` replaced by `s()`
* `ssmlSayAs()` replaced by `sayAs()`
* `ssmlSub()` replaced by `sub()`
* `ssmlW()` replaced by `w()`
* Old:
```js
const response = new VoiceResponse();
const say = response.say("Hello");
say.ssmlEmphasis("you");
```
* New:
```js
const response = new VoiceResponse();
const say = response.say("Hello");
say.emphasis("you");
```
* TaskRouter Workers Statistics operations updated ([#820](https://github.com/twilio/twilio-node/pull/820))
* Cumulative and Real-Time Workers Statistics no longer accept a WorkerSid
* `GET /v1/Workspaces/{WorkspaceSid}/Workers/CumulativeStatistics`
* Old: `client.taskrouter.v1.workspaces('WS...').workers('WK...).cumulativeStatistics()`
* New: `client.taskrouter.v1.workspaces('WS...').workers.cumulativeStatistics()`
* `GET /v1/Workspaces/{WorkspaceSid}/Workers/RealTimeStatistics`
* Old: `client.taskrouter.v1.workspaces('WS...').workers('WK...).realTimeStatistics()`
* New: `client.taskrouter.v1.workspaces('WS...').workers.realTimeStatistics()`

[2017-05-22] 3.1.x to 3.2.x
---------------------------
Expand Down
9 changes: 9 additions & 0 deletions babel.config.js
@@ -0,0 +1,9 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
plugins: [
'babel-plugin-replace-ts-export-assignment',
],
};
94 changes: 94 additions & 0 deletions cluster_test.spec.ts
@@ -0,0 +1,94 @@
jest.setTimeout(15000);

import twilio from "./lib/";

const fromNumber = process.env.TWILIO_FROM_NUMBER;
const toNumber = process.env.TWILIO_TO_NUMBER;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const testClient = twilio(apiKey, apiSecret, { accountSid });
const twiml = new twilio.twiml.VoiceResponse();

test("Should send a text", () => {
return testClient.messages
.create({
body: "hello world",
to: toNumber,
from: fromNumber,
})
.then((msg) => {
expect(msg.sid).not.toBeUndefined();
expect(msg.to).toBe(toNumber);
expect(msg.from).toBe(fromNumber);
expect(msg.body).toBe("hello world");
});
});

test("Should list incoming numbers", () => {
return testClient.incomingPhoneNumbers.list().then((incomingPhoneNumbers) => {
expect(incomingPhoneNumbers).not.toBeNull();
expect(incomingPhoneNumbers.length).toBeGreaterThanOrEqual(2);
});
});

test("Should list a incoming number", () => {
return testClient.incomingPhoneNumbers
.list({ limit: 1 })
.then((incomingPhoneNumbers) => {
expect(incomingPhoneNumbers).not.toBeUndefined();
expect(incomingPhoneNumbers.length).toEqual(1);
});
});

test("Should allow special characters for friendly and identity name", async () => {
const friendlyName = "service|friendly&name";
const identityName = "user|identity&string";
const conversation = await testClient.conversations.v1.conversations.create({
friendlyName: friendlyName,
});
const participant = await testClient.conversations.v1
.conversations(conversation.sid)
.participants.create({ identity: identityName });

expect(conversation).not.toBeNull();
expect(participant).not.toBeNull();
expect(conversation.friendlyName).toBe(friendlyName);
expect(participant.identity).toBe(identityName);

const removeConversation = await testClient.conversations.v1
.conversations(conversation.sid)
.remove();

expect(removeConversation).toBeTruthy();
});

test("Should list available numbers", () => {
return testClient
.availablePhoneNumbers("US")
.tollFree.list({ limit: 2 })
.then((tollFree) => {
expect(tollFree).not.toBeNull();
expect(tollFree.length).toEqual(2);
});
});

test("Should call with twiml string", () => {
return testClient.calls
.create({
twiml: twiml.toString(),
to: toNumber,
from: fromNumber,
})
.then((call) => expect(call.sid).toBeDefined());
});

test("Should call with twiml object", () => {
return testClient.calls
.create({
twiml: twiml,
to: toNumber,
from: fromNumber,
})
.then((call) => expect(call.sid).toBeDefined());
});