telnyx 2.0.0-beta.6 → 2.0.1-beta.0

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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## v2
4
4
 
5
+ ### v2.0.1
6
+
7
+ - Add Messaging Inbound Webhook example
8
+ - Add Calls `clientStateUpdate` method
9
+ - Remove usage of `ResponsePayload` generic type with specific types from types definitions, since required types are not accepted
10
+ - Remove `MessagingProfiles` resource `metrics` method
11
+ - Unnest `PhoneNumbers` resource `inboundChannels` method
12
+ - Update all type defs
13
+
14
+ ### v2.0.0
15
+
16
+ - Typescript Support! :tada:
17
+
5
18
  ### v2.0.0-beta.6
6
19
 
7
20
  - Add `connections` example
@@ -394,7 +407,7 @@
394
407
 
395
408
  - **error-handling:** prevent undefined message on error handling
396
409
 
397
- ## v1.0.0 (2019-8-2)
410
+ ### v1.0.0 (2019-8-2)
398
411
 
399
412
  ##### New Features
400
413
 
package/README.md CHANGED
@@ -157,15 +157,16 @@ Telnyx, to the `constructEvent()` function; this will not work with a parsed
157
157
  (i.e., JSON) request body.
158
158
 
159
159
  You can find an example of how to use this with [Express](https://expressjs.com/)
160
- in the [`examples/webhook-signing`](examples/webhook-signing) folder, but here's
160
+ in the [`examples/messaging-inbound-webhook`](examples/messaging-inbound-webhook) folder, but here's
161
161
  what it looks like:
162
162
 
163
163
  ```typescript
164
164
  const event = telnyx.webhooks.constructEvent(
165
- webhookRawBody,
166
- webhookTelnyxSignatureHeader,
165
+ webhookRawBody, // JSON stringified
166
+ webhookTelnyxSignatureHeader, // Buffer from base 64 encoded signature
167
167
  webhookTelnyxTimestampHeader,
168
- publicKey,
168
+ publicKey, // Buffer from base 64 encoded public key
169
+ timeToleranceInSeconds, // Optional, defaults to 300 seconds
169
170
  );
170
171
  ```
171
172
 
@@ -179,11 +180,11 @@ You can find an example of how to use this with [Express](https://expressjs.com/
179
180
  const timeToleranceInSeconds = 300; // Will validate signatures of webhooks up to 5 minutes after Telnyx sent the request
180
181
  try {
181
182
  telnyx.webhooks.signature.verifySignature(
182
- webhookRawBody,
183
- webhookTelnyxSignatureHeader,
183
+ webhookRawBody, // JSON stringified
184
+ webhookTelnyxSignatureHeader, // Buffer from base 64 encoded signature
184
185
  webhookTelnyxTimestampHeader,
185
- publicKey,
186
- timeToleranceInSeconds,
186
+ publicKey, // Buffer from base 64 encoded public key
187
+ timeToleranceInSeconds, // Optional, defaults to 300 seconds
187
188
  );
188
189
  } catch (e) {
189
190
  console.log('Failed to validate the signature');
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0-beta.6
1
+ 2.0.1-beta.0
@@ -56,7 +56,14 @@ function getSpec(callControlId) {
56
56
  }
57
57
  export const Calls = TelnyxResource.extend({
58
58
  path: 'calls',
59
- includeBasic: ['retrieve'], // status method
59
+ retrieve: telnyxMethod({
60
+ method: 'GET',
61
+ path: '/{call_control_id}',
62
+ urlParams: ['call_control_id'],
63
+ transformResponseData: function (response, telnyx) {
64
+ return utils.addResourceToResponseData(response, telnyx, 'calls', utils.createNestedMethods(telnyxMethod, CALL_COMMANDS, getSpec(response.data.call_control_id)));
65
+ },
66
+ }),
60
67
  dial: telnyxMethod({
61
68
  // dial method
62
69
  method: 'POST',
@@ -71,6 +78,11 @@ export const Calls = TelnyxResource.extend({
71
78
  return utils.addResourceToResponseData(response, telnyx, 'calls', utils.createNestedMethods(telnyxMethod, CALL_COMMANDS, getSpec(response.data.call_control_id)));
72
79
  },
73
80
  }),
81
+ clientStateUpdate: telnyxMethod({
82
+ path: '/{call_control_id}/actions/client_state_update',
83
+ urlParams: ['call_control_id'],
84
+ method: 'PUT',
85
+ }),
74
86
  updateClientState: telnyxMethod({
75
87
  path: '/{call_control_id}/actions/client_state_update',
76
88
  urlParams: ['call_control_id'],
@@ -4,7 +4,7 @@ export const Channelzones = TelnyxResource.extend({
4
4
  path: 'channel_zones',
5
5
  includeBasic: ['list'],
6
6
  update: telnyxMethod({
7
- method: 'PATCH',
7
+ method: 'PUT',
8
8
  path: '/{channel_zone_id}',
9
9
  urlParams: ['channel_zone_id'],
10
10
  }),
@@ -13,18 +13,4 @@ export const Channelzones = TelnyxResource.extend({
13
13
  path: '/{channel_zone_id}',
14
14
  urlParams: ['channel_zone_id'],
15
15
  }),
16
- createPhoneNumber: telnyxMethod({
17
- method: 'POST',
18
- path: '/{channel_zone_id}/channel_zone_phone_numbers',
19
- urlParams: ['channel_zone_id'],
20
- }),
21
- listPhoneNumbers: telnyxMethod({
22
- method: 'GET',
23
- path: '/{channel_zone_id}/channel_zone_phone_numbers',
24
- }),
25
- delPhoneNumber: telnyxMethod({
26
- method: 'DELETE',
27
- path: '/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}',
28
- urlParams: ['channel_zone_id', 'phone_number'],
29
- }),
30
16
  });
@@ -1,7 +1,7 @@
1
1
  import TelnyxResource from '../TelnyxResource.js';
2
2
  const telnyxMethod = TelnyxResource.method;
3
- export const PhoneNumbersInboundChannels = TelnyxResource.extend({
4
- path: 'phone_numbers/inbound_channels',
3
+ export const InboundChannels = TelnyxResource.extend({
4
+ path: 'inbound_channels',
5
5
  includeBasic: ['list'],
6
6
  update: telnyxMethod({
7
7
  method: 'PATCH',
@@ -129,10 +129,4 @@ export const MessagingProfiles = TelnyxResource.extend({
129
129
  urlParams: ['profileId', 'autorespCfgId'],
130
130
  paramsNames: ['profileId', 'autorespCfgId'],
131
131
  }),
132
- retrieveMetrics: telnyxMethod({
133
- method: 'GET',
134
- path: '/{id}/metrics',
135
- urlParams: ['id'],
136
- methodType: 'retrieve',
137
- }),
138
132
  });
@@ -2,7 +2,6 @@ import TelnyxResource from '../TelnyxResource.js';
2
2
  import * as utils from '../utils.js';
3
3
  import { PhoneNumbersMessaging } from './PhoneNumbersMessaging.js';
4
4
  import { PhoneNumbersVoice } from './PhoneNumbersVoice.js';
5
- import { PhoneNumbersInboundChannels } from './PhoneNumbersInboundChannels.js';
6
5
  const telnyxMethod = TelnyxResource.method;
7
6
  function transformResponseData(response, telnyx) {
8
7
  return utils.addResourceToResponseData(response, telnyx, 'phoneNumbers', {
@@ -28,7 +27,6 @@ export const PhoneNumbers = TelnyxResource.extend({
28
27
  nestedResources: {
29
28
  Messaging: PhoneNumbersMessaging,
30
29
  Voice: PhoneNumbersVoice,
31
- Inbound: PhoneNumbersInboundChannels,
32
30
  },
33
31
  retrieve: telnyxMethod({
34
32
  method: 'GET',
package/dist/telnyx.js CHANGED
@@ -63,7 +63,6 @@ import { MediaStorageApi } from './resources/MediaStorageApi.js';
63
63
  import { Messages } from './resources/Messages.js';
64
64
  import { MessagingHostedNumberOrders } from './resources/MessagingHostedNumberOrders.js';
65
65
  import { MessagingHostedNumbers } from './resources/MessagingHostedNumbers.js';
66
- import { MessagingProfileMetrics } from './resources/MessagingProfileMetrics.js';
67
66
  import { MessagingProfiles } from './resources/MessagingProfiles.js';
68
67
  import { MessagingShortCodes } from './resources/MessagingShortCodes.js';
69
68
  import { MessagingTollfreeVerification } from './resources/MessagingTollfreeVerification.js';
@@ -87,7 +86,7 @@ import { PhoneNumberBlockOrders } from './resources/PhoneNumberBlockOrders.js';
87
86
  import { PhoneNumberBlocksBackgroundJobs } from './resources/PhoneNumberBlocksBackgroundJobs.js';
88
87
  import { PhoneNumberCampaigns } from './resources/PhoneNumberCampaigns.js';
89
88
  import { PhoneNumbers } from './resources/PhoneNumbers.js';
90
- import { PhoneNumbersInboundChannels } from './resources/PhoneNumbersInboundChannels.js';
89
+ import { InboundChannels } from './resources/InboundChannels.js';
91
90
  import { PhoneNumbersMessaging } from './resources/PhoneNumbersMessaging.js';
92
91
  import { PhoneNumbersRegulatoryRequirements } from './resources/PhoneNumbersRegulatoryRequirements.js';
93
92
  import { PhoneNumbersSlim } from './resources/PhoneNumbersSlim.js';
@@ -216,6 +215,7 @@ export function createTelnyx() {
216
215
  FqdnConnections,
217
216
  Fqdns,
218
217
  GlobalIps,
218
+ InboundChannels,
219
219
  InventoryCoverage,
220
220
  IpConnections,
221
221
  Ips,
@@ -226,7 +226,6 @@ export function createTelnyx() {
226
226
  Messages,
227
227
  MessagingHostedNumberOrders,
228
228
  MessagingHostedNumbers,
229
- MessagingProfileMetrics,
230
229
  MessagingProfiles,
231
230
  MessagingShortCodes,
232
231
  MessagingTollfreeVerification,
@@ -252,7 +251,6 @@ export function createTelnyx() {
252
251
  PhoneNumbersRegulatoryRequirements,
253
252
  PhoneNumbersSlim,
254
253
  PhoneNumbers,
255
- PhoneNumbersInboundChannels,
256
254
  PhoneNumbersMessaging,
257
255
  PhoneNumbersVoice,
258
256
  PhoneNumbersCsvDownloads,
@@ -129,6 +129,10 @@ declare module 'telnyx' {
129
129
  paths['/calls/{call_control_id}/actions/leave_queue']['post']['parameters']['path']['call_control_id'];
130
130
  type CallsLeaveQueueParams =
131
131
  paths['/calls/{call_control_id}/actions/leave_queue']['post']['requestBody']['content']['application/json'];
132
+ type CallsClientStateUpdateId =
133
+ paths['/calls/{call_control_id}/actions/client_state_update']['put']['parameters']['path']['call_control_id'];
134
+ type CallsClientStateUpdateParams =
135
+ paths['/calls/{call_control_id}/actions/client_state_update']['put']['requestBody']['content']['application/json'];
132
136
 
133
137
  type CallsAnswerResponse =
134
138
  paths['/calls/{call_control_id}/actions/answer']['post']['responses']['200']['content']['application/json'];
@@ -186,6 +190,8 @@ declare module 'telnyx' {
186
190
  paths['/calls/{call_control_id}/actions/enqueue']['post']['responses']['200']['content']['application/json'];
187
191
  type CallsLeaveQueueResponse =
188
192
  paths['/calls/{call_control_id}/actions/leave_queue']['post']['responses']['200']['content']['application/json'];
193
+ type CallsClientStateUpdateResponse =
194
+ paths['/calls/{call_control_id}/actions/client_state_update']['put']['responses']['200']['content']['application/json'];
189
195
 
190
196
  type CallsNestedMethods = {
191
197
  answer(
@@ -300,6 +306,10 @@ declare module 'telnyx' {
300
306
  params: CallsLeaveQueueParams,
301
307
  options?: RequestOptions,
302
308
  ): Promise<Telnyx.Response<Telnyx.CallsLeaveQueueResponse>>;
309
+ clientStateUpdate(
310
+ params: CallsClientStateUpdateParams,
311
+ options?: RequestOptions,
312
+ ): Promise<Telnyx.Response<Telnyx.CallsClientStateUpdateResponse>>;
303
313
  };
304
314
 
305
315
  class CallsResource {
@@ -468,6 +478,11 @@ declare module 'telnyx' {
468
478
  params: CallsLeaveQueueParams,
469
479
  options?: RequestOptions,
470
480
  ): Promise<Telnyx.Response<Telnyx.CallsLeaveQueueResponse>>;
481
+ clientStateUpdate(
482
+ id: CallsClientStateUpdateId,
483
+ params: CallsClientStateUpdateParams,
484
+ options?: RequestOptions,
485
+ ): Promise<Telnyx.Response<Telnyx.CallsClientStateUpdateResponse>>;
471
486
  }
472
487
  }
473
488
  }
@@ -9,49 +9,13 @@ declare module 'telnyx' {
9
9
  paths['/channel_zones']['get']['responses']['200']['content']['application/json'];
10
10
 
11
11
  type ChannelzonesUpdateId =
12
- paths['/channel_zones/{channel_zone_id}']['patch']['parameters']['path']['channel_zone_id'];
12
+ paths['/channel_zones/{channel_zone_id}']['put']['parameters']['path']['channel_zone_id'];
13
13
 
14
14
  type ChannelzonesUpdateParams =
15
- paths['/channel_zones/{channel_zone_id}']['patch']['requestBody']['content']['application/json'];
15
+ paths['/channel_zones/{channel_zone_id}']['put']['requestBody']['content']['application/json'];
16
16
 
17
17
  type ChannelzonesUpdateResponse =
18
- paths['/channel_zones/{channel_zone_id}']['patch']['responses']['200']['content']['application/json'];
19
-
20
- type ChannelzonesRetrieveId =
21
- paths['/channel_zones/{channel_zone_id}']['get']['parameters']['path']['channel_zone_id'];
22
-
23
- type ChannelzonesRetrieveParams =
24
- paths['/channel_zones/{channel_zone_id}']['get']['parameters']['query'];
25
-
26
- type ChannelzonesRetrieveResponse =
27
- paths['/channel_zones/{channel_zone_id}']['get']['responses']['200']['content']['application/json'];
28
-
29
- type ChannelzonesPhoneNumbersListChannelzoneId =
30
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['get']['parameters']['path']['channel_zone_id'];
31
-
32
- type ChannelzonesPhoneNumbersListParams =
33
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['get']['parameters']['query'];
34
-
35
- type ChannelzonesPhoneNumbersListResponse =
36
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['get']['responses']['200']['content']['application/json'];
37
-
38
- type ChannelzonesPhoneNumbersCreateChannelZoneId =
39
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['post']['parameters']['path']['channel_zone_id'];
40
-
41
- type ChannelzonesPhoneNumbersCreateParams =
42
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['post']['requestBody']['content']['application/json'];
43
-
44
- type ChannelzonesPhoneNumbersCreateResponse =
45
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['post']['responses']['200']['content']['application/json'];
46
-
47
- type ChannelzonesPhoneNumbersDeleteChannelzoneId =
48
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}']['delete']['parameters']['path']['channel_zone_id'];
49
-
50
- type ChannelzonesPhoneNumbersDeletePhoneNumber =
51
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}']['delete']['parameters']['path']['phone_number'];
52
-
53
- type ChannelzonesPhoneNumbersDeleteResponse =
54
- paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}']['delete']['responses']['200']['content'];
18
+ paths['/channel_zones/{channel_zone_id}']['put']['responses']['200']['content']['application/json'];
55
19
 
56
20
  class ChannelzonesResource {
57
21
  list(
@@ -64,33 +28,6 @@ declare module 'telnyx' {
64
28
  params: ChannelzonesUpdateParams,
65
29
  options?: RequestOptions,
66
30
  ): Promise<Telnyx.Response<Telnyx.ChannelzonesUpdateResponse>>;
67
-
68
- retrieve(
69
- id: ChannelzonesRetrieveId,
70
- options?: RequestOptions,
71
- ): Promise<Telnyx.Response<Telnyx.ChannelzonesRetrieveResponse>>;
72
-
73
- listPhoneNumbers(
74
- id: ChannelzonesPhoneNumbersListChannelzoneId,
75
- params?: ChannelzonesPhoneNumbersListParams,
76
- options?: RequestOptions,
77
- ): Promise<Telnyx.Response<Telnyx.ChannelzonesPhoneNumbersListResponse>>;
78
-
79
- createPhoneNumber(
80
- id: ChannelzonesPhoneNumbersCreateChannelZoneId,
81
- params: ChannelzonesPhoneNumbersCreateParams,
82
- options?: RequestOptions,
83
- ): Promise<
84
- Telnyx.Response<Telnyx.ChannelzonesPhoneNumbersCreateResponse>
85
- >;
86
-
87
- delPhoneNumber(
88
- id: ChannelzonesPhoneNumbersDeleteChannelzoneId,
89
- phoneNumber: ChannelzonesPhoneNumbersDeletePhoneNumber,
90
- options?: RequestOptions,
91
- ): Promise<
92
- Telnyx.Response<Telnyx.ChannelzonesPhoneNumbersDeleteResponse>
93
- >;
94
31
  }
95
32
  }
96
33
  }
@@ -24,7 +24,7 @@ declare module 'telnyx' {
24
24
  paths['/documents/{id}']['patch']['parameters']['path']['id'];
25
25
 
26
26
  type DocumentsUpdateParams =
27
- paths['/documents/{id}']['patch']['requestBody']['content']['application/json'];
27
+ NonNullable<paths['/documents/{id}']['patch']['requestBody']>['content']['application/json'];
28
28
 
29
29
  type DocumentsUpdateResponse =
30
30
  paths['/documents/{id}']['patch']['responses']['200']['content']['application/json'];
@@ -42,7 +42,7 @@ declare module 'telnyx' {
42
42
  paths['/documents/{id}/download']['get']['parameters']['path']['id'];
43
43
 
44
44
  type DocumentsDownloadResponse =
45
- paths['/documents/{id}/download']['get']['responses']['200']['content']['*'];
45
+ paths['/documents/{id}/download']['get']['responses']['200']['content']['*/*'];
46
46
 
47
47
  class DocumentsResource {
48
48
  list(
@@ -55,6 +55,16 @@ declare module 'telnyx' {
55
55
  components['schemas']['CallSiprecStartedEvent'];
56
56
  type CallSiprecStoppedEvent =
57
57
  components['schemas']['CallSiprecStoppedEvent'];
58
+ type CallAIGatherMessageHistoryUpdatedEvent =
59
+ components['schemas']['CallAIGatherMessageHistoryUpdatedEvent'];
60
+ type CallAIGatherPartialResultsEvent =
61
+ components['schemas']['CallAIGatherPartialResultsEvent'];
62
+ type CallConversationEndedEvent =
63
+ components['schemas']['callConversationEndedEvent'];
64
+ type CallConversationInsightsGeneratedEvent =
65
+ components['schemas']['callConversationInsightsGeneratedEvent'];
66
+ type CallRecordingTranscriptionSavedEvent =
67
+ components['schemas']['callRecordingTranscriptionSavedEvent'];
58
68
  type ConferenceCreatedEvent =
59
69
  components['schemas']['ConferenceCreatedEvent'];
60
70
  type ConferenceEndedEvent = components['schemas']['ConferenceEndedEvent'];
@@ -88,7 +98,6 @@ declare module 'telnyx' {
88
98
  type NotificationEvent = components['schemas']['NotificationEvent'];
89
99
  type NumberOrderBlockEvent =
90
100
  components['schemas']['NumberOrderBlockEvent'];
91
- type NumberOrderedEvent = components['schemas']['NumberOrderedEvent'];
92
101
  type OutboundMessageEvent = components['schemas']['OutboundMessageEvent'];
93
102
  type PortingEvent = components['schemas']['PortingEvent'];
94
103
  type PortoutEvent = components['schemas']['PortoutEvent'];
@@ -3,18 +3,18 @@ import {paths} from './TelnyxAPI.js';
3
3
  declare module 'telnyx' {
4
4
  namespace Telnyx {
5
5
  type PhoneNumbersInboundChannelsListParams =
6
- paths['/phone_numbers/inbound_channels']['get']['parameters']['query'];
6
+ paths['/inbound_channels']['get']['parameters']['query'];
7
7
 
8
8
  type PhoneNumbersInboundChannelsListResponse =
9
- paths['/phone_numbers/inbound_channels']['get']['responses']['200']['content']['application/json'];
9
+ paths['/inbound_channels']['get']['responses']['200']['content']['application/json'];
10
10
 
11
11
  type PhoneNumbersInboundChannelsUpdateParams =
12
- paths['/phone_numbers/inbound_channels']['patch']['requestBody']['content']['application/json'];
12
+ paths['/inbound_channels']['patch']['requestBody']['content']['application/json'];
13
13
 
14
14
  type PhoneNumbersInboundChannelsUpdateResponse =
15
- paths['/phone_numbers/inbound_channels']['patch']['responses']['200']['content']['application/json'];
15
+ paths['/inbound_channels']['patch']['responses']['200']['content']['application/json'];
16
16
 
17
- class PhoneNumbersInboundChannelsResource {
17
+ class InboundChannelsResource {
18
18
  list(
19
19
  params?: PhoneNumbersInboundChannelsListParams,
20
20
  options?: RequestOptions,
@@ -59,15 +59,6 @@ declare module 'telnyx' {
59
59
  type MessagingProfilesListShortCodesResponse =
60
60
  paths['/messaging_profiles/{id}/short_codes']['get']['responses']['200']['content']['application/json'];
61
61
 
62
- type MessagingProfilesRetrieveMetricsId =
63
- paths['/messaging_profiles/{id}/metrics']['get']['parameters']['path']['id'];
64
-
65
- type MessagingProfilesRetrieveMetricsParams =
66
- paths['/messaging_profiles/{id}/metrics']['get']['parameters']['query'];
67
-
68
- type MessagingProfilesRetrieveMetricsResponse =
69
- paths['/messaging_profiles/{id}/metrics']['get']['responses']['200']['content']['application/json'];
70
-
71
62
  type MessagingProfilesListAutorespConfigsId =
72
63
  paths['/messaging_profiles/{profile_id}/autoresp_configs']['get']['parameters']['path']['profile_id'];
73
64
 
@@ -141,13 +132,6 @@ declare module 'telnyx' {
141
132
  ): Promise<
142
133
  Telnyx.Response<Telnyx.MessagingProfilesListAutorespConfigsResponse>
143
134
  >;
144
-
145
- retrieveMetrics(
146
- params: MessagingProfilesRetrieveMetricsParams,
147
- options?: RequestOptions,
148
- ): Promise<
149
- Telnyx.Response<Telnyx.MessagingProfilesRetrieveMetricsResponse>
150
- >;
151
135
  };
152
136
 
153
137
  class MessagingProfilesResource {
@@ -209,14 +193,6 @@ declare module 'telnyx' {
209
193
  Telnyx.Response<Telnyx.MessagingProfilesListShortCodesResponse>
210
194
  >;
211
195
 
212
- retrieveMetrics(
213
- id: MessagingProfilesRetrieveMetricsId,
214
- params: MessagingProfilesRetrieveMetricsParams,
215
- options?: RequestOptions,
216
- ): Promise<
217
- Telnyx.Response<Telnyx.MessagingProfilesRetrieveMetricsResponse>
218
- >;
219
-
220
196
  listAutorespConfigs(
221
197
  id: MessagingProfilesListAutorespConfigsId,
222
198
  params: MessagingProfilesListAutorespConfigsParams,