telnyx 1.27.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -1
- package/LICENSE +1 -1
- package/README.md +117 -100
- package/VERSION +1 -1
- package/dist/Error.js +156 -0
- package/dist/TelnyxMethod.basic.js +24 -0
- package/{lib → dist}/TelnyxMethod.js +34 -41
- package/dist/TelnyxResource.js +393 -0
- package/dist/Webhooks.js +52 -0
- package/dist/autoPagination.js +201 -0
- package/dist/makeRequest.js +108 -0
- package/dist/multipart.js +60 -0
- package/dist/resources/AI.js +40 -0
- package/dist/resources/AccessIpAddress.js +5 -0
- package/dist/resources/AccessIpRanges.js +5 -0
- package/dist/resources/Actions.js +8 -0
- package/dist/resources/ActionsSimCards.js +13 -0
- package/dist/resources/ActivateDeactivateBulkCredentials.js +15 -0
- package/dist/resources/Addresses.js +37 -0
- package/dist/resources/AuthenticationProviders.js +5 -0
- package/dist/resources/AutorespConfigs.js +11 -0
- package/dist/resources/AvailablePhoneNumbers.js +5 -0
- package/dist/resources/Balance.js +5 -0
- package/dist/resources/BillingGroups.js +5 -0
- package/dist/resources/Brands.js +57 -0
- package/dist/resources/BulkCredentials.js +15 -0
- package/dist/resources/BulkSoleProprietorCreation.js +20 -0
- package/dist/resources/BulkTelephonyCredentials.js +36 -0
- package/dist/resources/BusinessIdentity.js +15 -0
- package/dist/resources/CallControlApplications.js +39 -0
- package/dist/resources/CallEvents.js +5 -0
- package/dist/resources/CallInformation.js +10 -0
- package/dist/resources/CallRecordings.js +22 -0
- package/dist/resources/Calls.js +64 -0
- package/dist/resources/Campaign.js +75 -0
- package/dist/resources/CampaignBuilder.js +35 -0
- package/dist/resources/CdrUsageReports.js +10 -0
- package/dist/resources/Channelzones.js +22 -0
- package/dist/resources/ClientStateUpdate.js +5 -0
- package/dist/resources/Conferences.js +46 -0
- package/dist/resources/Connections.js +5 -0
- package/dist/resources/CredentialConnections.js +5 -0
- package/dist/resources/Credentials.js +24 -0
- package/dist/resources/CsvDownloads.js +15 -0
- package/dist/resources/CustomerServiceRecord.js +18 -0
- package/dist/resources/Debugging.js +10 -0
- package/dist/resources/DetailRecords.js +9 -0
- package/dist/resources/DialogflowIntegration.js +10 -0
- package/dist/resources/DocumentLinks.js +5 -0
- package/dist/resources/Documents.js +44 -0
- package/dist/resources/DynamicEmergency.js +9 -0
- package/dist/resources/DynamicEmergencyAddresses.js +5 -0
- package/dist/resources/DynamicEmergencyEndpoints.js +5 -0
- package/dist/resources/Events.js +5 -0
- package/dist/resources/ExternalConnections.js +71 -0
- package/dist/resources/FaxApplications.js +39 -0
- package/dist/resources/Faxes.js +36 -0
- package/dist/resources/FqdnConnections.js +39 -0
- package/dist/resources/Fqdns.js +39 -0
- package/dist/resources/GlobalIps.js +42 -0
- package/dist/resources/InboundChannels.js +10 -0
- package/dist/resources/InventoryCoverage.js +9 -0
- package/dist/resources/InventoryLevel.js +10 -0
- package/dist/resources/IpAddresses.js +15 -0
- package/dist/resources/IpConnections.js +39 -0
- package/dist/resources/IpRanges.js +15 -0
- package/dist/resources/Ips.js +39 -0
- package/dist/resources/ManagedAccounts.js +48 -0
- package/dist/resources/MdrDetailReports.js +19 -0
- package/dist/resources/MdrUsageReports.js +19 -0
- package/dist/resources/MediaStorageApi.js +18 -0
- package/dist/resources/Messages.js +9 -0
- package/dist/resources/MessagesAlphanumericSenderId.js +5 -0
- package/dist/resources/MessagingHostedNumber.js +25 -0
- package/dist/resources/MessagingHostedNumberOrders.js +5 -0
- package/dist/resources/MessagingHostedNumbers.js +5 -0
- package/dist/resources/MessagingPhoneNumbers.js +5 -0
- package/dist/resources/MessagingProfileMetrics.js +5 -0
- package/dist/resources/MessagingProfiles.js +81 -0
- package/dist/resources/MessagingSenderIds.js +5 -0
- package/dist/resources/MessagingShortCodes.js +5 -0
- package/dist/resources/MessagingTollfreeVerification.js +15 -0
- package/dist/resources/MessagingUrlDomains.js +10 -0
- package/dist/resources/MobileNetworkOperators.js +10 -0
- package/dist/resources/MobileOperatorNetworks.js +5 -0
- package/dist/resources/Networks.js +22 -0
- package/dist/resources/NumberBackgroundJobs.js +18 -0
- package/dist/resources/NumberLookup.js +5 -0
- package/dist/resources/NumberOrderDocuments.js +10 -0
- package/dist/resources/NumberOrders.js +5 -0
- package/dist/resources/NumberPortouts.js +64 -0
- package/dist/resources/NumberReservations.js +22 -0
- package/dist/resources/NumbersFeatures.js +10 -0
- package/dist/resources/Object.js +16 -0
- package/dist/resources/OtaUpdates.js +14 -0
- package/dist/resources/OutboundVoiceProfiles.js +43 -0
- package/dist/resources/Payment.js +13 -0
- package/dist/resources/PhoneNumberAssignmentByProfile.js +52 -0
- package/dist/resources/PhoneNumberBlockOrders.js +15 -0
- package/dist/resources/PhoneNumberBlocksBackgroundJobs.js +19 -0
- package/dist/resources/PhoneNumberCampaigns.js +15 -0
- package/dist/resources/PhoneNumberOrderDocuments.js +15 -0
- package/dist/resources/PhoneNumberRegulatoryRequirements.js +5 -0
- package/dist/resources/PhoneNumberSearch.js +14 -0
- package/dist/resources/PhoneNumbers.js +41 -0
- package/dist/resources/PhoneNumbersInboundChannels.js +23 -0
- package/dist/resources/PhoneNumbersMessaging.js +5 -0
- package/dist/resources/PhoneNumbersVoice.js +5 -0
- package/dist/resources/PortabilityChecks.js +8 -0
- package/dist/resources/PortingOrders.js +85 -0
- package/dist/resources/PortingPhoneNumbers.js +5 -0
- package/dist/resources/PortoutRequests.js +47 -0
- package/dist/resources/PresignedObjectUrls.js +11 -0
- package/dist/resources/PrivateWirelessGateways.js +14 -0
- package/dist/resources/PublicInternetGateways.js +14 -0
- package/dist/resources/PublicKey.js +8 -0
- package/dist/resources/PushCredentials.js +15 -0
- package/dist/resources/Queues.js +48 -0
- package/dist/resources/RecordingsCommands.js +11 -0
- package/dist/resources/Regions.js +10 -0
- package/dist/resources/RegulatoryRequirements.js +5 -0
- package/dist/resources/Reporting.js +14 -0
- package/dist/resources/Reports.js +14 -0
- package/dist/resources/ReportsMdrs.js +5 -0
- package/dist/resources/RequirementTypes.js +14 -0
- package/dist/resources/Requirements.js +14 -0
- package/dist/resources/RoomCompositions.js +5 -0
- package/dist/resources/RoomParticipants.js +5 -0
- package/dist/resources/RoomRecordings.js +15 -0
- package/dist/resources/RoomSessions.js +38 -0
- package/dist/resources/Rooms.js +5 -0
- package/dist/resources/RoomsClientToken.js +15 -0
- package/dist/resources/RoomsClientTokens.js +16 -0
- package/dist/resources/SharedCampaigns.js +15 -0
- package/dist/resources/ShortCodes.js +27 -0
- package/dist/resources/SimCardActions.js +22 -0
- package/dist/resources/SimCardGroupActions.js +14 -0
- package/dist/resources/SimCardGroups.js +39 -0
- package/dist/resources/SimCardOrders.js +5 -0
- package/dist/resources/SimCards.js +103 -0
- package/dist/resources/StorageBuckets.js +30 -0
- package/dist/resources/TelephonyCredentials.js +35 -0
- package/dist/resources/TexmlApplications.js +5 -0
- package/dist/resources/UpdateClientState.js +14 -0
- package/dist/resources/Verifications.js +53 -0
- package/dist/resources/VerifiedNumbers.js +5 -0
- package/dist/resources/Verify.js +50 -0
- package/dist/resources/VerifyProfiles.js +45 -0
- package/dist/resources/VirtualCrossConnects.js +26 -0
- package/dist/resources/WdrDetailReports.js +10 -0
- package/dist/resources/Webhooks.js +5 -0
- package/dist/resources/WireguardInterfaces.js +34 -0
- package/dist/resources/WirelessDetailRecordReports.js +5 -0
- package/dist/telnyx.js +553 -0
- package/dist/telnyx.node.js +3 -0
- package/dist/types/AccessIpAddressResource.d.ts +57 -0
- package/dist/types/AccessIpRangesResource.d.ts +43 -0
- package/dist/types/AddressesResource.d.ts +78 -0
- package/dist/types/AutorespConfigsResource.d.ts +74 -0
- package/dist/types/AvailablePhoneNumbersResource.d.ts +18 -0
- package/dist/types/BalanceResource.d.ts +19 -0
- package/dist/types/BillingGroupsResource.d.ts +72 -0
- package/dist/types/BrandsResource.d.ts +142 -0
- package/dist/types/CallsResource.d.ts +299 -0
- package/dist/types/Errors.d.ts +131 -0
- package/dist/types/MessagingProfileMetricsResource.d.ts +18 -0
- package/dist/types/MessagingProfilesResource.d.ts +132 -0
- package/dist/types/PhoneNumberAssignmentByProfileResource.d.ts +53 -0
- package/dist/types/StorageBucketsResource.d.ts +74 -0
- package/dist/types/TelnyxAPI.d.ts +65420 -0
- package/dist/types/Webhooks.d.ts +26 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/lib.d.ts +44 -0
- package/dist/utils.js +277 -0
- package/package.json +40 -33
- package/lib/Error.js +0 -143
- package/lib/MultipartDataGenerator.js +0 -45
- package/lib/TelnyxMethod.basic.js +0 -112
- package/lib/TelnyxResource.js +0 -479
- package/lib/Webhooks.js +0 -72
- package/lib/autoPagination.js +0 -231
- package/lib/makeRequest.js +0 -144
- package/lib/resources/AI.js +0 -45
- package/lib/resources/AccessIpAddress.js +0 -6
- package/lib/resources/AccessIpRanges.js +0 -6
- package/lib/resources/AccessTokens.js +0 -6
- package/lib/resources/Actions.js +0 -9
- package/lib/resources/ActionsSimCards.js +0 -18
- package/lib/resources/ActivateDeactivateBulkCredentials.js +0 -20
- package/lib/resources/Addresses.js +0 -47
- package/lib/resources/AdvancedOptinoptout.js +0 -21
- package/lib/resources/AuthenticationProviders.js +0 -8
- package/lib/resources/Autorechargepreferences.js +0 -15
- package/lib/resources/AvailablePhoneNumbers.js +0 -7
- package/lib/resources/Balance.js +0 -11
- package/lib/resources/Billing.js +0 -15
- package/lib/resources/BillingGroups.js +0 -6
- package/lib/resources/Brands.js +0 -36
- package/lib/resources/Bucket.js +0 -16
- package/lib/resources/BucketUsage.js +0 -21
- package/lib/resources/BulkCreation.js +0 -52
- package/lib/resources/BulkCredentials.js +0 -20
- package/lib/resources/BulkPhoneNumberCampaigns.js +0 -25
- package/lib/resources/BulkPhoneNumberOperations.js +0 -32
- package/lib/resources/BulkSoleProprietorCreation.js +0 -25
- package/lib/resources/BulkTelephonyCredentials.js +0 -46
- package/lib/resources/BusinessIdentity.js +0 -20
- package/lib/resources/CallControlApplications.js +0 -54
- package/lib/resources/CallEvents.js +0 -7
- package/lib/resources/CallInformation.js +0 -15
- package/lib/resources/CallRecordings.js +0 -27
- package/lib/resources/Calls.js +0 -73
- package/lib/resources/Campaign.js +0 -84
- package/lib/resources/CampaignBuilder.js +0 -40
- package/lib/resources/CdrUsageReports.js +0 -15
- package/lib/resources/Channelzones.js +0 -27
- package/lib/resources/ClientStateUpdate.js +0 -6
- package/lib/resources/Conferences.js +0 -62
- package/lib/resources/Connections.js +0 -8
- package/lib/resources/CredentialConnections.js +0 -6
- package/lib/resources/Credentials.js +0 -29
- package/lib/resources/CsvDownloads.js +0 -20
- package/lib/resources/CustomerServiceRecord.js +0 -23
- package/lib/resources/Debugging.js +0 -15
- package/lib/resources/DetailRecords.js +0 -13
- package/lib/resources/DialogflowIntegration.js +0 -15
- package/lib/resources/DocumentLinks.js +0 -6
- package/lib/resources/Documents.js +0 -50
- package/lib/resources/DynamicEmergency.js +0 -10
- package/lib/resources/DynamicEmergencyAddresses.js +0 -8
- package/lib/resources/DynamicEmergencyEndpoints.js +0 -8
- package/lib/resources/Events.js +0 -7
- package/lib/resources/ExternalConnections.js +0 -76
- package/lib/resources/FaxApplications.js +0 -55
- package/lib/resources/Faxes.js +0 -53
- package/lib/resources/FqdnConnections.js +0 -55
- package/lib/resources/Fqdns.js +0 -55
- package/lib/resources/GlobalIps.js +0 -47
- package/lib/resources/InboundChannels.js +0 -15
- package/lib/resources/InventoryCoverage.js +0 -13
- package/lib/resources/InventoryLevel.js +0 -15
- package/lib/resources/IpAddresses.js +0 -20
- package/lib/resources/IpConnections.js +0 -55
- package/lib/resources/IpRanges.js +0 -20
- package/lib/resources/Ips.js +0 -55
- package/lib/resources/ManagedAccounts.js +0 -57
- package/lib/resources/MdrDetailReports.js +0 -24
- package/lib/resources/MdrUsageReports.js +0 -24
- package/lib/resources/MediaStorageApi.js +0 -23
- package/lib/resources/Messages.js +0 -10
- package/lib/resources/MessagesAlphanumericSenderId.js +0 -6
- package/lib/resources/MessagingHostedNumber.js +0 -30
- package/lib/resources/MessagingHostedNumberOrders.js +0 -6
- package/lib/resources/MessagingHostedNumbers.js +0 -6
- package/lib/resources/MessagingPhoneNumbers.js +0 -7
- package/lib/resources/MessagingProfileMetrics.js +0 -7
- package/lib/resources/MessagingProfiles.js +0 -112
- package/lib/resources/MessagingSenderIds.js +0 -7
- package/lib/resources/MessagingShortCodes.js +0 -7
- package/lib/resources/MessagingTollfreeVerification.js +0 -20
- package/lib/resources/MessagingUrlDomains.js +0 -15
- package/lib/resources/MobileNetworkOperators.js +0 -15
- package/lib/resources/MobileOperatorNetworks.js +0 -8
- package/lib/resources/Networks.js +0 -27
- package/lib/resources/NumberBackgroundJobs.js +0 -24
- package/lib/resources/NumberLookup.js +0 -8
- package/lib/resources/NumberOrderDocuments.js +0 -15
- package/lib/resources/NumberOrders.js +0 -7
- package/lib/resources/NumberPortouts.js +0 -71
- package/lib/resources/NumberReservations.js +0 -33
- package/lib/resources/NumbersFeatures.js +0 -15
- package/lib/resources/Object.js +0 -21
- package/lib/resources/OtaUpdates.js +0 -19
- package/lib/resources/Outbound.js +0 -55
- package/lib/resources/OutboundVoiceProfiles.js +0 -19
- package/lib/resources/PhoneNumberAssignmentByProfile.js +0 -55
- package/lib/resources/PhoneNumberBlockOrders.js +0 -20
- package/lib/resources/PhoneNumberBlocksBackgroundJobs.js +0 -24
- package/lib/resources/PhoneNumberCampaigns.js +0 -19
- package/lib/resources/PhoneNumberOrderDocuments.js +0 -20
- package/lib/resources/PhoneNumberRegulatoryRequirements.js +0 -9
- package/lib/resources/PhoneNumberSearch.js +0 -19
- package/lib/resources/PhoneNumbers.js +0 -48
- package/lib/resources/PhoneNumbersInboundChannels.js +0 -34
- package/lib/resources/PhoneNumbersMessaging.js +0 -6
- package/lib/resources/PhoneNumbersVoice.js +0 -6
- package/lib/resources/PortabilityChecks.js +0 -12
- package/lib/resources/PortingOrders.js +0 -107
- package/lib/resources/PortingPhoneNumbers.js +0 -8
- package/lib/resources/PortoutRequests.js +0 -53
- package/lib/resources/PresignedObjectUrls.js +0 -16
- package/lib/resources/PrivateWirelessGateways.js +0 -19
- package/lib/resources/PublicInternetGateways.js +0 -19
- package/lib/resources/PublicKey.js +0 -13
- package/lib/resources/PushCredentials.js +0 -20
- package/lib/resources/Queues.js +0 -41
- package/lib/resources/RecordingsCommands.js +0 -16
- package/lib/resources/Regions.js +0 -15
- package/lib/resources/RegisterCall.js +0 -6
- package/lib/resources/RegulatoryRequirements.js +0 -9
- package/lib/resources/Reporting.js +0 -19
- package/lib/resources/Reports.js +0 -19
- package/lib/resources/ReportsMdrs.js +0 -6
- package/lib/resources/RequirementTypes.js +0 -19
- package/lib/resources/Requirements.js +0 -19
- package/lib/resources/RoomCompositions.js +0 -8
- package/lib/resources/RoomParticipants.js +0 -8
- package/lib/resources/RoomRecordings.js +0 -20
- package/lib/resources/RoomSessions.js +0 -43
- package/lib/resources/Rooms.js +0 -6
- package/lib/resources/RoomsClientToken.js +0 -18
- package/lib/resources/RoomsClientTokens.js +0 -21
- package/lib/resources/SharedCampaigns.js +0 -20
- package/lib/resources/ShortCodes.js +0 -39
- package/lib/resources/SimCardActions.js +0 -27
- package/lib/resources/SimCardGroupActions.js +0 -19
- package/lib/resources/SimCardGroups.js +0 -55
- package/lib/resources/SimCardOrders.js +0 -6
- package/lib/resources/SimCards.js +0 -139
- package/lib/resources/SslCertificates.js +0 -20
- package/lib/resources/TeXMLApplication.js +0 -6
- package/lib/resources/TelephonyCredentials.js +0 -55
- package/lib/resources/UpdateClientState.js +0 -22
- package/lib/resources/Verifications.js +0 -68
- package/lib/resources/VerifiedCallsDisplayProfile.js +0 -25
- package/lib/resources/VerifiedCallsDisplayProfiles.js +0 -13
- package/lib/resources/VerifiedNumbers.js +0 -6
- package/lib/resources/Verify.js +0 -55
- package/lib/resources/VerifyProfiles.js +0 -61
- package/lib/resources/VirtualCrossConnects.js +0 -31
- package/lib/resources/WdrDetailReports.js +0 -15
- package/lib/resources/Webhooks.js +0 -6
- package/lib/resources/WireguardInterfaces.js +0 -39
- package/lib/resources/WirelessDetailRecordReports.js +0 -8
- package/lib/telnyx.js +0 -425
- package/lib/utils.js +0 -366
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,72 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## v2
|
|
4
|
+
|
|
5
|
+
### v2.0.0-alpha.1
|
|
6
|
+
|
|
7
|
+
- Update actions workflow versions to v4 and `.npmignore` to v2
|
|
8
|
+
- Update examples dependencies
|
|
9
|
+
|
|
10
|
+
### v2.0.0-alpha.0
|
|
11
|
+
|
|
12
|
+
- Add Typescript default config, linter and dependencies
|
|
13
|
+
- Bump default Node version to `20`
|
|
14
|
+
- Update README on [Development](./README.md#development) instructions
|
|
15
|
+
- Remove `yarn` in favor of `npm` 10
|
|
16
|
+
- Convert SDK files to Typescript
|
|
17
|
+
- Convert Resources to Typescript
|
|
18
|
+
- Use ES Modules syntax
|
|
19
|
+
- Update package `main` entrypoint to be compiled version of [src telnyx.ts](./src/telnyx.ts)
|
|
20
|
+
- Added `Jest` and create tests in Typescript
|
|
21
|
+
- Update tests expect matchers according to limitations with `prism mock`
|
|
22
|
+
- Add `nock` cleanup setup
|
|
23
|
+
- Make `setApiKey` TelnyxObject prototype method private
|
|
24
|
+
- Moved to `moduleResolution` Bundler to support better imports and tests with `Jest`
|
|
25
|
+
- Enabled `esModuleInterop` for Jest
|
|
26
|
+
- Update files included when publishing
|
|
27
|
+
- Remove custom resource get `generateAccessTokenFromCredential` from `TelephonyCredentials`
|
|
28
|
+
- Update `AutoRechargePreferences` resource
|
|
29
|
+
- Remove `RegisterCall` resource
|
|
30
|
+
- Remove `ProgrammableFaxCommants` specs
|
|
31
|
+
- Remove `BulkCreation` resource
|
|
32
|
+
- Update `TexmlApplications` resource
|
|
33
|
+
- Remove `Conferences` `dial_participant` action
|
|
34
|
+
- Remove `SimCards` `deletePublicIp` and `setPublicIp`
|
|
35
|
+
- Update `Queues` method names to camelCase
|
|
36
|
+
- Remove `VerifiedCallsDisplayProfile` resource
|
|
37
|
+
- Update examples to Typescript
|
|
38
|
+
- Remove duplicated `AccessTokens` resource
|
|
39
|
+
- Move custom `AdvancedOptinoptout` resource to be `AutoRespConfigs` resource
|
|
40
|
+
- Remove `Billing` resource
|
|
41
|
+
- Remove inexistent `Bucket` resource
|
|
42
|
+
- Move `BucketUsage` resource to `StorageBuckets`
|
|
43
|
+
- Remove duplicated `BulkPhoneNumberCampaigns` resource
|
|
44
|
+
- Remove duplicated `BulkPhoneNumberOperations` resource
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## v1
|
|
4
48
|
|
|
5
49
|
### v1.26.2
|
|
50
|
+
|
|
6
51
|
- Fix Brand and Campaign redirects
|
|
7
52
|
- Update security
|
|
8
53
|
|
|
9
54
|
### v1.26.1
|
|
55
|
+
|
|
10
56
|
- Fix porting comments
|
|
11
57
|
|
|
12
58
|
### v1.26.0
|
|
59
|
+
|
|
13
60
|
- Endpoint additions
|
|
14
61
|
- Package upgrades
|
|
15
62
|
- Preparation for typescript migration/support
|
|
16
63
|
|
|
17
64
|
### v1.25.5
|
|
65
|
+
|
|
18
66
|
- Security Updates + API Additions
|
|
19
67
|
|
|
20
68
|
### v1.23.0 (2021-10-19)
|
|
69
|
+
|
|
21
70
|
- **Addresses** added `validate`
|
|
22
71
|
- **AuthenticationProvider** added `list`, `create`, `retrieve`, `update`, `del`
|
|
23
72
|
- **DynamicEmergency** (for `endpoints` and `addresses`) added `list`, `retrieve`, `create`, `del`
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Copyright (C) 2011 Ask Bjørn Hansen
|
|
2
2
|
Copyright (C) 2013 Stripe, Inc. (https://stripe.com)
|
|
3
|
-
Copyright (C) 2019 Telnyx, Inc. (https://
|
|
3
|
+
Copyright (C) 2019 Telnyx, Inc. (https://telnyx.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.org/package/telnyx)
|
|
4
4
|
[](https://github.com/team-telnyx/telnyx-node/actions)
|
|
5
|
-
[](https://coveralls.io/github/team-telnyx/telnyx-node?branch=master)
|
|
6
5
|
[](https://www.npmjs.com/package/telnyx)
|
|
7
6
|
[](https://runkit.com/npm/telnyx)
|
|
8
7
|
[](https://joinslack.telnyx.com/)
|
|
@@ -26,62 +25,41 @@ The package needs to be configured with your account's API key which is
|
|
|
26
25
|
available in your the [Telnyx Mission Control Portal][api-keys]. Require it with the key's
|
|
27
26
|
value:
|
|
28
27
|
|
|
29
|
-
```
|
|
30
|
-
|
|
28
|
+
```typescript
|
|
29
|
+
import Telnyx from 'telnyx';
|
|
30
|
+
|
|
31
|
+
const telnyx = new Telnyx('KEY123456...');
|
|
31
32
|
|
|
32
33
|
const messagingProfile = await telnyx.messagingProfiles.create({
|
|
33
|
-
name: 'Summer Campaign'
|
|
34
|
+
name: 'Summer Campaign',
|
|
34
35
|
});
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
Or with versions of Node.js prior to v7.9:
|
|
38
|
-
|
|
39
|
-
``` js
|
|
40
|
-
var telnyx = require('telnyx')('KEY123456...');
|
|
41
|
-
|
|
42
|
-
telnyx.messagingProfiles.create(
|
|
43
|
-
{ name: 'Summer Campaign' },
|
|
44
|
-
function(err, messagingProfile) {
|
|
45
|
-
err; // null if no error occurred
|
|
46
|
-
messagingProfile; // the created messaging profile object
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Or using ES modules, this looks more like:
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
import Telnyx from 'telnyx';
|
|
55
|
-
const telnyx = Telnyx('KEY...');
|
|
56
|
-
//…
|
|
57
|
-
```
|
|
58
|
-
|
|
59
38
|
### Using Promises
|
|
60
39
|
|
|
61
40
|
Every method returns a chainable promise which can be used instead of a regular
|
|
62
41
|
callback:
|
|
63
42
|
|
|
64
|
-
```
|
|
43
|
+
```typescript
|
|
65
44
|
// Create a new messaging profile and then send a message using that profile:
|
|
66
|
-
telnyx.
|
|
67
|
-
name: 'Summer Campaign'
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
'+18005554000',
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
45
|
+
telnyx.,essagingProfiles.create({
|
|
46
|
+
name: 'Summer Campaign',
|
|
47
|
+
})
|
|
48
|
+
.then((messagingProfile) => {
|
|
49
|
+
return telnyx.messagingPhoneNumbers.update('+18005554000', {
|
|
50
|
+
messaging_profile_id: messagingProfile.data.id,
|
|
51
|
+
});
|
|
52
|
+
})
|
|
53
|
+
.catch((err) => {
|
|
54
|
+
// Deal with an error
|
|
55
|
+
});
|
|
78
56
|
```
|
|
79
57
|
|
|
80
58
|
### Configuring Timeout
|
|
81
59
|
|
|
82
60
|
Request timeout is configurable (the default is Node's default of 120 seconds):
|
|
83
61
|
|
|
84
|
-
```
|
|
62
|
+
```typescript
|
|
85
63
|
telnyx.setTimeout(20000); // in ms (this is 20 seconds)
|
|
86
64
|
```
|
|
87
65
|
|
|
@@ -90,11 +68,12 @@ telnyx.setTimeout(20000); // in ms (this is 20 seconds)
|
|
|
90
68
|
An [https-proxy-agent][https-proxy-agent] can be configured with
|
|
91
69
|
`setHttpAgent`.
|
|
92
70
|
|
|
93
|
-
To use telnyx behind a proxy you can pass
|
|
71
|
+
To use telnyx behind a proxy you can pass to sdk:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import ProxyAgent from 'https-proxy-agent';
|
|
94
75
|
|
|
95
|
-
```js
|
|
96
76
|
if (process.env.http_proxy) {
|
|
97
|
-
const ProxyAgent = require('https-proxy-agent');
|
|
98
77
|
telnyx.setHttpAgent(new ProxyAgent(process.env.http_proxy));
|
|
99
78
|
}
|
|
100
79
|
```
|
|
@@ -105,7 +84,7 @@ Automatic network retries can be enabled with `setMaxNetworkRetries`. This will
|
|
|
105
84
|
retry requests `n` times with exponential backoff if they fail due to an
|
|
106
85
|
intermittent network problem.
|
|
107
86
|
|
|
108
|
-
```
|
|
87
|
+
```typescript
|
|
109
88
|
// Retry a request once before giving up
|
|
110
89
|
telnyx.setMaxNetworkRetries(1);
|
|
111
90
|
```
|
|
@@ -115,21 +94,23 @@ telnyx.setMaxNetworkRetries(1);
|
|
|
115
94
|
Some information about the response which generated a resource is available
|
|
116
95
|
with the `lastResponse` property:
|
|
117
96
|
|
|
118
|
-
```
|
|
119
|
-
messagingProfile.lastResponse.requestId // see: https://telnyx.com/docs/api/node#request_ids
|
|
120
|
-
messagingProfile.lastResponse.statusCode
|
|
97
|
+
```typescript
|
|
98
|
+
messagingProfile.lastResponse.requestId; // see: https://telnyx.com/docs/api/node#request_ids
|
|
99
|
+
messagingProfile.lastResponse.statusCode;
|
|
121
100
|
```
|
|
122
101
|
|
|
123
102
|
### `request` and `response` events
|
|
124
103
|
|
|
125
|
-
The Telnyx object emits `request` and `response` events.
|
|
104
|
+
The Telnyx object emits `request` and `response` events. You can use them like this:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import Telnyx from 'telnyx';
|
|
126
108
|
|
|
127
|
-
|
|
128
|
-
const telnyx = require('telnyx')('KEY...');
|
|
109
|
+
const telnyx = new Telnyx('KEY...');
|
|
129
110
|
|
|
130
111
|
const onRequest = (request) => {
|
|
131
112
|
// Do something.
|
|
132
|
-
}
|
|
113
|
+
};
|
|
133
114
|
|
|
134
115
|
// Add the event handler function:
|
|
135
116
|
telnyx.on('request', onRequest);
|
|
@@ -139,7 +120,8 @@ telnyx.off('request', onRequest);
|
|
|
139
120
|
```
|
|
140
121
|
|
|
141
122
|
#### `request` object
|
|
142
|
-
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
143
125
|
{
|
|
144
126
|
method: 'POST',
|
|
145
127
|
path: '/v2/messaging_profiles'
|
|
@@ -147,7 +129,8 @@ telnyx.off('request', onRequest);
|
|
|
147
129
|
```
|
|
148
130
|
|
|
149
131
|
#### `response` object
|
|
150
|
-
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
151
134
|
{
|
|
152
135
|
method: 'POST',
|
|
153
136
|
path: '/v2/messaging_profiles',
|
|
@@ -171,12 +154,12 @@ You can find an example of how to use this with [Express](https://expressjs.com/
|
|
|
171
154
|
in the [`examples/webhook-signing`](examples/webhook-signing) folder, but here's
|
|
172
155
|
what it looks like:
|
|
173
156
|
|
|
174
|
-
```
|
|
157
|
+
```typescript
|
|
175
158
|
const event = telnyx.webhooks.constructEvent(
|
|
176
159
|
webhookRawBody,
|
|
177
160
|
webhookTelnyxSignatureHeader,
|
|
178
161
|
webhookTelnyxTimestampHeader,
|
|
179
|
-
publicKey
|
|
162
|
+
publicKey,
|
|
180
163
|
);
|
|
181
164
|
```
|
|
182
165
|
|
|
@@ -186,7 +169,7 @@ TeXML sends webhooks as form-encoded payloads instead of JSON. To validate the s
|
|
|
186
169
|
|
|
187
170
|
You can find an example of how to use this with [Express](https://expressjs.com/) in the [`examples/webhook-signing`](examples/webhook-signing) folder.
|
|
188
171
|
|
|
189
|
-
```
|
|
172
|
+
```typescript
|
|
190
173
|
const timeToleranceInSeconds = 300; // Will validate signatures of webhooks up to 5 minutes after Telnyx sent the request
|
|
191
174
|
try {
|
|
192
175
|
telnyx.webhooks.signature.verifySignature(
|
|
@@ -194,20 +177,19 @@ try {
|
|
|
194
177
|
webhookTelnyxSignatureHeader,
|
|
195
178
|
webhookTelnyxTimestampHeader,
|
|
196
179
|
publicKey,
|
|
197
|
-
timeToleranceInSeconds
|
|
180
|
+
timeToleranceInSeconds,
|
|
198
181
|
);
|
|
199
182
|
} catch (e) {
|
|
200
|
-
console.log(
|
|
183
|
+
console.log('Failed to validate the signature');
|
|
201
184
|
console.log(e);
|
|
202
185
|
}
|
|
203
|
-
|
|
204
186
|
```
|
|
205
187
|
|
|
206
188
|
### Writing a Plugin
|
|
207
189
|
|
|
208
190
|
If you're writing a plugin that uses the library, we'd appreciate it if you identified using `telnyx.setAppInfo()`:
|
|
209
191
|
|
|
210
|
-
```
|
|
192
|
+
```typescript
|
|
211
193
|
telnyx.setAppInfo({
|
|
212
194
|
name: 'MyAwesomePlugin',
|
|
213
195
|
version: '1.2.34', // Optional
|
|
@@ -222,14 +204,13 @@ This information is passed along when the library makes calls to the Telnyx API.
|
|
|
222
204
|
You can auto-paginate list methods. We provide a few different APIs for this to
|
|
223
205
|
aid with a variety of node versions and styles.
|
|
224
206
|
|
|
225
|
-
|
|
226
207
|
#### Async iterators (`for-await-of`)
|
|
227
208
|
|
|
228
209
|
If you are in a Node environment that has support for [async iteration](https://github.com/tc39/proposal-async-iteration#the-async-iteration-statement-for-await-of),
|
|
229
210
|
such as Node 10+ or [babel](https://babeljs.io/docs/en/babel-plugin-transform-async-generator-functions),
|
|
230
211
|
the following will auto-paginate:
|
|
231
212
|
|
|
232
|
-
```
|
|
213
|
+
```typescript
|
|
233
214
|
for await (const messagingProfile of telnyx.messagingProfiles.list()) {
|
|
234
215
|
doSomething(messagingProfile);
|
|
235
216
|
if (shouldStop()) {
|
|
@@ -243,36 +224,42 @@ for await (const messagingProfile of telnyx.messagingProfiles.list()) {
|
|
|
243
224
|
If you are in a Node environment that has support for `await`, such as Node 7.9 and greater,
|
|
244
225
|
you may pass an async function to `.autoPagingEach`:
|
|
245
226
|
|
|
246
|
-
```
|
|
247
|
-
await telnyx.messagingProfiles
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
227
|
+
```typescript
|
|
228
|
+
await telnyx.messagingProfiles
|
|
229
|
+
.list()
|
|
230
|
+
.autoPagingEach(async (messagingProfile) => {
|
|
231
|
+
await doSomething(messagingProfile);
|
|
232
|
+
if (shouldBreak()) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
253
236
|
console.log('Done iterating.');
|
|
254
237
|
```
|
|
255
238
|
|
|
256
239
|
Equivalently, without `await`, you may return a Promise, which can resolve to `false` to break:
|
|
257
240
|
|
|
258
|
-
```
|
|
259
|
-
telnyx.messagingProfiles
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
})
|
|
241
|
+
```typescript
|
|
242
|
+
telnyx.messagingProfiles
|
|
243
|
+
.list()
|
|
244
|
+
.autoPagingEach((messagingProfile) => {
|
|
245
|
+
return doSomething(messagingProfile).then(() => {
|
|
246
|
+
if (shouldBreak()) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
})
|
|
251
|
+
.then(() => {
|
|
252
|
+
console.log('Done iterating.');
|
|
253
|
+
})
|
|
254
|
+
.catch(handleError);
|
|
268
255
|
```
|
|
269
256
|
|
|
270
257
|
If you prefer callbacks to promises, you may also use a `next` callback and a second `onDone` callback:
|
|
271
258
|
|
|
272
|
-
```
|
|
259
|
+
```typescript
|
|
273
260
|
telnyx.messagingProfiles.list().autoPagingEach(
|
|
274
261
|
function onItem(messagingProfile, next) {
|
|
275
|
-
doSomething(messagingProfile, function(err, result) {
|
|
262
|
+
doSomething(messagingProfile, function (err, result) {
|
|
276
263
|
if (shouldStop(result)) {
|
|
277
264
|
next(false); // Passing `false` breaks out of the loop.
|
|
278
265
|
} else {
|
|
@@ -286,8 +273,8 @@ telnyx.messagingProfiles.list().autoPagingEach(
|
|
|
286
273
|
} else {
|
|
287
274
|
console.log('Done iterating.');
|
|
288
275
|
}
|
|
289
|
-
}
|
|
290
|
-
)
|
|
276
|
+
},
|
|
277
|
+
);
|
|
291
278
|
```
|
|
292
279
|
|
|
293
280
|
If your `onItem` function does not accept a `next` callback parameter _or_ return a Promise,
|
|
@@ -301,31 +288,41 @@ to prevent runaway list growth from consuming too much memory.
|
|
|
301
288
|
|
|
302
289
|
Returns a promise of an array of all items across pages for a list request.
|
|
303
290
|
|
|
304
|
-
```
|
|
305
|
-
const allMessagingProfiles = await telnyx.messagingProfiles
|
|
291
|
+
```typescript
|
|
292
|
+
const allMessagingProfiles = await telnyx.messagingProfiles
|
|
293
|
+
.list()
|
|
306
294
|
.autoPagingToArray({limit: 10000});
|
|
307
295
|
```
|
|
308
296
|
|
|
309
297
|
## Development
|
|
310
298
|
|
|
311
299
|
### Setup
|
|
312
|
-
|
|
300
|
+
|
|
301
|
+
Run the following to create your env file
|
|
313
302
|
|
|
314
303
|
```bash
|
|
315
|
-
|
|
304
|
+
cp .env.local .env
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
> Don't forget to update your `.env` values accordingly.
|
|
316
308
|
|
|
317
|
-
|
|
309
|
+
Now inject envs into terminal:
|
|
318
310
|
|
|
319
|
-
|
|
311
|
+
```bash
|
|
312
|
+
. ./setup_env.sh
|
|
320
313
|
```
|
|
321
314
|
|
|
322
|
-
|
|
315
|
+
> Feel free to use Node `--env-file` parameter to [setup envs](https://nodejs.org/en/learn/command-line/how-to-read-environment-variables-from-nodejs) if you prefer
|
|
316
|
+
|
|
317
|
+
The test suite depends on the [Prism Mock Server](https://github.com/stoplightio/prism).
|
|
318
|
+
|
|
319
|
+
Start the prism mock service with the following command:
|
|
323
320
|
|
|
324
321
|
```bash
|
|
325
|
-
prism mock https://raw.githubusercontent.com/team-telnyx/openapi/master/openapi/spec3.json
|
|
322
|
+
npx prism mock https://raw.githubusercontent.com/team-telnyx/openapi/master/openapi/spec3.json
|
|
326
323
|
```
|
|
327
324
|
|
|
328
|
-
|
|
325
|
+
---
|
|
329
326
|
|
|
330
327
|
One final step -- because the Node SDK originally expected to reach the legacy `telnyx-mock` service at port 12111 (in addition to providing a `/v2/` base path), we need to setup the [Telnyx mock proxy server](https://github.com/team-telnyx/telnyx-mock-server-proxy) to modify the request path and forward along to the prism mock server.
|
|
331
328
|
|
|
@@ -335,7 +332,7 @@ One final step -- because the Node SDK originally expected to reach the legacy `
|
|
|
335
332
|
git clone git@github.com:team-telnyx/telnyx-prism-mock.git
|
|
336
333
|
cd telnyx-prism-mock/proxy
|
|
337
334
|
|
|
338
|
-
|
|
335
|
+
npm install
|
|
339
336
|
node index.js
|
|
340
337
|
```
|
|
341
338
|
|
|
@@ -349,22 +346,22 @@ $ npm test
|
|
|
349
346
|
Run all tests with a custom `telnyx-mock` port:
|
|
350
347
|
|
|
351
348
|
```bash
|
|
352
|
-
$ TELNYX_MOCK_PORT=
|
|
349
|
+
$ TELNYX_MOCK_PORT=12111 npm test
|
|
353
350
|
```
|
|
354
351
|
|
|
355
352
|
Run a single test suite:
|
|
356
353
|
|
|
357
354
|
```bash
|
|
358
|
-
$ npm
|
|
355
|
+
$ npm test -- test/Error.test.ts
|
|
359
356
|
```
|
|
360
357
|
|
|
361
358
|
Run a single test (case sensitive):
|
|
362
359
|
|
|
363
360
|
```bash
|
|
364
|
-
$ npm
|
|
361
|
+
$ npm test -- test/Error.test.ts -t 'Populates with type'
|
|
365
362
|
```
|
|
366
363
|
|
|
367
|
-
If you wish, you may run tests using your Telnyx
|
|
364
|
+
If you wish, you may run tests using your Telnyx _Test_ API key by setting the
|
|
368
365
|
environment variable `TELNYX_TEST_API_KEY` before running the tests:
|
|
369
366
|
|
|
370
367
|
```bash
|
|
@@ -377,10 +374,12 @@ $ npm test
|
|
|
377
374
|
|
|
378
375
|
To inspect values in tests first import debug:
|
|
379
376
|
|
|
380
|
-
```
|
|
381
|
-
|
|
377
|
+
```typescript
|
|
378
|
+
import Debug from 'debug';
|
|
379
|
+
|
|
380
|
+
const debug = Debug('foo');
|
|
382
381
|
//...
|
|
383
|
-
debug(result)
|
|
382
|
+
debug(result);
|
|
384
383
|
```
|
|
385
384
|
|
|
386
385
|
Then run the tests with:
|
|
@@ -395,6 +394,24 @@ To view verbose debugging for `nock` run the tests with:
|
|
|
395
394
|
$ DEBUG=nock.* npm test
|
|
396
395
|
```
|
|
397
396
|
|
|
397
|
+
### Typescript
|
|
398
|
+
|
|
399
|
+
Run:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
npm run build
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Then check output in [dist](./dist) folder
|
|
406
|
+
|
|
407
|
+
### Linter (Prettier)
|
|
408
|
+
|
|
409
|
+
Add an [editor integration](https://prettier.io/docs/en/editors.html) or:
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
$ npm run fix
|
|
413
|
+
```
|
|
414
|
+
|
|
398
415
|
## Acknowledgements
|
|
399
416
|
|
|
400
417
|
The contributors and maintainers of Telnyx Node would like to extend their deep gratitude to the
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
2.0.0-alpha.1
|
package/dist/Error.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export const generate = (rawTelnyxError) => {
|
|
2
|
+
switch (rawTelnyxError.statusCode) {
|
|
3
|
+
case 400:
|
|
4
|
+
return new TelnyxInvalidRequestError(rawTelnyxError);
|
|
5
|
+
case 401:
|
|
6
|
+
return new TelnyxAuthenticationError(rawTelnyxError);
|
|
7
|
+
case 403:
|
|
8
|
+
return new TelnyxPermissionError(rawTelnyxError);
|
|
9
|
+
case 404:
|
|
10
|
+
return new TelnyxResourceNotFoundError(rawTelnyxError);
|
|
11
|
+
case 405:
|
|
12
|
+
return new TelnyxMethodNotSupportedError(rawTelnyxError);
|
|
13
|
+
case 408:
|
|
14
|
+
return new TelnyxTimeoutError(rawTelnyxError);
|
|
15
|
+
case 415:
|
|
16
|
+
return new TelnyxUnsupportedMediaTypeError(rawTelnyxError);
|
|
17
|
+
case 422:
|
|
18
|
+
return new TelnyxInvalidParametersError(rawTelnyxError);
|
|
19
|
+
case 429:
|
|
20
|
+
return new TelnyxRateLimitError(rawTelnyxError);
|
|
21
|
+
case 500:
|
|
22
|
+
return new TelnyxAPIError(rawTelnyxError);
|
|
23
|
+
case 503:
|
|
24
|
+
return new TelnyxServiceUnavailableError(rawTelnyxError);
|
|
25
|
+
}
|
|
26
|
+
return new TelnyxError({ type: 'Generic', message: 'Unknown Error' });
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* TelnyxError is the base error from which all other more specific Telnyx errors derive.
|
|
30
|
+
* Specifically for errors returned from Telnyx's REST API.
|
|
31
|
+
*/
|
|
32
|
+
export class TelnyxError extends Error {
|
|
33
|
+
message;
|
|
34
|
+
type;
|
|
35
|
+
raw;
|
|
36
|
+
headers;
|
|
37
|
+
requestId;
|
|
38
|
+
detail;
|
|
39
|
+
code;
|
|
40
|
+
statusCode;
|
|
41
|
+
responseBody;
|
|
42
|
+
constructor(raw = {}, type = null) {
|
|
43
|
+
super(raw.message);
|
|
44
|
+
this.type = type || this.constructor.name;
|
|
45
|
+
this.raw = raw;
|
|
46
|
+
this.code = raw.code;
|
|
47
|
+
this.detail = raw.detail;
|
|
48
|
+
this.headers = raw.headers;
|
|
49
|
+
this.requestId = raw.requestId;
|
|
50
|
+
this.statusCode = raw.statusCode;
|
|
51
|
+
this.responseBody = raw.responseBody;
|
|
52
|
+
// @ts-expect-error message needs to be required here
|
|
53
|
+
this.message = raw.message;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Helper factory which takes raw Telnyx errors and outputs wrapping instances
|
|
57
|
+
*/
|
|
58
|
+
static generate = generate;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* InvalidRequestError is raised when a request is initiated with invalid
|
|
62
|
+
* parameters.
|
|
63
|
+
*/
|
|
64
|
+
export class TelnyxInvalidRequestError extends TelnyxError {
|
|
65
|
+
constructor(raw = {}) {
|
|
66
|
+
super(raw, 'TelnyxInvalidRequestError');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* APIError is a generic error that may be raised in cases where none of the
|
|
71
|
+
* other named errors cover the problem. It could also be raised in the case
|
|
72
|
+
* that a new error has been introduced in the API, but this version of the
|
|
73
|
+
* Node.JS SDK doesn't know how to handle it.
|
|
74
|
+
*/
|
|
75
|
+
export class TelnyxAPIError extends TelnyxError {
|
|
76
|
+
constructor(raw = {}) {
|
|
77
|
+
super(raw, 'TelnyxAPIError');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* AuthenticationError is raised when invalid credentials are used to connect
|
|
82
|
+
* to Telnyx's servers.
|
|
83
|
+
*/
|
|
84
|
+
export class TelnyxAuthenticationError extends TelnyxError {
|
|
85
|
+
constructor(raw = {}) {
|
|
86
|
+
super(raw, 'TelnyxAuthenticationError');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* PermissionError is raised in cases where access was attempted on a resource
|
|
91
|
+
* that wasn't allowed.
|
|
92
|
+
*/
|
|
93
|
+
export class TelnyxPermissionError extends TelnyxError {
|
|
94
|
+
constructor(raw = {}) {
|
|
95
|
+
super(raw, 'TelnyxPermissionError');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export class TelnyxResourceNotFoundError extends TelnyxError {
|
|
99
|
+
constructor(raw = {}) {
|
|
100
|
+
super(raw, 'TelnyxResourceNotFoundError');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class TelnyxMethodNotSupportedError extends TelnyxError {
|
|
104
|
+
constructor(raw = {}) {
|
|
105
|
+
super(raw, 'TelnyxMethodNotSupportedError');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export class TelnyxTimeoutError extends TelnyxError {
|
|
109
|
+
constructor(raw = {}) {
|
|
110
|
+
super(raw, 'TelnyxTimeoutError');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export class TelnyxUnsupportedMediaTypeError extends TelnyxError {
|
|
114
|
+
constructor(raw = {}) {
|
|
115
|
+
super(raw, 'TelnyxUnsupportedMediaTypeError');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export class TelnyxInvalidParametersError extends TelnyxError {
|
|
119
|
+
constructor(raw = {}) {
|
|
120
|
+
super(raw, 'TelnyxInvalidParametersError');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* RateLimitError is raised in cases where an account is putting too much load
|
|
125
|
+
* on Telnyx's API servers (usually by performing too many requests). Please
|
|
126
|
+
* back off on request rate.
|
|
127
|
+
*/
|
|
128
|
+
export class TelnyxRateLimitError extends TelnyxError {
|
|
129
|
+
constructor(raw = {}) {
|
|
130
|
+
super(raw, 'TelnyxRateLimitError');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export class TelnyxServiceUnavailableError extends TelnyxError {
|
|
134
|
+
constructor(raw = {}) {
|
|
135
|
+
super(raw, 'TelnyxServiceUnavailableError');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* TelnyxConnectionError is raised in the event that the SDK can't connect to
|
|
140
|
+
* Telnyx's servers. That can be for a variety of different reasons from a
|
|
141
|
+
* downed network to a bad TLS certificate.
|
|
142
|
+
*/
|
|
143
|
+
export class TelnyxConnectionError extends TelnyxError {
|
|
144
|
+
constructor(raw = {}) {
|
|
145
|
+
super(raw, 'TelnyxConnectionError');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* SignatureVerificationError is raised when the signature verification for a
|
|
150
|
+
* webhook fails
|
|
151
|
+
*/
|
|
152
|
+
export class TelnyxSignatureVerificationError extends TelnyxError {
|
|
153
|
+
constructor(raw = {}) {
|
|
154
|
+
super(raw, 'TelnyxSignatureVerificationError');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import telnyxMethod from './TelnyxMethod';
|
|
2
|
+
export const create = telnyxMethod({
|
|
3
|
+
method: 'POST',
|
|
4
|
+
});
|
|
5
|
+
export const list = telnyxMethod({
|
|
6
|
+
method: 'GET',
|
|
7
|
+
methodType: 'list',
|
|
8
|
+
});
|
|
9
|
+
export const retrieve = telnyxMethod({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/{id}',
|
|
12
|
+
urlParams: ['id'],
|
|
13
|
+
});
|
|
14
|
+
export const update = telnyxMethod({
|
|
15
|
+
method: 'PATCH',
|
|
16
|
+
path: '{id}',
|
|
17
|
+
urlParams: ['id'],
|
|
18
|
+
});
|
|
19
|
+
// Avoid 'delete' keyword in JS
|
|
20
|
+
export const del = telnyxMethod({
|
|
21
|
+
method: 'DELETE',
|
|
22
|
+
path: '{id}',
|
|
23
|
+
urlParams: ['id'],
|
|
24
|
+
});
|