-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
324128e
commit d601c0a
Showing
8 changed files
with
1,557 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,9 @@ | ||
module.exports = { | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
}, | ||
rules: { | ||
'new-cap': 'off', | ||
'no-console': 'off', | ||
}, | ||
}; |
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 @@ | ||
20.17.0 |
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,2 @@ | ||
nodejs 20.17.0 | ||
npm 10.8.1 |
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,9 @@ | ||
# Node SDK Example - Numbers | ||
|
||
To test this run `npm install` and then run the main script in `package.json` with `ts-node`: | ||
|
||
```bash | ||
npm run start | ||
``` | ||
|
||
> don't forget to populate your Telnyx API Key with `export TELNYX_API_KEY=KEY...` |
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,29 @@ | ||
/** | ||
* To run this file, just provide your Secret API Key, like so: | ||
* TELNYX_API_KEY=KEY... node index.js | ||
*/ | ||
|
||
import Telnyx from 'telnyx'; | ||
|
||
const telnyx = new Telnyx(process.env.TELNYX_API_KEY || ''); | ||
|
||
const params: Telnyx.AvailablePhoneNumbersListParams = { | ||
'filter[features]': ['sms', 'emergency', 'mms', 'international_sms'], | ||
'filter[limit]': 10, | ||
'filter[country_code]': 'US', | ||
}; | ||
|
||
(async function numbers() { | ||
try { | ||
const {data: numbers} = await telnyx.availablePhoneNumbers.list(params); | ||
|
||
console.log(numbers); | ||
} catch (e: unknown) { | ||
console.error(e); | ||
|
||
const rawError: Telnyx.TelnyxRawError = (e as {raw: Telnyx.TelnyxRawError}) | ||
.raw; | ||
|
||
console.dir(JSON.stringify(rawError.errors)); | ||
} | ||
})(); |
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,26 @@ | ||
{ | ||
"name": "telnyx-numbers-example", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.ts", | ||
"scripts": { | ||
"debug": "tsx index.ts", | ||
"start": "tsx index.ts" | ||
}, | ||
"author": "Telnyx <[email protected]> (https://telnyx.com)", | ||
"license": "ISC", | ||
"type": "module", | ||
"engines": { | ||
"node": "^18 || >=20" | ||
}, | ||
"dependencies": { | ||
"telnyx": "2.0.0-beta.5" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.7.4", | ||
"tsx": "^4.19.1", | ||
"typescript": "^5.6.2", | ||
"typescript-eslint": "^8.8.0" | ||
}, | ||
"packageManager": "[email protected]+sha512.b8fef5494bd3fe4cbd4edabd0745df2ee5be3e4b0b8b08fa643aa3e4c6702ccc0f00d68fa8a8c9858a735a0032485a44990ed2810526c875e416f001b17df12b" | ||
} |
Oops, something went wrong.