telnyx 2.0.0-alpha.0 → 2.0.0-alpha.2
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 +9 -0
- package/README.md +0 -1
- package/VERSION +1 -1
- package/dist/Error.js +156 -0
- package/{src/TelnyxMethod.basic.ts → dist/TelnyxMethod.basic.js} +12 -17
- package/{src/TelnyxMethod.ts → dist/TelnyxMethod.js} +32 -58
- 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/{src/resources/AccessIpAddress.ts → dist/resources/AccessIpAddress.js} +2 -3
- package/{src/resources/AccessIpRanges.ts → dist/resources/AccessIpRanges.js} +2 -3
- 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/AiAssistants.js +21 -0
- package/dist/resources/AiAudioTranscriptions.js +5 -0
- package/dist/resources/AiChatCompletions.js +5 -0
- package/dist/resources/AiEmbeddings.js +11 -0
- package/dist/resources/AiEmbeddingsBuckets.js +16 -0
- package/dist/resources/AiEmbeddingsSimilaritySearch.js +5 -0
- package/dist/resources/AiModels.js +5 -0
- package/dist/resources/AiSummarize.js +5 -0
- package/{src/resources/AuthenticationProviders.ts → dist/resources/AuthenticationProviders.js} +2 -3
- package/dist/resources/AutorespConfigs.js +11 -0
- package/{src/resources/AvailablePhoneNumbers.ts → dist/resources/AvailablePhoneNumbers.js} +2 -3
- package/{src/resources/Balance.ts → dist/resources/Balance.js} +2 -3
- package/{src/resources/BillingGroups.ts → dist/resources/BillingGroups.js} +2 -3
- 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/{src/resources/CallEvents.ts → dist/resources/CallEvents.js} +2 -3
- 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/{src/resources/ClientStateUpdate.ts → dist/resources/ClientStateUpdate.js} +2 -3
- package/dist/resources/Conferences.js +46 -0
- package/{src/resources/Connections.ts → dist/resources/Connections.js} +2 -3
- package/{src/resources/CredentialConnections.ts → dist/resources/CredentialConnections.js} +2 -3
- 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/{src/resources/DetailRecords.ts → dist/resources/DetailRecords.js} +5 -7
- package/dist/resources/DialogflowIntegration.js +10 -0
- package/{src/resources/DocumentLinks.ts → dist/resources/DocumentLinks.js} +2 -3
- package/dist/resources/Documents.js +44 -0
- package/dist/resources/DynamicEmergency.js +9 -0
- package/{src/resources/DynamicEmergencyAddresses.ts → dist/resources/DynamicEmergencyAddresses.js} +2 -3
- package/{src/resources/DynamicEmergencyEndpoints.ts → dist/resources/DynamicEmergencyEndpoints.js} +2 -3
- package/{src/resources/Events.ts → dist/resources/Events.js} +2 -3
- 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/{src/resources/InventoryCoverage.ts → dist/resources/InventoryCoverage.js} +5 -7
- 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/{src/resources/MessagesAlphanumericSenderId.ts → dist/resources/MessagesAlphanumericSenderId.js} +2 -3
- package/dist/resources/MessagingHostedNumber.js +25 -0
- package/{src/resources/MessagingHostedNumberOrders.ts → dist/resources/MessagingHostedNumberOrders.js} +2 -3
- package/{src/resources/MessagingHostedNumbers.ts → dist/resources/MessagingHostedNumbers.js} +2 -3
- package/{src/resources/MessagingPhoneNumbers.ts → dist/resources/MessagingPhoneNumbers.js} +2 -3
- package/{src/resources/MessagingProfileMetrics.ts → dist/resources/MessagingProfileMetrics.js} +2 -3
- package/dist/resources/MessagingProfiles.js +81 -0
- package/dist/resources/MessagingSenderIds.js +5 -0
- package/{src/resources/MessagingShortCodes.ts → dist/resources/MessagingShortCodes.js} +2 -3
- package/dist/resources/MessagingTollfreeVerification.js +15 -0
- package/dist/resources/MessagingUrlDomains.js +10 -0
- package/dist/resources/MobileNetworkOperators.js +10 -0
- package/{src/resources/MobileOperatorNetworks.ts → dist/resources/MobileOperatorNetworks.js} +2 -3
- package/dist/resources/Networks.js +22 -0
- package/dist/resources/NumberBackgroundJobs.js +18 -0
- package/{src/resources/NumberLookup.ts → dist/resources/NumberLookup.js} +2 -3
- package/dist/resources/NumberOrderDocuments.js +10 -0
- package/{src/resources/NumberOrders.ts → dist/resources/NumberOrders.js} +2 -3
- 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/{src/resources/PhoneNumberRegulatoryRequirements.ts → dist/resources/PhoneNumberRegulatoryRequirements.js} +2 -4
- package/dist/resources/PhoneNumberSearch.js +14 -0
- package/dist/resources/PhoneNumbers.js +41 -0
- package/dist/resources/PhoneNumbersInboundChannels.js +23 -0
- package/{src/resources/PhoneNumbersMessaging.ts → dist/resources/PhoneNumbersMessaging.js} +2 -3
- package/{src/resources/PhoneNumbersVoice.ts → dist/resources/PhoneNumbersVoice.js} +2 -3
- package/{src/resources/PortabilityChecks.ts → dist/resources/PortabilityChecks.js} +4 -6
- package/dist/resources/PortingOrders.js +85 -0
- package/{src/resources/PortingPhoneNumbers.ts → dist/resources/PortingPhoneNumbers.js} +2 -3
- 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/{src/resources/PublicKey.ts → dist/resources/PublicKey.js} +4 -6
- 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/{src/resources/RegulatoryRequirements.ts → dist/resources/RegulatoryRequirements.js} +2 -4
- package/dist/resources/Reporting.js +14 -0
- package/dist/resources/Reports.js +14 -0
- package/{src/resources/ReportsMdrs.ts → dist/resources/ReportsMdrs.js} +2 -3
- package/dist/resources/RequirementTypes.js +14 -0
- package/dist/resources/Requirements.js +14 -0
- package/{src/resources/RoomCompositions.ts → dist/resources/RoomCompositions.js} +2 -3
- package/{src/resources/RoomParticipants.ts → dist/resources/RoomParticipants.js} +2 -3
- package/dist/resources/RoomRecordings.js +15 -0
- package/dist/resources/RoomSessions.js +38 -0
- package/{src/resources/Rooms.ts → dist/resources/Rooms.js} +2 -3
- 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/{src/resources/SimCardOrders.ts → dist/resources/SimCardOrders.js} +2 -3
- package/dist/resources/SimCards.js +103 -0
- package/dist/resources/StorageBuckets.js +30 -0
- package/dist/resources/TelephonyCredentials.js +35 -0
- package/{src/resources/TexmlApplications.ts → dist/resources/TexmlApplications.js} +2 -3
- package/dist/resources/UpdateClientState.js +14 -0
- package/dist/resources/Verifications.js +53 -0
- package/{src/resources/VerifiedNumbers.ts → dist/resources/VerifiedNumbers.js} +2 -3
- 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/{src/resources/Webhooks.ts → dist/resources/Webhooks.js} +2 -3
- package/dist/resources/WireguardInterfaces.js +34 -0
- package/{src/resources/WirelessDetailRecordReports.ts → dist/resources/WirelessDetailRecordReports.js} +2 -3
- package/dist/telnyx.js +567 -0
- package/{types → dist/types}/AccessIpRangesResource.d.ts +1 -1
- package/{types → dist/types}/AddressesResource.d.ts +5 -5
- package/dist/types/AiAssistantsResource.d.ts +69 -0
- package/dist/types/AiAudioTranscriptionsResource.d.ts +18 -0
- package/dist/types/AiChatCompletionsResource.d.ts +18 -0
- package/dist/types/AiEmbeddingsBucketsResource.d.ts +46 -0
- package/dist/types/AiEmbeddingsResource.d.ts +43 -0
- package/dist/types/AiEmbeddingsSimilaritySearchResource.d.ts +20 -0
- package/dist/types/AiModelsResource.d.ts +17 -0
- package/dist/types/AiSummarizeResource.d.ts +18 -0
- package/{types → dist/types}/AutorespConfigsResource.d.ts +4 -4
- package/{types → dist/types}/AvailablePhoneNumbersResource.d.ts +1 -1
- package/{types → dist/types}/BalanceResource.d.ts +1 -1
- package/{types → dist/types}/BillingGroupsResource.d.ts +5 -5
- package/{types → dist/types}/CallsResource.d.ts +30 -30
- package/{types → dist/types}/MessagingProfileMetricsResource.d.ts +1 -1
- package/{types → dist/types}/MessagingProfilesResource.d.ts +8 -8
- package/{types → dist/types}/StorageBucketsResource.d.ts +5 -5
- package/{types → dist/types}/index.d.ts +17 -0
- package/{types → dist/types}/lib.d.ts +1 -1
- package/dist/utils.js +277 -0
- package/package.json +1 -1
- package/src/Error.ts +0 -196
- package/src/TelnyxResource.ts +0 -556
- package/src/Types.d.ts +0 -244
- package/src/Webhooks.ts +0 -98
- package/src/autoPagination.ts +0 -315
- package/src/makeRequest.ts +0 -163
- package/src/multipart.ts +0 -99
- package/src/resources/AI.ts +0 -43
- package/src/resources/Actions.ts +0 -9
- package/src/resources/ActionsSimCards.ts +0 -16
- package/src/resources/ActivateDeactivateBulkCredentials.ts +0 -22
- package/src/resources/Addresses.ts +0 -51
- package/src/resources/AutorespConfigs.ts +0 -13
- package/src/resources/Brands.ts +0 -68
- package/src/resources/BulkCredentials.ts +0 -17
- package/src/resources/BulkSoleProprietorCreation.ts +0 -22
- package/src/resources/BulkTelephonyCredentials.ts +0 -49
- package/src/resources/BusinessIdentity.ts +0 -17
- package/src/resources/CallControlApplications.ts +0 -57
- package/src/resources/CallInformation.ts +0 -12
- package/src/resources/CallRecordings.ts +0 -24
- package/src/resources/Calls.ts +0 -94
- package/src/resources/Campaign.ts +0 -87
- package/src/resources/CampaignBuilder.ts +0 -43
- package/src/resources/CdrUsageReports.ts +0 -12
- package/src/resources/Channelzones.ts +0 -24
- package/src/resources/Conferences.ts +0 -67
- package/src/resources/Credentials.ts +0 -26
- package/src/resources/CsvDownloads.ts +0 -17
- package/src/resources/CustomerServiceRecord.ts +0 -20
- package/src/resources/Debugging.ts +0 -12
- package/src/resources/DialogflowIntegration.ts +0 -12
- package/src/resources/Documents.ts +0 -53
- package/src/resources/DynamicEmergency.ts +0 -10
- package/src/resources/ExternalConnections.ts +0 -73
- package/src/resources/FaxApplications.ts +0 -53
- package/src/resources/Faxes.ts +0 -51
- package/src/resources/FqdnConnections.ts +0 -53
- package/src/resources/Fqdns.ts +0 -53
- package/src/resources/GlobalIps.ts +0 -44
- package/src/resources/InboundChannels.ts +0 -12
- package/src/resources/InventoryLevel.ts +0 -12
- package/src/resources/IpAddresses.ts +0 -17
- package/src/resources/IpConnections.ts +0 -53
- package/src/resources/IpRanges.ts +0 -17
- package/src/resources/Ips.ts +0 -53
- package/src/resources/ManagedAccounts.ts +0 -60
- package/src/resources/MdrDetailReports.ts +0 -21
- package/src/resources/MdrUsageReports.ts +0 -21
- package/src/resources/MediaStorageApi.ts +0 -20
- package/src/resources/Messages.ts +0 -11
- package/src/resources/MessagingHostedNumber.ts +0 -27
- package/src/resources/MessagingProfiles.ts +0 -112
- package/src/resources/MessagingSenderIds.ts +0 -6
- package/src/resources/MessagingTollfreeVerification.ts +0 -17
- package/src/resources/MessagingUrlDomains.ts +0 -12
- package/src/resources/MobileNetworkOperators.ts +0 -12
- package/src/resources/Networks.ts +0 -24
- package/src/resources/NumberBackgroundJobs.ts +0 -22
- package/src/resources/NumberOrderDocuments.ts +0 -12
- package/src/resources/NumberPortouts.ts +0 -74
- package/src/resources/NumberReservations.ts +0 -30
- package/src/resources/NumbersFeatures.ts +0 -12
- package/src/resources/Object.ts +0 -18
- package/src/resources/OtaUpdates.ts +0 -16
- package/src/resources/OutboundVoiceProfiles.ts +0 -63
- package/src/resources/Payment.ts +0 -16
- package/src/resources/PhoneNumberAssignmentByProfile.ts +0 -74
- package/src/resources/PhoneNumberBlockOrders.ts +0 -17
- package/src/resources/PhoneNumberBlocksBackgroundJobs.ts +0 -21
- package/src/resources/PhoneNumberCampaigns.ts +0 -17
- package/src/resources/PhoneNumberOrderDocuments.ts +0 -17
- package/src/resources/PhoneNumberSearch.ts +0 -16
- package/src/resources/PhoneNumbers.ts +0 -49
- package/src/resources/PhoneNumbersInboundChannels.ts +0 -37
- package/src/resources/PortingOrders.ts +0 -105
- package/src/resources/PortoutRequests.ts +0 -51
- package/src/resources/PresignedObjectUrls.ts +0 -13
- package/src/resources/PrivateWirelessGateways.ts +0 -16
- package/src/resources/PublicInternetGateways.ts +0 -16
- package/src/resources/PushCredentials.ts +0 -17
- package/src/resources/Queues.ts +0 -68
- package/src/resources/RecordingsCommands.ts +0 -13
- package/src/resources/Regions.ts +0 -12
- package/src/resources/Reporting.ts +0 -16
- package/src/resources/Reports.ts +0 -16
- package/src/resources/RequirementTypes.ts +0 -16
- package/src/resources/Requirements.ts +0 -16
- package/src/resources/RoomRecordings.ts +0 -17
- package/src/resources/RoomSessions.ts +0 -41
- package/src/resources/RoomsClientToken.ts +0 -16
- package/src/resources/RoomsClientTokens.ts +0 -18
- package/src/resources/SharedCampaigns.ts +0 -17
- package/src/resources/ShortCodes.ts +0 -37
- package/src/resources/SimCardActions.ts +0 -24
- package/src/resources/SimCardGroupActions.ts +0 -16
- package/src/resources/SimCardGroups.ts +0 -53
- package/src/resources/SimCards.ts +0 -126
- package/src/resources/StorageBuckets.ts +0 -36
- package/src/resources/TelephonyCredentials.ts +0 -57
- package/src/resources/UpdateClientState.ts +0 -25
- package/src/resources/Verifications.ts +0 -70
- package/src/resources/Verify.ts +0 -52
- package/src/resources/VerifyProfiles.ts +0 -62
- package/src/resources/VirtualCrossConnects.ts +0 -28
- package/src/resources/WdrDetailReports.ts +0 -12
- package/src/resources/WireguardInterfaces.ts +0 -36
- package/src/telnyx.node.ts +0 -5
- package/src/telnyx.ts +0 -636
- package/src/utils.ts +0 -383
- /package/{types → dist/types}/AccessIpAddressResource.d.ts +0 -0
- /package/{types → dist/types}/BrandsResource.d.ts +0 -0
- /package/{types → dist/types}/Errors.d.ts +0 -0
- /package/{types → dist/types}/PhoneNumberAssignmentByProfileResource.d.ts +0 -0
- /package/{types → dist/types}/TelnyxAPI.d.ts +0 -0
- /package/{types → dist/types}/Webhooks.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## v2
|
|
4
4
|
|
|
5
|
+
### v2.0.0-alpha.2
|
|
6
|
+
|
|
7
|
+
- Fix `AI` resource methods and created nested structure
|
|
8
|
+
|
|
9
|
+
### v2.0.0-alpha.1
|
|
10
|
+
|
|
11
|
+
- Update actions workflow versions to v4 and `.npmignore` to v2
|
|
12
|
+
- Update examples dependencies
|
|
13
|
+
|
|
5
14
|
### v2.0.0-alpha.0
|
|
6
15
|
|
|
7
16
|
- Add Typescript default config, linter and dependencies
|
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
|
-
Coverage Status: Pending
|
|
6
5
|
[](https://www.npmjs.com/package/telnyx)
|
|
7
6
|
[](https://runkit.com/npm/telnyx)
|
|
8
7
|
[](https://joinslack.telnyx.com/)
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.0.0-alpha.
|
|
1
|
+
2.0.0-alpha.2
|
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
|
+
}
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import telnyxMethod from './TelnyxMethod';
|
|
2
|
-
|
|
3
2
|
export const create = telnyxMethod({
|
|
4
|
-
|
|
3
|
+
method: 'POST',
|
|
5
4
|
});
|
|
6
|
-
|
|
7
5
|
export const list = telnyxMethod({
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
method: 'GET',
|
|
7
|
+
methodType: 'list',
|
|
10
8
|
});
|
|
11
|
-
|
|
12
9
|
export const retrieve = telnyxMethod({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/{id}',
|
|
12
|
+
urlParams: ['id'],
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
export const update = telnyxMethod({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
method: 'PATCH',
|
|
16
|
+
path: '{id}',
|
|
17
|
+
urlParams: ['id'],
|
|
22
18
|
});
|
|
23
|
-
|
|
24
19
|
// Avoid 'delete' keyword in JS
|
|
25
20
|
export const del = telnyxMethod({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
method: 'DELETE',
|
|
22
|
+
path: '{id}',
|
|
23
|
+
urlParams: ['id'],
|
|
29
24
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {MethodSpec, TelnyxResourceObject} from './Types';
|
|
2
1
|
import * as utils from './utils';
|
|
3
2
|
import makeRequest from './makeRequest';
|
|
4
|
-
import {makeAutoPaginationMethods} from './autoPagination';
|
|
5
|
-
|
|
3
|
+
import { makeAutoPaginationMethods } from './autoPagination';
|
|
6
4
|
/**
|
|
7
5
|
* Create an API method from the declared spec.
|
|
8
6
|
*
|
|
@@ -22,66 +20,42 @@ import {makeAutoPaginationMethods} from './autoPagination';
|
|
|
22
20
|
* @param [spec.host] Hostname for the request.
|
|
23
21
|
* @param [spec.transformResponseData] mutates response data to decorate with any util functions or info.
|
|
24
22
|
*/
|
|
25
|
-
function telnyxMethod(
|
|
26
|
-
|
|
27
|
-
): (...args: unknown[]) => Promise<unknown> {
|
|
28
|
-
return function (
|
|
29
|
-
this: TelnyxResourceObject,
|
|
23
|
+
function telnyxMethod(spec) {
|
|
24
|
+
return function (
|
|
30
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
...args
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (spec.methodType === 'list') {
|
|
45
|
-
const autoPaginationMethods = makeAutoPaginationMethods(
|
|
46
|
-
this,
|
|
47
|
-
args,
|
|
48
|
-
spec,
|
|
49
|
-
requestPromise,
|
|
50
|
-
);
|
|
51
|
-
Object.assign(requestPromise, autoPaginationMethods);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return requestPromise;
|
|
55
|
-
};
|
|
26
|
+
...args // needs to be any since callback is extracted from these args and there's no easy way to type all args
|
|
27
|
+
) {
|
|
28
|
+
if (spec.paramsValues) {
|
|
29
|
+
populateUrlParamsWithResource(this, args, spec);
|
|
30
|
+
}
|
|
31
|
+
const callback = typeof args[args.length - 1] == 'function' && args.pop();
|
|
32
|
+
const requestPromise = utils.callbackifyPromiseWithTimeout(makeRequest(this, args, spec, {}), callback);
|
|
33
|
+
if (spec.methodType === 'list') {
|
|
34
|
+
const autoPaginationMethods = makeAutoPaginationMethods(this, args, spec, requestPromise);
|
|
35
|
+
Object.assign(requestPromise, autoPaginationMethods);
|
|
36
|
+
}
|
|
37
|
+
return requestPromise;
|
|
38
|
+
};
|
|
56
39
|
}
|
|
57
|
-
|
|
58
40
|
/**
|
|
59
41
|
* Populate nested method URL params with resource object attributes that match the param name.
|
|
60
42
|
* This allows you to do things like setting the `call_control_id` attribute from an existing call object on a new instance of `telnyx.calls`.
|
|
61
43
|
*/
|
|
62
|
-
function populateUrlParamsWithResource(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return result;
|
|
79
|
-
}, []);
|
|
80
|
-
|
|
81
|
-
args.unshift(paramsValues);
|
|
82
|
-
} else {
|
|
83
|
-
args.unshift(spec.paramsValues);
|
|
84
|
-
}
|
|
44
|
+
function populateUrlParamsWithResource(self, args, spec) {
|
|
45
|
+
// if url params is not in resource response data.
|
|
46
|
+
if (spec.paramsValues && !spec.paramsValues[0]) {
|
|
47
|
+
const paramsValues = (spec.paramsNames || []).reduce(function (result, name) {
|
|
48
|
+
// @ts-expect-error TODO: cast name to index of self
|
|
49
|
+
if (self[name]) {
|
|
50
|
+
// @ts-expect-error TODO: cast name to index of self
|
|
51
|
+
result.push(self[name]);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}, []);
|
|
55
|
+
args.unshift(paramsValues);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
args.unshift(spec.paramsValues);
|
|
59
|
+
}
|
|
85
60
|
}
|
|
86
|
-
|
|
87
61
|
export default telnyxMethod;
|