telnyx 2.0.0-alpha.7 → 2.0.0-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,16 @@
2
2
 
3
3
  ## v2
4
4
 
5
+ ### v2.0.0-beta.0
6
+
7
+ - Move `AutorespConfigs` resource to be nested in `MessagingProfiles`
8
+ - Fix nested resources in `Calls`, `MessagingProfiles` and `Conferences` ID usage instead of using constructors data
9
+ - Fix nested resources `Calls`, `MessagingProfiles` and `Conferences` method names
10
+ - Fix `Brand` resources method name
11
+ - Fix bug on `DELETE` operations empty `responseBody` JSON Parsing
12
+ - Update types on resources methods with multiple urlParams
13
+ - FIX: README Typo by @mpareja-godaddy in https://github.com/team-telnyx/telnyx-node/pull/186
14
+
5
15
  ### v2.0.0-alpha.7
6
16
 
7
17
  - Export API callback `events` type definitions
package/README.md CHANGED
@@ -43,7 +43,7 @@ callback:
43
43
 
44
44
  ```typescript
45
45
  // Create a new messaging profile and then send a message using that profile:
46
- telnyx.,essagingProfiles.create({
46
+ telnyx.messagingProfiles.create({
47
47
  name: 'Summer Campaign',
48
48
  })
49
49
  .then((messagingProfile) => {
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0-alpha.7
1
+ 2.0.0-beta.0
@@ -123,7 +123,11 @@ TelnyxResource.prototype = {
123
123
  let responseBody;
124
124
  try {
125
125
  responseBody = utils.tryParseJSON(response);
126
- if (responseBody.errors) {
126
+ // JSON response might be empty on deletion operations
127
+ if (!responseBody) {
128
+ responseBody = {};
129
+ }
130
+ else if (responseBody.errors) {
127
131
  const error = {};
128
132
  error.errors =
129
133
  responseBody.errors;
@@ -30,7 +30,7 @@ export const Brands = TelnyxResource.extend({
30
30
  urlParams: ['brandId'],
31
31
  methodType: 'list',
32
32
  }),
33
- exportExternalVettings: telnyxMethod({
33
+ importExternalVettings: telnyxMethod({
34
34
  method: 'PUT',
35
35
  path: '/brand/{brandId}/externalVetting',
36
36
  urlParams: ['brandId'],
@@ -32,12 +32,23 @@ const CALL_COMMANDS = [
32
32
  'leave_queue',
33
33
  ];
34
34
  function getSpec(callControlId) {
35
+ if (callControlId) {
36
+ return function (methodName) {
37
+ return {
38
+ method: 'POST',
39
+ path: `/{call_control_id}/actions/${methodName}`,
40
+ urlParams: ['call_control_id'],
41
+ paramsValues: [callControlId],
42
+ paramsNames: ['call_control_id'],
43
+ methodType: 'create',
44
+ };
45
+ };
46
+ }
35
47
  return function (methodName) {
36
48
  return {
37
49
  method: 'POST',
38
50
  path: `/{call_control_id}/actions/${methodName}`,
39
51
  urlParams: ['call_control_id'],
40
- paramsValues: [callControlId],
41
52
  paramsNames: ['call_control_id'],
42
53
  methodType: 'create',
43
54
  };
@@ -1,7 +1,7 @@
1
1
  import TelnyxResource from '../TelnyxResource';
2
2
  import * as utils from '../utils';
3
3
  const telnyxMethod = TelnyxResource.method;
4
- const CONFERENCES = [
4
+ const CONFERENCES_COMMANDS = [
5
5
  'join',
6
6
  'mute',
7
7
  'unmute',
@@ -18,17 +18,37 @@ const CONFERENCES = [
18
18
  'record_pause',
19
19
  ];
20
20
  function getSpec(conferenceId) {
21
+ if (conferenceId) {
22
+ return function (methodName) {
23
+ return {
24
+ method: 'POST',
25
+ path: `/{conferenceId}/actions/${methodName}`,
26
+ urlParams: ['conferenceId'],
27
+ paramsValues: [conferenceId],
28
+ paramsNames: ['conferenceId'],
29
+ methodType: 'create',
30
+ };
31
+ };
32
+ }
21
33
  return function (methodName) {
22
34
  return {
23
35
  method: 'POST',
24
36
  path: `/{conferenceId}/actions/${methodName}`,
25
37
  urlParams: ['conferenceId'],
26
- paramsValues: [conferenceId],
27
- paramsNames: ['id'],
38
+ paramsNames: ['conferenceId'],
28
39
  methodType: 'create',
29
40
  };
30
41
  };
31
42
  }
43
+ const transformResponseData = (response, telnyx) => {
44
+ const methods = utils.createNestedMethods(telnyxMethod, CONFERENCES_COMMANDS, getSpec(response.data.id));
45
+ methods.listParticipants = telnyxMethod({
46
+ method: 'GET',
47
+ path: '/{conferenceId}/participants',
48
+ urlParams: ['conferenceId'],
49
+ });
50
+ return utils.addResourceToResponseData(response, telnyx, 'conferences', methods);
51
+ };
32
52
  export const Conferences = TelnyxResource.extend({
33
53
  path: 'conferences',
34
54
  includeBasic: ['list'],
@@ -36,20 +56,16 @@ export const Conferences = TelnyxResource.extend({
36
56
  method: 'GET',
37
57
  path: '/{id}',
38
58
  urlParams: ['id'],
39
- transformResponseData: function (response, telnyx) {
40
- return utils.addResourceToResponseData(response, telnyx, 'conferences', utils.createNestedMethods(telnyxMethod, CONFERENCES, getSpec(response.data.id)));
41
- },
59
+ transformResponseData: transformResponseData,
42
60
  }),
43
61
  create: telnyxMethod({
44
62
  method: 'POST',
45
- transformResponseData: function (response, telnyx) {
46
- return utils.addResourceToResponseData(response, telnyx, 'conferences', utils.createNestedMethods(telnyxMethod, CONFERENCES, getSpec(response.data.id)));
47
- },
63
+ transformResponseData: transformResponseData,
48
64
  }),
49
- participants: telnyxMethod({
65
+ listParticipants: telnyxMethod({
50
66
  method: 'GET',
51
67
  path: '/{conferenceId}/participants',
52
68
  urlParams: ['conferenceId'],
53
69
  }),
54
- instanceMethods: utils.createNestedMethods(telnyxMethod, CONFERENCES, getSpec()),
70
+ instanceMethods: utils.createNestedMethods(telnyxMethod, CONFERENCES_COMMANDS, getSpec()),
55
71
  });
@@ -1,7 +1,7 @@
1
1
  import TelnyxResource from '../TelnyxResource';
2
2
  import * as utils from '../utils';
3
3
  const telnyxMethod = TelnyxResource.method;
4
- const ACTIONS = ['phone_numbers', 'short_codes', 'metrics', 'autoresp_configs'];
4
+ const MESSAGING_PROFILES_COMMANDS = ['phone_numbers', 'short_codes'];
5
5
  function getSpec(messagingProfileId) {
6
6
  return function (methodName) {
7
7
  return {
@@ -9,19 +9,65 @@ function getSpec(messagingProfileId) {
9
9
  path: `/{messagingProfileId}/${methodName}`,
10
10
  urlParams: ['messagingProfileId'],
11
11
  paramsValues: [messagingProfileId],
12
- paramsNames: ['id'],
12
+ paramsNames: ['messagingProfileId'],
13
13
  methodType: 'list',
14
14
  };
15
15
  };
16
16
  }
17
17
  const transformResponseData = (response, telnyx) => {
18
- const methods = utils.createNestedMethods(telnyxMethod, ACTIONS, getSpec(response.data.id));
18
+ const methods = utils.createNestedMethods(telnyxMethod, MESSAGING_PROFILES_COMMANDS, getSpec(response.data.id));
19
19
  methods.del = telnyxMethod({
20
20
  method: 'DELETE',
21
21
  path: '/{messagingProfileId}',
22
22
  urlParams: ['messagingProfileId'],
23
23
  paramsValues: [response.data.id],
24
- paramsNames: ['id'],
24
+ paramsNames: ['messagingProfileId'],
25
+ });
26
+ methods.listAutorespConfigs = telnyxMethod({
27
+ method: 'GET',
28
+ path: '/{profileId}/autoresp_configs',
29
+ urlParams: ['profileId'],
30
+ paramsValues: [response.data.id],
31
+ paramsNames: ['profileId'],
32
+ methodType: 'list',
33
+ });
34
+ methods.createAutorespConfig = telnyxMethod({
35
+ method: 'POST',
36
+ path: '/{profileId}/autoresp_configs',
37
+ urlParams: ['profileId'],
38
+ paramsValues: [response.data.id],
39
+ paramsNames: ['profileId'],
40
+ methodType: 'create',
41
+ });
42
+ methods.delAutorespConfig = telnyxMethod({
43
+ method: 'DELETE',
44
+ path: '/{profileId}/autoresp_configs/{autorespCfgId}',
45
+ paramsValues: [response.data.id],
46
+ urlParams: ['profileId', 'autorespCfgId'],
47
+ paramsNames: ['profileId', 'autorespCfgId'],
48
+ });
49
+ methods.retrieveAutorespConfig = telnyxMethod({
50
+ method: 'GET',
51
+ path: '/{profileId}/autoresp_configs/{autorespCfgId}',
52
+ paramsValues: [response.data.id],
53
+ urlParams: ['profileId', 'autorespCfgId'],
54
+ paramsNames: ['profileId', 'autorespCfgId'],
55
+ methodType: 'retrieve',
56
+ });
57
+ methods.updateAutorespConfig = telnyxMethod({
58
+ method: 'PUT',
59
+ path: '/{profileId}/autoresp_configs/{autorespCfgId}',
60
+ paramsValues: [response.data.id],
61
+ urlParams: ['profileId', 'autorespCfgId'],
62
+ paramsNames: ['profileId', 'autorespCfgId'],
63
+ });
64
+ methods.retrieveMetrics = telnyxMethod({
65
+ method: 'GET',
66
+ path: '/{messagingProfileId}/metrics',
67
+ urlParams: ['messagingProfileId'],
68
+ paramsValues: [response.data.id],
69
+ paramsNames: ['messagingProfileId'],
70
+ methodType: 'retrieve',
25
71
  });
26
72
  return utils.addResourceToResponseData(response, telnyx, 'messagingProfiles', methods);
27
73
  };
@@ -44,38 +90,49 @@ export const MessagingProfiles = TelnyxResource.extend({
44
90
  urlParams: ['messagingProfileId'],
45
91
  methodType: 'list',
46
92
  }),
47
- phoneNumbers: telnyxMethod({
48
- method: 'GET',
49
- path: '/{messagingProfileId}/phone_numbers',
50
- urlParams: ['messagingProfileId'],
51
- }),
52
93
  listShortCodes: telnyxMethod({
53
94
  method: 'GET',
54
95
  path: '/{messagingProfileId}/short_codes',
55
96
  urlParams: ['messagingProfileId'],
56
97
  methodType: 'list',
57
98
  }),
58
- shortCodes: telnyxMethod({
99
+ listAutorespConfigs: telnyxMethod({
59
100
  method: 'GET',
60
- path: '/{messagingProfileId}/short_codes',
61
- urlParams: ['messagingProfileId'],
101
+ path: '/{profileId}/autoresp_configs',
102
+ urlParams: ['profileId'],
103
+ paramsNames: ['profileId'],
104
+ methodType: 'list',
62
105
  }),
63
- retrieveMetrics: telnyxMethod({
106
+ createAutorespConfig: telnyxMethod({
107
+ method: 'POST',
108
+ path: '/{profileId}/autoresp_configs',
109
+ urlParams: ['profileId'],
110
+ paramsNames: ['profileId'],
111
+ methodType: 'create',
112
+ }),
113
+ delAutorespConfig: telnyxMethod({
114
+ method: 'DELETE',
115
+ path: '/{profileId}/autoresp_configs/{autorespCfgId}',
116
+ urlParams: ['profileId', 'autorespCfgId'],
117
+ paramsNames: ['profileId', 'autorespCfgId'],
118
+ }),
119
+ retrieveAutorespConfig: telnyxMethod({
64
120
  method: 'GET',
65
- path: '/{messagingProfileId}/metrics',
66
- urlParams: ['messagingProfileId'],
121
+ path: '/{profileId}/autoresp_configs/{autorespCfgId}',
122
+ urlParams: ['profileId', 'autorespCfgId'],
123
+ paramsNames: ['profileId', 'autorespCfgId'],
67
124
  methodType: 'retrieve',
68
125
  }),
69
- autorespConfigs: telnyxMethod({
70
- method: 'GET',
71
- path: '/{messagingProfileId}/autoresp_configs',
72
- urlParams: ['messagingProfileId'],
73
- methodType: 'list',
126
+ updateAutorespConfig: telnyxMethod({
127
+ method: 'PUT',
128
+ path: '/{profileId}/autoresp_configs/{autorespCfgId}',
129
+ urlParams: ['profileId', 'autorespCfgId'],
130
+ paramsNames: ['profileId', 'autorespCfgId'],
74
131
  }),
75
- listAutorespConfigs: telnyxMethod({
132
+ retrieveMetrics: telnyxMethod({
76
133
  method: 'GET',
77
- path: '/{messagingProfileId}/autoresp_configs',
78
- urlParams: ['messagingProfileId'],
79
- methodType: 'list',
134
+ path: '/{id}/metrics',
135
+ urlParams: ['id'],
136
+ methodType: 'retrieve',
80
137
  }),
81
138
  });
package/dist/telnyx.js CHANGED
@@ -10,7 +10,6 @@ import { Actions } from './resources/Actions';
10
10
  import { ActionsSimCards } from './resources/ActionsSimCards';
11
11
  import { ActivateDeactivateBulkCredentials } from './resources/ActivateDeactivateBulkCredentials';
12
12
  import { Addresses } from './resources/Addresses';
13
- import { AutorespConfigs } from './resources/AutorespConfigs';
14
13
  import { AiAssistants } from './resources/AiAssistants';
15
14
  import { AiAudioTranscriptions } from './resources/AiAudioTranscriptions';
16
15
  import { AiChatCompletions } from './resources/AiChatCompletions';
@@ -173,7 +172,6 @@ export function createTelnyx() {
173
172
  ActionsSimCards,
174
173
  ActivateDeactivateBulkCredentials,
175
174
  Addresses,
176
- AutorespConfigs,
177
175
  AiAssistants,
178
176
  AiAudioTranscriptions,
179
177
  AiChatCompletions,
@@ -40,29 +40,29 @@ declare module 'telnyx' {
40
40
  type BrandsUpdateResponse =
41
41
  paths['/brand/{brandId}']['put']['responses']['200']['content']['application/json'];
42
42
 
43
- type BrandsResend2faEmailPathParams =
44
- paths['/brand/{brandId}/2faEmail']['post']['parameters']['path'];
43
+ type BrandsResend2faEmailId =
44
+ paths['/brand/{brandId}/2faEmail']['post']['parameters']['path']['brandId'];
45
45
 
46
46
  type BrandsResend2faEmailResponse =
47
47
  paths['/brand/{brandId}/2faEmail']['post']['responses']['200']['content'];
48
48
 
49
- type BrandsListExternalVettingsPathParams =
50
- paths['/brand/{brandId}/externalVetting']['get']['parameters']['path'];
49
+ type BrandsListExternalVettingsId =
50
+ paths['/brand/{brandId}/externalVetting']['get']['parameters']['path']['brandId'];
51
51
 
52
52
  type BrandsListExternalVettingsResponse =
53
53
  paths['/brand/{brandId}/externalVetting']['get']['responses']['200']['content']['application/json'];
54
54
 
55
- type BrandsExportExternalVettingsPathParams =
56
- paths['/brand/{brandId}/externalVetting']['put']['parameters']['path'];
55
+ type BrandsImportExternalVettingsId =
56
+ paths['/brand/{brandId}/externalVetting']['put']['parameters']['path']['brandId'];
57
57
 
58
- type BrandsExportExternalVettingsParams =
58
+ type BrandsImportExternalVettingsParams =
59
59
  paths['/brand/{brandId}/externalVetting']['put']['requestBody']['content']['application/json'];
60
60
 
61
- type BrandsExportExternalVettingsResponse =
61
+ type BrandsImportExternalVettingsResponse =
62
62
  paths['/brand/{brandId}/externalVetting']['put']['responses']['200']['content']['application/json'];
63
63
 
64
- type BrandsOrderExternalVettingsPathParams =
65
- paths['/brand/{brandId}/externalVetting']['post']['parameters']['path'];
64
+ type BrandsOrderExternalVettingsId =
65
+ paths['/brand/{brandId}/externalVetting']['post']['parameters']['path']['brandId'];
66
66
 
67
67
  type BrandsOrderExternalVettingsParams =
68
68
  paths['/brand/{brandId}/externalVetting']['post']['requestBody']['content']['application/json'];
@@ -70,8 +70,8 @@ declare module 'telnyx' {
70
70
  type BrandsOrderExternalVettingsResponse =
71
71
  paths['/brand/{brandId}/externalVetting']['post']['responses']['200']['content']['application/json'];
72
72
 
73
- type BrandsRevetPathParams =
74
- paths['/brand/{brandId}/revet']['put']['parameters']['path'];
73
+ type BrandsRevetid =
74
+ paths['/brand/{brandId}/revet']['put']['parameters']['path']['brandId'];
75
75
 
76
76
  type BrandsRevetParams =
77
77
  paths['/brand/{brandId}/externalVetting']['put']['requestBody']['content']['application/json'];
@@ -79,10 +79,10 @@ declare module 'telnyx' {
79
79
  type BrandsRevetResponse =
80
80
  paths['/brand/{brandId}/revet']['put']['responses']['200']['content']['application/json'];
81
81
 
82
- type BrandsFeedbackPathParams =
83
- paths['/brand/feedback/{brandId}']['get']['parameters']['path'];
82
+ type BrandsFeedbackRetrieveId =
83
+ paths['/brand/feedback/{brandId}']['get']['parameters']['path']['brandId'];
84
84
 
85
- type BrandsFeedbackResponse =
85
+ type BrandsFeedbackRetrieveResponse =
86
86
  paths['/brand/feedback/{brandId}']['get']['responses']['200']['content']['application/json'];
87
87
 
88
88
  class BrandsResource {
@@ -113,37 +113,37 @@ declare module 'telnyx' {
113
113
  ): Promise<Telnyx.Response<Telnyx.BrandsUpdateResponse>>;
114
114
 
115
115
  resend2faEmail(
116
- pathParams: BrandsResend2faEmailPathParams,
116
+ id: BrandsResend2faEmailId,
117
117
  options?: RequestOptions,
118
118
  ): Promise<Telnyx.Response<Telnyx.BrandsResend2faEmailResponse>>;
119
119
 
120
120
  listExternalVettings(
121
- pathParams: BrandsListExternalVettingsPathParams,
121
+ id: BrandsListExternalVettingsId,
122
122
  options?: RequestOptions,
123
123
  ): Promise<Telnyx.Response<Telnyx.BrandsListExternalVettingsResponse>>;
124
124
 
125
- exportExternalVettings(
126
- pathParams: BrandsExportExternalVettingsPathParams,
127
- params: BrandsExportExternalVettingsParams,
125
+ importExternalVettings(
126
+ id: BrandsImportExternalVettingsId,
127
+ params: BrandsImportExternalVettingsParams,
128
128
  options?: RequestOptions,
129
- ): Promise<Telnyx.Response<Telnyx.BrandsExportExternalVettingsResponse>>;
129
+ ): Promise<Telnyx.Response<Telnyx.BrandsImportExternalVettingsResponse>>;
130
130
 
131
131
  orderExternalVettings(
132
- pathParams: BrandsOrderExternalVettingsPathParams,
132
+ id: BrandsOrderExternalVettingsId,
133
133
  params: BrandsOrderExternalVettingsParams,
134
134
  options?: RequestOptions,
135
135
  ): Promise<Telnyx.Response<Telnyx.BrandsOrderExternalVettingsResponse>>;
136
136
 
137
137
  revet(
138
- pathParams: BrandsRevetPathParams,
138
+ id: BrandsRevetid,
139
139
  params: BrandsRevetParams,
140
140
  options?: RequestOptions,
141
141
  ): Promise<Telnyx.Response<Telnyx.BrandsRevetResponse>>;
142
142
 
143
- feedback(
144
- pathParams: BrandsFeedbackPathParams,
143
+ retrieveFeedback(
144
+ id: BrandsFeedbackRetrieveId,
145
145
  options?: RequestOptions,
146
- ): Promise<Telnyx.Response<Telnyx.BrandsFeedbackResponse>>;
146
+ ): Promise<Telnyx.Response<Telnyx.BrandsFeedbackRetrieveResponse>>;
147
147
  }
148
148
  }
149
149
  }