retell-sdk 2.2.2 → 2.2.4

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.
Files changed (145) hide show
  1. package/example.js +61 -7
  2. package/example.js.map +1 -1
  3. package/lib/config.d.ts.map +1 -1
  4. package/lib/config.js.map +1 -1
  5. package/lib/sdks.d.ts.map +1 -1
  6. package/lib/sdks.js.map +1 -1
  7. package/lib/security.d.ts.map +1 -1
  8. package/lib/security.js +5 -1
  9. package/lib/security.js.map +1 -1
  10. package/models/components/agent.d.ts +62 -0
  11. package/models/components/agent.d.ts.map +1 -1
  12. package/models/components/agent.js +95 -15
  13. package/models/components/agent.js.map +1 -1
  14. package/models/components/agentpromptparams.d.ts.map +1 -1
  15. package/models/components/agentpromptparams.js.map +1 -1
  16. package/models/components/calldetail.d.ts.map +1 -1
  17. package/models/components/calldetail.js +18 -6
  18. package/models/components/calldetail.js.map +1 -1
  19. package/models/components/callphonenumber.d.ts.map +1 -1
  20. package/models/components/callphonenumber.js.map +1 -1
  21. package/models/components/phonenumber.d.ts.map +1 -1
  22. package/models/components/phonenumber.js.map +1 -1
  23. package/models/components/security.d.ts.map +1 -1
  24. package/models/errors/createagent.d.ts.map +1 -1
  25. package/models/errors/createagent.js +36 -12
  26. package/models/errors/createagent.js.map +1 -1
  27. package/models/errors/createphonecall.d.ts.map +1 -1
  28. package/models/errors/createphonecall.js +54 -18
  29. package/models/errors/createphonecall.js.map +1 -1
  30. package/models/errors/createphonenumber.d.ts.map +1 -1
  31. package/models/errors/createphonenumber.js +42 -14
  32. package/models/errors/createphonenumber.js.map +1 -1
  33. package/models/errors/deleteagent.d.ts.map +1 -1
  34. package/models/errors/deleteagent.js +36 -12
  35. package/models/errors/deleteagent.js.map +1 -1
  36. package/models/errors/deletephonenumber.d.ts.map +1 -1
  37. package/models/errors/deletephonenumber.js +33 -11
  38. package/models/errors/deletephonenumber.js.map +1 -1
  39. package/models/errors/getagent.d.ts.map +1 -1
  40. package/models/errors/getagent.js +36 -12
  41. package/models/errors/getagent.js.map +1 -1
  42. package/models/errors/getcall.d.ts.map +1 -1
  43. package/models/errors/getcall.js +30 -10
  44. package/models/errors/getcall.js.map +1 -1
  45. package/models/errors/getphonenumber.d.ts.map +1 -1
  46. package/models/errors/getphonenumber.js +36 -12
  47. package/models/errors/getphonenumber.js.map +1 -1
  48. package/models/errors/listagents.d.ts.map +1 -1
  49. package/models/errors/listagents.js +15 -5
  50. package/models/errors/listagents.js.map +1 -1
  51. package/models/errors/listcalls.d.ts.map +1 -1
  52. package/models/errors/listcalls.js +24 -8
  53. package/models/errors/listcalls.js.map +1 -1
  54. package/models/errors/listphonenumbers.d.ts.map +1 -1
  55. package/models/errors/listphonenumbers.js +27 -9
  56. package/models/errors/listphonenumbers.js.map +1 -1
  57. package/models/errors/updateagent.d.ts.map +1 -1
  58. package/models/errors/updateagent.js +36 -12
  59. package/models/errors/updateagent.js.map +1 -1
  60. package/models/errors/updatephoneagent.d.ts.map +1 -1
  61. package/models/errors/updatephoneagent.js +36 -12
  62. package/models/errors/updatephoneagent.js.map +1 -1
  63. package/models/operations/createagent.d.ts +7 -0
  64. package/models/operations/createagent.d.ts.map +1 -1
  65. package/models/operations/createagent.js +18 -4
  66. package/models/operations/createagent.js.map +1 -1
  67. package/models/operations/createphonecall.d.ts.map +1 -1
  68. package/models/operations/createphonecall.js +18 -6
  69. package/models/operations/createphonecall.js.map +1 -1
  70. package/models/operations/createphonenumber.d.ts.map +1 -1
  71. package/models/operations/createphonenumber.js +6 -2
  72. package/models/operations/createphonenumber.js.map +1 -1
  73. package/models/operations/createwebcall.d.ts.map +1 -1
  74. package/models/operations/deleteagent.d.ts.map +1 -1
  75. package/models/operations/deleteagent.js.map +1 -1
  76. package/models/operations/deletephonenumber.d.ts.map +1 -1
  77. package/models/operations/deletephonenumber.js.map +1 -1
  78. package/models/operations/getagent.d.ts.map +1 -1
  79. package/models/operations/getagent.js.map +1 -1
  80. package/models/operations/getcall.d.ts.map +1 -1
  81. package/models/operations/getcall.js.map +1 -1
  82. package/models/operations/getphonenumber.d.ts.map +1 -1
  83. package/models/operations/getphonenumber.js +6 -2
  84. package/models/operations/getphonenumber.js.map +1 -1
  85. package/models/operations/listagents.d.ts.map +1 -1
  86. package/models/operations/listagents.js.map +1 -1
  87. package/models/operations/listcalls.d.ts.map +1 -1
  88. package/models/operations/listcalls.js +6 -2
  89. package/models/operations/listcalls.js.map +1 -1
  90. package/models/operations/listphonenumbers.d.ts.map +1 -1
  91. package/models/operations/listphonenumbers.js +6 -2
  92. package/models/operations/listphonenumbers.js.map +1 -1
  93. package/models/operations/updateagent.d.ts +7 -0
  94. package/models/operations/updateagent.d.ts.map +1 -1
  95. package/models/operations/updateagent.js +22 -4
  96. package/models/operations/updateagent.js.map +1 -1
  97. package/models/operations/updatephoneagent.d.ts.map +1 -1
  98. package/models/operations/updatephoneagent.js +6 -2
  99. package/models/operations/updatephoneagent.js.map +1 -1
  100. package/package.json +1 -1
  101. package/sdk/liveClient.d.ts.map +1 -1
  102. package/sdk/liveClient.js +7 -2
  103. package/sdk/liveClient.js.map +1 -1
  104. package/sdk/sdk.d.ts.map +1 -1
  105. package/sdk/sdk.js +22 -5
  106. package/sdk/sdk.js.map +1 -1
  107. package/src/example.ts +122 -65
  108. package/src/lib/config.ts +32 -32
  109. package/src/lib/sdks.ts +91 -82
  110. package/src/lib/security.ts +133 -118
  111. package/src/models/components/agent.ts +482 -303
  112. package/src/models/components/agentpromptparams.ts +46 -38
  113. package/src/models/components/calldetail.ts +137 -125
  114. package/src/models/components/callphonenumber.ts +46 -38
  115. package/src/models/components/phonenumber.ts +69 -68
  116. package/src/models/components/security.ts +1 -1
  117. package/src/models/errors/createagent.ts +359 -311
  118. package/src/models/errors/createphonecall.ts +537 -472
  119. package/src/models/errors/createphonenumber.ts +447 -395
  120. package/src/models/errors/deleteagent.ts +359 -311
  121. package/src/models/errors/deletephonenumber.ts +357 -315
  122. package/src/models/errors/getagent.ts +358 -302
  123. package/src/models/errors/getcall.ts +348 -294
  124. package/src/models/errors/getphonenumber.ts +357 -312
  125. package/src/models/errors/listagents.ts +174 -147
  126. package/src/models/errors/listcalls.ts +251 -211
  127. package/src/models/errors/listphonenumbers.ts +252 -217
  128. package/src/models/errors/updateagent.ts +359 -311
  129. package/src/models/errors/updatephoneagent.ts +357 -312
  130. package/src/models/operations/createagent.ts +166 -119
  131. package/src/models/operations/createphonecall.ts +283 -238
  132. package/src/models/operations/createphonenumber.ts +118 -98
  133. package/src/models/operations/createwebcall.ts +13 -13
  134. package/src/models/operations/deleteagent.ts +94 -78
  135. package/src/models/operations/deletephonenumber.ts +94 -78
  136. package/src/models/operations/getagent.ts +104 -88
  137. package/src/models/operations/getcall.ts +101 -88
  138. package/src/models/operations/getphonenumber.ts +108 -88
  139. package/src/models/operations/listagents.ts +68 -60
  140. package/src/models/operations/listcalls.ts +238 -213
  141. package/src/models/operations/listphonenumbers.ts +72 -60
  142. package/src/models/operations/updateagent.ts +227 -163
  143. package/src/models/operations/updatephoneagent.ts +160 -132
  144. package/src/sdk/liveClient.ts +11 -7
  145. package/src/sdk/sdk.ts +1313 -1160
package/src/sdk/sdk.ts CHANGED
@@ -11,1181 +11,1334 @@ import * as operations from "../models/operations";
11
11
  import { LiveClient } from "./liveClient";
12
12
 
13
13
  export class RetellClient extends ClientSDK {
14
- private readonly options$: SDKOptions;
15
-
16
- constructor(options: SDKOptions = {}) {
17
- super({
18
- client: options.httpClient || new HTTPClient(),
19
- baseURL: serverURLFromOptions(options),
14
+ private readonly options$: SDKOptions;
15
+
16
+ constructor(options: SDKOptions = {}) {
17
+ super({
18
+ client: options.httpClient || new HTTPClient(),
19
+ baseURL: serverURLFromOptions(options),
20
+ });
21
+
22
+ this.options$ = options;
23
+ void this.options$;
24
+ }
25
+
26
+ async createWebCall(
27
+ input: operations.CreateWebCallRequestBody,
28
+ ): Promise<LiveClient> {
29
+ const liveClient = new LiveClient(
30
+ this.options$.apiKey as unknown as string,
31
+ input,
32
+ );
33
+ await liveClient.waitForReady();
34
+ return liveClient;
35
+ }
36
+
37
+ /**
38
+ * Create a new agent
39
+ */
40
+ async createAgent(
41
+ input: operations.CreateAgentRequestBody,
42
+ options?: RequestOptions,
43
+ ): Promise<operations.CreateAgentResponse> {
44
+ const headers$ = new Headers();
45
+ headers$.set("user-agent", SDK_METADATA.userAgent);
46
+ headers$.set("Content-Type", "application/json");
47
+ headers$.set("Accept", "application/json");
48
+
49
+ const payload$ =
50
+ operations.CreateAgentRequestBody$.outboundSchema.parse(input);
51
+ const body$ = enc$.encodeJSON("body", payload$, { explode: true });
52
+
53
+ const path$ = this.templateURLComponent("/create-agent")();
54
+
55
+ let security$;
56
+ if (typeof this.options$.apiKey === "function") {
57
+ security$ = { apiKey: await this.options$.apiKey() };
58
+ } else if (this.options$.apiKey) {
59
+ security$ = { apiKey: this.options$.apiKey };
60
+ } else {
61
+ security$ = {};
62
+ }
63
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
64
+
65
+ const response = await this.fetch$(
66
+ {
67
+ security: securitySettings$,
68
+ method: "post",
69
+ path: path$,
70
+ headers: headers$,
71
+ body: body$,
72
+ },
73
+ options,
74
+ );
75
+
76
+ const responseFields$ = {
77
+ ContentType:
78
+ response.headers.get("content-type") ?? "application/octet-stream",
79
+ StatusCode: response.status,
80
+ RawResponse: response,
81
+ };
82
+
83
+ if (this.matchResponse(response, 201, "application/json")) {
84
+ const responseBody = await response.json();
85
+ const result = operations.CreateAgentResponse$.inboundSchema.parse({
86
+ ...responseFields$,
87
+ Agent: responseBody,
88
+ });
89
+ return result;
90
+ } else if (this.matchResponse(response, 400, "application/json")) {
91
+ const responseBody = await response.json();
92
+ const result = errors.CreateAgentResponseBody$.inboundSchema.parse({
93
+ ...responseFields$,
94
+ ...responseBody,
95
+ });
96
+ throw result;
97
+ } else if (this.matchResponse(response, 401, "application/json")) {
98
+ const responseBody = await response.json();
99
+ const result =
100
+ errors.CreateAgentResponseResponseBody$.inboundSchema.parse({
101
+ ...responseFields$,
102
+ ...responseBody,
20
103
  });
21
-
22
- this.options$ = options;
23
- void this.options$;
104
+ throw result;
105
+ } else if (this.matchResponse(response, 422, "application/json")) {
106
+ const responseBody = await response.json();
107
+ const result =
108
+ errors.CreateAgentResponse422ResponseBody$.inboundSchema.parse({
109
+ ...responseFields$,
110
+ ...responseBody,
111
+ });
112
+ throw result;
113
+ } else if (this.matchResponse(response, 500, "application/json")) {
114
+ const responseBody = await response.json();
115
+ const result =
116
+ errors.CreateAgentResponse500ResponseBody$.inboundSchema.parse({
117
+ ...responseFields$,
118
+ ...responseBody,
119
+ });
120
+ throw result;
121
+ } else {
122
+ const responseBody = await response.text();
123
+ throw new errors.SDKError(
124
+ "Unexpected API response",
125
+ response,
126
+ responseBody,
127
+ );
24
128
  }
25
-
26
- async createWebCall(
27
- input: operations.CreateWebCallRequestBody
28
- ): Promise<LiveClient> {
29
- const liveClient = new LiveClient(
30
- this.options$.apiKey as unknown as string,
31
- input
32
- );
33
- await liveClient.waitForReady();
34
- return liveClient;
35
- }
36
-
37
- /**
38
- * Create a new agent
39
- */
40
- async createAgent(
41
- input: operations.CreateAgentRequestBody,
42
- options?: RequestOptions
43
- ): Promise<operations.CreateAgentResponse> {
44
- const headers$ = new Headers();
45
- headers$.set("user-agent", SDK_METADATA.userAgent);
46
- headers$.set("Content-Type", "application/json");
47
- headers$.set("Accept", "application/json");
48
-
49
- const payload$ = operations.CreateAgentRequestBody$.outboundSchema.parse(input);
50
- const body$ = enc$.encodeJSON("body", payload$, { explode: true });
51
-
52
- const path$ = this.templateURLComponent("/create-agent")();
53
-
54
- let security$;
55
- if (typeof this.options$.apiKey === "function") {
56
- security$ = { apiKey: await this.options$.apiKey() };
57
- } else if (this.options$.apiKey) {
58
- security$ = { apiKey: this.options$.apiKey };
59
- } else {
60
- security$ = {};
61
- }
62
- const securitySettings$ = this.resolveGlobalSecurity(security$);
63
-
64
- const response = await this.fetch$(
65
- {
66
- security: securitySettings$,
67
- method: "post",
68
- path: path$,
69
- headers: headers$,
70
- body: body$,
71
- },
72
- options
73
- );
74
-
75
- const responseFields$ = {
76
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
77
- StatusCode: response.status,
78
- RawResponse: response,
79
- };
80
-
81
- if (this.matchResponse(response, 201, "application/json")) {
82
- const responseBody = await response.json();
83
- const result = operations.CreateAgentResponse$.inboundSchema.parse({
84
- ...responseFields$,
85
- Agent: responseBody,
86
- });
87
- return result;
88
- } else if (this.matchResponse(response, 400, "application/json")) {
89
- const responseBody = await response.json();
90
- const result = errors.CreateAgentResponseBody$.inboundSchema.parse({
91
- ...responseFields$,
92
- ...responseBody,
93
- });
94
- throw result;
95
- } else if (this.matchResponse(response, 401, "application/json")) {
96
- const responseBody = await response.json();
97
- const result = errors.CreateAgentResponseResponseBody$.inboundSchema.parse({
98
- ...responseFields$,
99
- ...responseBody,
100
- });
101
- throw result;
102
- } else if (this.matchResponse(response, 422, "application/json")) {
103
- const responseBody = await response.json();
104
- const result = errors.CreateAgentResponse422ResponseBody$.inboundSchema.parse({
105
- ...responseFields$,
106
- ...responseBody,
107
- });
108
- throw result;
109
- } else if (this.matchResponse(response, 500, "application/json")) {
110
- const responseBody = await response.json();
111
- const result = errors.CreateAgentResponse500ResponseBody$.inboundSchema.parse({
112
- ...responseFields$,
113
- ...responseBody,
114
- });
115
- throw result;
116
- } else {
117
- const responseBody = await response.text();
118
- throw new errors.SDKError("Unexpected API response", response, responseBody);
119
- }
129
+ }
130
+
131
+ /**
132
+ * Initiate an outbound phone call.
133
+ */
134
+ async createPhoneCall(
135
+ input: operations.CreatePhoneCallRequestBody,
136
+ options?: RequestOptions,
137
+ ): Promise<operations.CreatePhoneCallResponse> {
138
+ const headers$ = new Headers();
139
+ headers$.set("user-agent", SDK_METADATA.userAgent);
140
+ headers$.set("Content-Type", "application/json");
141
+ headers$.set("Accept", "application/json");
142
+
143
+ const payload$ =
144
+ operations.CreatePhoneCallRequestBody$.outboundSchema.parse(input);
145
+ const body$ = enc$.encodeJSON("body", payload$, { explode: true });
146
+
147
+ const path$ = this.templateURLComponent("/create-phone-call")();
148
+
149
+ let security$;
150
+ if (typeof this.options$.apiKey === "function") {
151
+ security$ = { apiKey: await this.options$.apiKey() };
152
+ } else if (this.options$.apiKey) {
153
+ security$ = { apiKey: this.options$.apiKey };
154
+ } else {
155
+ security$ = {};
120
156
  }
121
-
122
- /**
123
- * Initiate an outbound phone call.
124
- */
125
- async createPhoneCall(
126
- input: operations.CreatePhoneCallRequestBody,
127
- options?: RequestOptions
128
- ): Promise<operations.CreatePhoneCallResponse> {
129
- const headers$ = new Headers();
130
- headers$.set("user-agent", SDK_METADATA.userAgent);
131
- headers$.set("Content-Type", "application/json");
132
- headers$.set("Accept", "application/json");
133
-
134
- const payload$ = operations.CreatePhoneCallRequestBody$.outboundSchema.parse(input);
135
- const body$ = enc$.encodeJSON("body", payload$, { explode: true });
136
-
137
- const path$ = this.templateURLComponent("/create-phone-call")();
138
-
139
- let security$;
140
- if (typeof this.options$.apiKey === "function") {
141
- security$ = { apiKey: await this.options$.apiKey() };
142
- } else if (this.options$.apiKey) {
143
- security$ = { apiKey: this.options$.apiKey };
144
- } else {
145
- security$ = {};
146
- }
147
- const securitySettings$ = this.resolveGlobalSecurity(security$);
148
-
149
- const response = await this.fetch$(
150
- {
151
- security: securitySettings$,
152
- method: "post",
153
- path: path$,
154
- headers: headers$,
155
- body: body$,
156
- },
157
- options
158
- );
159
-
160
- const responseFields$ = {
161
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
162
- StatusCode: response.status,
163
- RawResponse: response,
164
- };
165
-
166
- if (this.matchResponse(response, 201, "application/json")) {
167
- const responseBody = await response.json();
168
- const result = operations.CreatePhoneCallResponse$.inboundSchema.parse({
169
- ...responseFields$,
170
- callDetail: responseBody,
171
- });
172
- return result;
173
- } else if (this.matchResponse(response, 400, "application/json")) {
174
- const responseBody = await response.json();
175
- const result = errors.CreatePhoneCallResponseBody$.inboundSchema.parse({
176
- ...responseFields$,
177
- ...responseBody,
178
- });
179
- throw result;
180
- } else if (this.matchResponse(response, 401, "application/json")) {
181
- const responseBody = await response.json();
182
- const result = errors.CreatePhoneCallResponseResponseBody$.inboundSchema.parse({
183
- ...responseFields$,
184
- ...responseBody,
185
- });
186
- throw result;
187
- } else if (this.matchResponse(response, 402, "application/json")) {
188
- const responseBody = await response.json();
189
- const result = errors.CreatePhoneCallResponse402ResponseBody$.inboundSchema.parse({
190
- ...responseFields$,
191
- ...responseBody,
192
- });
193
- throw result;
194
- } else if (this.matchResponse(response, 422, "application/json")) {
195
- const responseBody = await response.json();
196
- const result = errors.CreatePhoneCallResponse422ResponseBody$.inboundSchema.parse({
197
- ...responseFields$,
198
- ...responseBody,
199
- });
200
- throw result;
201
- } else if (this.matchResponse(response, 429, "application/json")) {
202
- const responseBody = await response.json();
203
- const result = errors.CreatePhoneCallResponse429ResponseBody$.inboundSchema.parse({
204
- ...responseFields$,
205
- ...responseBody,
206
- });
207
- throw result;
208
- } else if (this.matchResponse(response, 500, "application/json")) {
209
- const responseBody = await response.json();
210
- const result = errors.CreatePhoneCallResponse500ResponseBody$.inboundSchema.parse({
211
- ...responseFields$,
212
- ...responseBody,
213
- });
214
- throw result;
215
- } else {
216
- const responseBody = await response.text();
217
- throw new errors.SDKError("Unexpected API response", response, responseBody);
218
- }
157
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
158
+
159
+ const response = await this.fetch$(
160
+ {
161
+ security: securitySettings$,
162
+ method: "post",
163
+ path: path$,
164
+ headers: headers$,
165
+ body: body$,
166
+ },
167
+ options,
168
+ );
169
+
170
+ const responseFields$ = {
171
+ ContentType:
172
+ response.headers.get("content-type") ?? "application/octet-stream",
173
+ StatusCode: response.status,
174
+ RawResponse: response,
175
+ };
176
+
177
+ if (this.matchResponse(response, 201, "application/json")) {
178
+ const responseBody = await response.json();
179
+ const result = operations.CreatePhoneCallResponse$.inboundSchema.parse({
180
+ ...responseFields$,
181
+ callDetail: responseBody,
182
+ });
183
+ return result;
184
+ } else if (this.matchResponse(response, 400, "application/json")) {
185
+ const responseBody = await response.json();
186
+ const result = errors.CreatePhoneCallResponseBody$.inboundSchema.parse({
187
+ ...responseFields$,
188
+ ...responseBody,
189
+ });
190
+ throw result;
191
+ } else if (this.matchResponse(response, 401, "application/json")) {
192
+ const responseBody = await response.json();
193
+ const result =
194
+ errors.CreatePhoneCallResponseResponseBody$.inboundSchema.parse({
195
+ ...responseFields$,
196
+ ...responseBody,
197
+ });
198
+ throw result;
199
+ } else if (this.matchResponse(response, 402, "application/json")) {
200
+ const responseBody = await response.json();
201
+ const result =
202
+ errors.CreatePhoneCallResponse402ResponseBody$.inboundSchema.parse({
203
+ ...responseFields$,
204
+ ...responseBody,
205
+ });
206
+ throw result;
207
+ } else if (this.matchResponse(response, 422, "application/json")) {
208
+ const responseBody = await response.json();
209
+ const result =
210
+ errors.CreatePhoneCallResponse422ResponseBody$.inboundSchema.parse({
211
+ ...responseFields$,
212
+ ...responseBody,
213
+ });
214
+ throw result;
215
+ } else if (this.matchResponse(response, 429, "application/json")) {
216
+ const responseBody = await response.json();
217
+ const result =
218
+ errors.CreatePhoneCallResponse429ResponseBody$.inboundSchema.parse({
219
+ ...responseFields$,
220
+ ...responseBody,
221
+ });
222
+ throw result;
223
+ } else if (this.matchResponse(response, 500, "application/json")) {
224
+ const responseBody = await response.json();
225
+ const result =
226
+ errors.CreatePhoneCallResponse500ResponseBody$.inboundSchema.parse({
227
+ ...responseFields$,
228
+ ...responseBody,
229
+ });
230
+ throw result;
231
+ } else {
232
+ const responseBody = await response.text();
233
+ throw new errors.SDKError(
234
+ "Unexpected API response",
235
+ response,
236
+ responseBody,
237
+ );
219
238
  }
220
-
221
- /**
222
- * Create a new phone number
223
- */
224
- async createPhoneNumber(
225
- input: operations.CreatePhoneNumberRequestBody,
226
- options?: RequestOptions
227
- ): Promise<operations.CreatePhoneNumberResponse> {
228
- const headers$ = new Headers();
229
- headers$.set("user-agent", SDK_METADATA.userAgent);
230
- headers$.set("Content-Type", "application/json");
231
- headers$.set("Accept", "application/json");
232
-
233
- const payload$ = operations.CreatePhoneNumberRequestBody$.outboundSchema.parse(input);
234
- const body$ = enc$.encodeJSON("body", payload$, { explode: true });
235
-
236
- const path$ = this.templateURLComponent("/create-phone-number")();
237
-
238
- let security$;
239
- if (typeof this.options$.apiKey === "function") {
240
- security$ = { apiKey: await this.options$.apiKey() };
241
- } else if (this.options$.apiKey) {
242
- security$ = { apiKey: this.options$.apiKey };
243
- } else {
244
- security$ = {};
245
- }
246
- const securitySettings$ = this.resolveGlobalSecurity(security$);
247
-
248
- const response = await this.fetch$(
249
- {
250
- security: securitySettings$,
251
- method: "post",
252
- path: path$,
253
- headers: headers$,
254
- body: body$,
255
- },
256
- options
257
- );
258
-
259
- const responseFields$ = {
260
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
261
- StatusCode: response.status,
262
- RawResponse: response,
263
- };
264
-
265
- if (this.matchResponse(response, 201, "application/json")) {
266
- const responseBody = await response.json();
267
- const result = operations.CreatePhoneNumberResponse$.inboundSchema.parse({
268
- ...responseFields$,
269
- PhoneNumber: responseBody,
270
- });
271
- return result;
272
- } else if (this.matchResponse(response, 400, "application/json")) {
273
- const responseBody = await response.json();
274
- const result = errors.CreatePhoneNumberResponseBody$.inboundSchema.parse({
275
- ...responseFields$,
276
- ...responseBody,
277
- });
278
- throw result;
279
- } else if (this.matchResponse(response, 401, "application/json")) {
280
- const responseBody = await response.json();
281
- const result = errors.CreatePhoneNumberResponseResponseBody$.inboundSchema.parse({
282
- ...responseFields$,
283
- ...responseBody,
284
- });
285
- throw result;
286
- } else if (this.matchResponse(response, 402, "application/json")) {
287
- const responseBody = await response.json();
288
- const result = errors.CreatePhoneNumberResponse402ResponseBody$.inboundSchema.parse({
289
- ...responseFields$,
290
- ...responseBody,
291
- });
292
- throw result;
293
- } else if (this.matchResponse(response, 422, "application/json")) {
294
- const responseBody = await response.json();
295
- const result = errors.CreatePhoneNumberResponse422ResponseBody$.inboundSchema.parse({
296
- ...responseFields$,
297
- ...responseBody,
298
- });
299
- throw result;
300
- } else if (this.matchResponse(response, 500, "application/json")) {
301
- const responseBody = await response.json();
302
- const result = errors.CreatePhoneNumberResponse500ResponseBody$.inboundSchema.parse({
303
- ...responseFields$,
304
- ...responseBody,
305
- });
306
- throw result;
307
- } else {
308
- const responseBody = await response.text();
309
- throw new errors.SDKError("Unexpected API response", response, responseBody);
310
- }
239
+ }
240
+
241
+ /**
242
+ * Create a new phone number
243
+ */
244
+ async createPhoneNumber(
245
+ input: operations.CreatePhoneNumberRequestBody,
246
+ options?: RequestOptions,
247
+ ): Promise<operations.CreatePhoneNumberResponse> {
248
+ const headers$ = new Headers();
249
+ headers$.set("user-agent", SDK_METADATA.userAgent);
250
+ headers$.set("Content-Type", "application/json");
251
+ headers$.set("Accept", "application/json");
252
+
253
+ const payload$ =
254
+ operations.CreatePhoneNumberRequestBody$.outboundSchema.parse(input);
255
+ const body$ = enc$.encodeJSON("body", payload$, { explode: true });
256
+
257
+ const path$ = this.templateURLComponent("/create-phone-number")();
258
+
259
+ let security$;
260
+ if (typeof this.options$.apiKey === "function") {
261
+ security$ = { apiKey: await this.options$.apiKey() };
262
+ } else if (this.options$.apiKey) {
263
+ security$ = { apiKey: this.options$.apiKey };
264
+ } else {
265
+ security$ = {};
311
266
  }
312
-
313
- /**
314
- * Delete an existing agent
315
- */
316
- async deleteAgent(
317
- agentId: string,
318
- options?: RequestOptions
319
- ): Promise<operations.DeleteAgentResponse> {
320
- const input$: operations.DeleteAgentRequest = {
321
- agentId: agentId,
322
- };
323
- const headers$ = new Headers();
324
- headers$.set("user-agent", SDK_METADATA.userAgent);
325
- headers$.set("Accept", "application/json");
326
-
327
- const payload$ = operations.DeleteAgentRequest$.outboundSchema.parse(input$);
328
- const body$ = null;
329
-
330
- const pathParams$ = {
331
- agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
332
- explode: false,
333
- charEncoding: "percent",
334
- }),
335
- };
336
-
337
- const path$ = this.templateURLComponent("/delete-agent/{agent_id}")(pathParams$);
338
-
339
- let security$;
340
- if (typeof this.options$.apiKey === "function") {
341
- security$ = { apiKey: await this.options$.apiKey() };
342
- } else if (this.options$.apiKey) {
343
- security$ = { apiKey: this.options$.apiKey };
344
- } else {
345
- security$ = {};
346
- }
347
- const securitySettings$ = this.resolveGlobalSecurity(security$);
348
-
349
- const response = await this.fetch$(
350
- {
351
- security: securitySettings$,
352
- method: "delete",
353
- path: path$,
354
- headers: headers$,
355
- body: body$,
356
- },
357
- options
358
- );
359
-
360
- const responseFields$ = {
361
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
362
- StatusCode: response.status,
363
- RawResponse: response,
364
- };
365
-
366
- if (this.matchStatusCode(response, 204)) {
367
- // fallthrough
368
- } else if (this.matchResponse(response, 400, "application/json")) {
369
- const responseBody = await response.json();
370
- const result = errors.DeleteAgentResponseBody$.inboundSchema.parse({
371
- ...responseFields$,
372
- ...responseBody,
373
- });
374
- throw result;
375
- } else if (this.matchResponse(response, 401, "application/json")) {
376
- const responseBody = await response.json();
377
- const result = errors.DeleteAgentResponseResponseBody$.inboundSchema.parse({
378
- ...responseFields$,
379
- ...responseBody,
380
- });
381
- throw result;
382
- } else if (this.matchResponse(response, 422, "application/json")) {
383
- const responseBody = await response.json();
384
- const result = errors.DeleteAgentResponse422ResponseBody$.inboundSchema.parse({
385
- ...responseFields$,
386
- ...responseBody,
387
- });
388
- throw result;
389
- } else if (this.matchResponse(response, 500, "application/json")) {
390
- const responseBody = await response.json();
391
- const result = errors.DeleteAgentResponse500ResponseBody$.inboundSchema.parse({
392
- ...responseFields$,
393
- ...responseBody,
394
- });
395
- throw result;
396
- } else {
397
- const responseBody = await response.text();
398
- throw new errors.SDKError("Unexpected API response", response, responseBody);
399
- }
400
-
401
- return operations.DeleteAgentResponse$.inboundSchema.parse(responseFields$);
267
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
268
+
269
+ const response = await this.fetch$(
270
+ {
271
+ security: securitySettings$,
272
+ method: "post",
273
+ path: path$,
274
+ headers: headers$,
275
+ body: body$,
276
+ },
277
+ options,
278
+ );
279
+
280
+ const responseFields$ = {
281
+ ContentType:
282
+ response.headers.get("content-type") ?? "application/octet-stream",
283
+ StatusCode: response.status,
284
+ RawResponse: response,
285
+ };
286
+
287
+ if (this.matchResponse(response, 201, "application/json")) {
288
+ const responseBody = await response.json();
289
+ const result = operations.CreatePhoneNumberResponse$.inboundSchema.parse({
290
+ ...responseFields$,
291
+ PhoneNumber: responseBody,
292
+ });
293
+ return result;
294
+ } else if (this.matchResponse(response, 400, "application/json")) {
295
+ const responseBody = await response.json();
296
+ const result = errors.CreatePhoneNumberResponseBody$.inboundSchema.parse({
297
+ ...responseFields$,
298
+ ...responseBody,
299
+ });
300
+ throw result;
301
+ } else if (this.matchResponse(response, 401, "application/json")) {
302
+ const responseBody = await response.json();
303
+ const result =
304
+ errors.CreatePhoneNumberResponseResponseBody$.inboundSchema.parse({
305
+ ...responseFields$,
306
+ ...responseBody,
307
+ });
308
+ throw result;
309
+ } else if (this.matchResponse(response, 402, "application/json")) {
310
+ const responseBody = await response.json();
311
+ const result =
312
+ errors.CreatePhoneNumberResponse402ResponseBody$.inboundSchema.parse({
313
+ ...responseFields$,
314
+ ...responseBody,
315
+ });
316
+ throw result;
317
+ } else if (this.matchResponse(response, 422, "application/json")) {
318
+ const responseBody = await response.json();
319
+ const result =
320
+ errors.CreatePhoneNumberResponse422ResponseBody$.inboundSchema.parse({
321
+ ...responseFields$,
322
+ ...responseBody,
323
+ });
324
+ throw result;
325
+ } else if (this.matchResponse(response, 500, "application/json")) {
326
+ const responseBody = await response.json();
327
+ const result =
328
+ errors.CreatePhoneNumberResponse500ResponseBody$.inboundSchema.parse({
329
+ ...responseFields$,
330
+ ...responseBody,
331
+ });
332
+ throw result;
333
+ } else {
334
+ const responseBody = await response.text();
335
+ throw new errors.SDKError(
336
+ "Unexpected API response",
337
+ response,
338
+ responseBody,
339
+ );
402
340
  }
403
-
404
- /**
405
- * Delete a specific phone number
406
- */
407
- async deletePhoneNumber(
408
- phoneNumber: string,
409
- options?: RequestOptions
410
- ): Promise<operations.DeletePhoneNumberResponse> {
411
- const input$: operations.DeletePhoneNumberRequest = {
412
- phoneNumber: phoneNumber,
413
- };
414
- const headers$ = new Headers();
415
- headers$.set("user-agent", SDK_METADATA.userAgent);
416
- headers$.set("Accept", "application/json");
417
-
418
- const payload$ = operations.DeletePhoneNumberRequest$.outboundSchema.parse(input$);
419
- const body$ = null;
420
-
421
- const pathParams$ = {
422
- phone_number: enc$.encodeSimple("phone_number", payload$.phone_number, {
423
- explode: false,
424
- charEncoding: "percent",
425
- }),
426
- };
427
-
428
- const path$ = this.templateURLComponent("/delete-phone-number/{phone_number}")(pathParams$);
429
-
430
- let security$;
431
- if (typeof this.options$.apiKey === "function") {
432
- security$ = { apiKey: await this.options$.apiKey() };
433
- } else if (this.options$.apiKey) {
434
- security$ = { apiKey: this.options$.apiKey };
435
- } else {
436
- security$ = {};
437
- }
438
- const securitySettings$ = this.resolveGlobalSecurity(security$);
439
-
440
- const response = await this.fetch$(
441
- {
442
- security: securitySettings$,
443
- method: "delete",
444
- path: path$,
445
- headers: headers$,
446
- body: body$,
447
- },
448
- options
449
- );
450
-
451
- const responseFields$ = {
452
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
453
- StatusCode: response.status,
454
- RawResponse: response,
455
- };
456
-
457
- if (this.matchStatusCode(response, 204)) {
458
- // fallthrough
459
- } else if (this.matchResponse(response, 400, "application/json")) {
460
- const responseBody = await response.json();
461
- const result = errors.DeletePhoneNumberResponseBody$.inboundSchema.parse({
462
- ...responseFields$,
463
- ...responseBody,
464
- });
465
- throw result;
466
- } else if (this.matchResponse(response, 401, "application/json")) {
467
- const responseBody = await response.json();
468
- const result = errors.DeletePhoneNumberResponseResponseBody$.inboundSchema.parse({
469
- ...responseFields$,
470
- ...responseBody,
471
- });
472
- throw result;
473
- } else if (this.matchResponse(response, 422, "application/json")) {
474
- const responseBody = await response.json();
475
- const result = errors.DeletePhoneNumberResponse422ResponseBody$.inboundSchema.parse({
476
- ...responseFields$,
477
- ...responseBody,
478
- });
479
- throw result;
480
- } else if (this.matchResponse(response, 500, "application/json")) {
481
- const responseBody = await response.json();
482
- const result = errors.DeletePhoneNumberResponse500ResponseBody$.inboundSchema.parse({
483
- ...responseFields$,
484
- ...responseBody,
485
- });
486
- throw result;
487
- } else {
488
- const responseBody = await response.text();
489
- throw new errors.SDKError("Unexpected API response", response, responseBody);
490
- }
491
-
492
- return operations.DeletePhoneNumberResponse$.inboundSchema.parse(responseFields$);
341
+ }
342
+
343
+ /**
344
+ * Delete an existing agent
345
+ */
346
+ async deleteAgent(
347
+ agentId: string,
348
+ options?: RequestOptions,
349
+ ): Promise<operations.DeleteAgentResponse> {
350
+ const input$: operations.DeleteAgentRequest = {
351
+ agentId: agentId,
352
+ };
353
+ const headers$ = new Headers();
354
+ headers$.set("user-agent", SDK_METADATA.userAgent);
355
+ headers$.set("Accept", "application/json");
356
+
357
+ const payload$ =
358
+ operations.DeleteAgentRequest$.outboundSchema.parse(input$);
359
+ const body$ = null;
360
+
361
+ const pathParams$ = {
362
+ agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
363
+ explode: false,
364
+ charEncoding: "percent",
365
+ }),
366
+ };
367
+
368
+ const path$ = this.templateURLComponent("/delete-agent/{agent_id}")(
369
+ pathParams$,
370
+ );
371
+
372
+ let security$;
373
+ if (typeof this.options$.apiKey === "function") {
374
+ security$ = { apiKey: await this.options$.apiKey() };
375
+ } else if (this.options$.apiKey) {
376
+ security$ = { apiKey: this.options$.apiKey };
377
+ } else {
378
+ security$ = {};
493
379
  }
494
-
495
- /**
496
- * Retrieve details of a specific agent
497
- */
498
- async getAgent(
499
- agentId: string,
500
- options?: RequestOptions
501
- ): Promise<operations.GetAgentResponse> {
502
- const input$: operations.GetAgentRequest = {
503
- agentId: agentId,
504
- };
505
- const headers$ = new Headers();
506
- headers$.set("user-agent", SDK_METADATA.userAgent);
507
- headers$.set("Accept", "application/json");
508
-
509
- const payload$ = operations.GetAgentRequest$.outboundSchema.parse(input$);
510
- const body$ = null;
511
-
512
- const pathParams$ = {
513
- agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
514
- explode: false,
515
- charEncoding: "percent",
516
- }),
517
- };
518
-
519
- const path$ = this.templateURLComponent("/get-agent/{agent_id}")(pathParams$);
520
-
521
- let security$;
522
- if (typeof this.options$.apiKey === "function") {
523
- security$ = { apiKey: await this.options$.apiKey() };
524
- } else if (this.options$.apiKey) {
525
- security$ = { apiKey: this.options$.apiKey };
526
- } else {
527
- security$ = {};
528
- }
529
- const securitySettings$ = this.resolveGlobalSecurity(security$);
530
-
531
- const response = await this.fetch$(
532
- {
533
- security: securitySettings$,
534
- method: "get",
535
- path: path$,
536
- headers: headers$,
537
- body: body$,
538
- },
539
- options
540
- );
541
-
542
- const responseFields$ = {
543
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
544
- StatusCode: response.status,
545
- RawResponse: response,
546
- };
547
-
548
- if (this.matchResponse(response, 200, "application/json")) {
549
- const responseBody = await response.json();
550
- const result = operations.GetAgentResponse$.inboundSchema.parse({
551
- ...responseFields$,
552
- Agent: responseBody,
553
- });
554
- return result;
555
- } else if (this.matchResponse(response, 400, "application/json")) {
556
- const responseBody = await response.json();
557
- const result = errors.GetAgentResponseBody$.inboundSchema.parse({
558
- ...responseFields$,
559
- ...responseBody,
560
- });
561
- throw result;
562
- } else if (this.matchResponse(response, 401, "application/json")) {
563
- const responseBody = await response.json();
564
- const result = errors.GetAgentResponseResponseBody$.inboundSchema.parse({
565
- ...responseFields$,
566
- ...responseBody,
567
- });
568
- throw result;
569
- } else if (this.matchResponse(response, 422, "application/json")) {
570
- const responseBody = await response.json();
571
- const result = errors.GetAgentResponse422ResponseBody$.inboundSchema.parse({
572
- ...responseFields$,
573
- ...responseBody,
574
- });
575
- throw result;
576
- } else if (this.matchResponse(response, 500, "application/json")) {
577
- const responseBody = await response.json();
578
- const result = errors.GetAgentResponse500ResponseBody$.inboundSchema.parse({
579
- ...responseFields$,
580
- ...responseBody,
581
- });
582
- throw result;
583
- } else {
584
- const responseBody = await response.text();
585
- throw new errors.SDKError("Unexpected API response", response, responseBody);
586
- }
380
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
381
+
382
+ const response = await this.fetch$(
383
+ {
384
+ security: securitySettings$,
385
+ method: "delete",
386
+ path: path$,
387
+ headers: headers$,
388
+ body: body$,
389
+ },
390
+ options,
391
+ );
392
+
393
+ const responseFields$ = {
394
+ ContentType:
395
+ response.headers.get("content-type") ?? "application/octet-stream",
396
+ StatusCode: response.status,
397
+ RawResponse: response,
398
+ };
399
+
400
+ if (this.matchStatusCode(response, 204)) {
401
+ // fallthrough
402
+ } else if (this.matchResponse(response, 400, "application/json")) {
403
+ const responseBody = await response.json();
404
+ const result = errors.DeleteAgentResponseBody$.inboundSchema.parse({
405
+ ...responseFields$,
406
+ ...responseBody,
407
+ });
408
+ throw result;
409
+ } else if (this.matchResponse(response, 401, "application/json")) {
410
+ const responseBody = await response.json();
411
+ const result =
412
+ errors.DeleteAgentResponseResponseBody$.inboundSchema.parse({
413
+ ...responseFields$,
414
+ ...responseBody,
415
+ });
416
+ throw result;
417
+ } else if (this.matchResponse(response, 422, "application/json")) {
418
+ const responseBody = await response.json();
419
+ const result =
420
+ errors.DeleteAgentResponse422ResponseBody$.inboundSchema.parse({
421
+ ...responseFields$,
422
+ ...responseBody,
423
+ });
424
+ throw result;
425
+ } else if (this.matchResponse(response, 500, "application/json")) {
426
+ const responseBody = await response.json();
427
+ const result =
428
+ errors.DeleteAgentResponse500ResponseBody$.inboundSchema.parse({
429
+ ...responseFields$,
430
+ ...responseBody,
431
+ });
432
+ throw result;
433
+ } else {
434
+ const responseBody = await response.text();
435
+ throw new errors.SDKError(
436
+ "Unexpected API response",
437
+ response,
438
+ responseBody,
439
+ );
587
440
  }
588
441
 
589
- /**
590
- * Retrieve details of a specific call
591
- */
592
- async getCall(callId: string, options?: RequestOptions): Promise<operations.GetCallResponse> {
593
- const input$: operations.GetCallRequest = {
594
- callId: callId,
595
- };
596
- const headers$ = new Headers();
597
- headers$.set("user-agent", SDK_METADATA.userAgent);
598
- headers$.set("Accept", "application/json");
599
-
600
- const payload$ = operations.GetCallRequest$.outboundSchema.parse(input$);
601
- const body$ = null;
602
-
603
- const pathParams$ = {
604
- call_id: enc$.encodeSimple("call_id", payload$.call_id, {
605
- explode: false,
606
- charEncoding: "percent",
607
- }),
608
- };
609
-
610
- const path$ = this.templateURLComponent("/get-call/{call_id}")(pathParams$);
611
-
612
- let security$;
613
- if (typeof this.options$.apiKey === "function") {
614
- security$ = { apiKey: await this.options$.apiKey() };
615
- } else if (this.options$.apiKey) {
616
- security$ = { apiKey: this.options$.apiKey };
617
- } else {
618
- security$ = {};
619
- }
620
- const securitySettings$ = this.resolveGlobalSecurity(security$);
621
-
622
- const response = await this.fetch$(
623
- {
624
- security: securitySettings$,
625
- method: "get",
626
- path: path$,
627
- headers: headers$,
628
- body: body$,
629
- },
630
- options
631
- );
632
-
633
- const responseFields$ = {
634
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
635
- StatusCode: response.status,
636
- RawResponse: response,
637
- };
638
-
639
- if (this.matchResponse(response, 200, "application/json")) {
640
- const responseBody = await response.json();
641
- const result = operations.GetCallResponse$.inboundSchema.parse({
642
- ...responseFields$,
643
- CallDetail: responseBody,
644
- });
645
- return result;
646
- } else if (this.matchResponse(response, 400, "application/json")) {
647
- const responseBody = await response.json();
648
- const result = errors.GetCallResponseBody$.inboundSchema.parse({
649
- ...responseFields$,
650
- ...responseBody,
651
- });
652
- throw result;
653
- } else if (this.matchResponse(response, 401, "application/json")) {
654
- const responseBody = await response.json();
655
- const result = errors.GetCallResponseResponseBody$.inboundSchema.parse({
656
- ...responseFields$,
657
- ...responseBody,
658
- });
659
- throw result;
660
- } else if (this.matchResponse(response, 422, "application/json")) {
661
- const responseBody = await response.json();
662
- const result = errors.GetCallResponse422ResponseBody$.inboundSchema.parse({
663
- ...responseFields$,
664
- ...responseBody,
665
- });
666
- throw result;
667
- } else if (this.matchResponse(response, 500, "application/json")) {
668
- const responseBody = await response.json();
669
- const result = errors.GetCallResponse500ResponseBody$.inboundSchema.parse({
670
- ...responseFields$,
671
- ...responseBody,
672
- });
673
- throw result;
674
- } else {
675
- const responseBody = await response.text();
676
- throw new errors.SDKError("Unexpected API response", response, responseBody);
677
- }
442
+ return operations.DeleteAgentResponse$.inboundSchema.parse(responseFields$);
443
+ }
444
+
445
+ /**
446
+ * Delete a specific phone number
447
+ */
448
+ async deletePhoneNumber(
449
+ phoneNumber: string,
450
+ options?: RequestOptions,
451
+ ): Promise<operations.DeletePhoneNumberResponse> {
452
+ const input$: operations.DeletePhoneNumberRequest = {
453
+ phoneNumber: phoneNumber,
454
+ };
455
+ const headers$ = new Headers();
456
+ headers$.set("user-agent", SDK_METADATA.userAgent);
457
+ headers$.set("Accept", "application/json");
458
+
459
+ const payload$ =
460
+ operations.DeletePhoneNumberRequest$.outboundSchema.parse(input$);
461
+ const body$ = null;
462
+
463
+ const pathParams$ = {
464
+ phone_number: enc$.encodeSimple("phone_number", payload$.phone_number, {
465
+ explode: false,
466
+ charEncoding: "percent",
467
+ }),
468
+ };
469
+
470
+ const path$ = this.templateURLComponent(
471
+ "/delete-phone-number/{phone_number}",
472
+ )(pathParams$);
473
+
474
+ let security$;
475
+ if (typeof this.options$.apiKey === "function") {
476
+ security$ = { apiKey: await this.options$.apiKey() };
477
+ } else if (this.options$.apiKey) {
478
+ security$ = { apiKey: this.options$.apiKey };
479
+ } else {
480
+ security$ = {};
678
481
  }
679
-
680
- /**
681
- * Retrieve info about a specific number
682
- */
683
- async getPhoneNumber(
684
- phoneNumber: string,
685
- options?: RequestOptions
686
- ): Promise<operations.GetPhoneNumberResponse> {
687
- const input$: operations.GetPhoneNumberRequest = {
688
- phoneNumber: phoneNumber,
689
- };
690
- const headers$ = new Headers();
691
- headers$.set("user-agent", SDK_METADATA.userAgent);
692
- headers$.set("Accept", "application/json");
693
-
694
- const payload$ = operations.GetPhoneNumberRequest$.outboundSchema.parse(input$);
695
- const body$ = null;
696
-
697
- const pathParams$ = {
698
- phone_number: enc$.encodeSimple("phone_number", payload$.phone_number, {
699
- explode: false,
700
- charEncoding: "percent",
701
- }),
702
- };
703
-
704
- const path$ = this.templateURLComponent("/get-phone-number/{phone_number}")(pathParams$);
705
-
706
- let security$;
707
- if (typeof this.options$.apiKey === "function") {
708
- security$ = { apiKey: await this.options$.apiKey() };
709
- } else if (this.options$.apiKey) {
710
- security$ = { apiKey: this.options$.apiKey };
711
- } else {
712
- security$ = {};
713
- }
714
- const securitySettings$ = this.resolveGlobalSecurity(security$);
715
-
716
- const response = await this.fetch$(
717
- {
718
- security: securitySettings$,
719
- method: "get",
720
- path: path$,
721
- headers: headers$,
722
- body: body$,
723
- },
724
- options
725
- );
726
-
727
- const responseFields$ = {
728
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
729
- StatusCode: response.status,
730
- RawResponse: response,
731
- };
732
-
733
- if (this.matchResponse(response, 200, "application/json")) {
734
- const responseBody = await response.json();
735
- const result = operations.GetPhoneNumberResponse$.inboundSchema.parse({
736
- ...responseFields$,
737
- PhoneNumber: responseBody,
738
- });
739
- return result;
740
- } else if (this.matchResponse(response, 400, "application/json")) {
741
- const responseBody = await response.json();
742
- const result = errors.GetPhoneNumberResponseBody$.inboundSchema.parse({
743
- ...responseFields$,
744
- ...responseBody,
745
- });
746
- throw result;
747
- } else if (this.matchResponse(response, 401, "application/json")) {
748
- const responseBody = await response.json();
749
- const result = errors.GetPhoneNumberResponseResponseBody$.inboundSchema.parse({
750
- ...responseFields$,
751
- ...responseBody,
752
- });
753
- throw result;
754
- } else if (this.matchResponse(response, 422, "application/json")) {
755
- const responseBody = await response.json();
756
- const result = errors.GetPhoneNumberResponse422ResponseBody$.inboundSchema.parse({
757
- ...responseFields$,
758
- ...responseBody,
759
- });
760
- throw result;
761
- } else if (this.matchResponse(response, 500, "application/json")) {
762
- const responseBody = await response.json();
763
- const result = errors.GetPhoneNumberResponse500ResponseBody$.inboundSchema.parse({
764
- ...responseFields$,
765
- ...responseBody,
766
- });
767
- throw result;
768
- } else {
769
- const responseBody = await response.text();
770
- throw new errors.SDKError("Unexpected API response", response, responseBody);
771
- }
482
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
483
+
484
+ const response = await this.fetch$(
485
+ {
486
+ security: securitySettings$,
487
+ method: "delete",
488
+ path: path$,
489
+ headers: headers$,
490
+ body: body$,
491
+ },
492
+ options,
493
+ );
494
+
495
+ const responseFields$ = {
496
+ ContentType:
497
+ response.headers.get("content-type") ?? "application/octet-stream",
498
+ StatusCode: response.status,
499
+ RawResponse: response,
500
+ };
501
+
502
+ if (this.matchStatusCode(response, 204)) {
503
+ // fallthrough
504
+ } else if (this.matchResponse(response, 400, "application/json")) {
505
+ const responseBody = await response.json();
506
+ const result = errors.DeletePhoneNumberResponseBody$.inboundSchema.parse({
507
+ ...responseFields$,
508
+ ...responseBody,
509
+ });
510
+ throw result;
511
+ } else if (this.matchResponse(response, 401, "application/json")) {
512
+ const responseBody = await response.json();
513
+ const result =
514
+ errors.DeletePhoneNumberResponseResponseBody$.inboundSchema.parse({
515
+ ...responseFields$,
516
+ ...responseBody,
517
+ });
518
+ throw result;
519
+ } else if (this.matchResponse(response, 422, "application/json")) {
520
+ const responseBody = await response.json();
521
+ const result =
522
+ errors.DeletePhoneNumberResponse422ResponseBody$.inboundSchema.parse({
523
+ ...responseFields$,
524
+ ...responseBody,
525
+ });
526
+ throw result;
527
+ } else if (this.matchResponse(response, 500, "application/json")) {
528
+ const responseBody = await response.json();
529
+ const result =
530
+ errors.DeletePhoneNumberResponse500ResponseBody$.inboundSchema.parse({
531
+ ...responseFields$,
532
+ ...responseBody,
533
+ });
534
+ throw result;
535
+ } else {
536
+ const responseBody = await response.text();
537
+ throw new errors.SDKError(
538
+ "Unexpected API response",
539
+ response,
540
+ responseBody,
541
+ );
772
542
  }
773
543
 
774
- /**
775
- * List all agents
776
- */
777
- async listAgents(options?: RequestOptions): Promise<operations.ListAgentsResponse> {
778
- const headers$ = new Headers();
779
- headers$.set("user-agent", SDK_METADATA.userAgent);
780
- headers$.set("Accept", "application/json");
781
-
782
- const path$ = this.templateURLComponent("/list-agents")();
783
-
784
- let security$;
785
- if (typeof this.options$.apiKey === "function") {
786
- security$ = { apiKey: await this.options$.apiKey() };
787
- } else if (this.options$.apiKey) {
788
- security$ = { apiKey: this.options$.apiKey };
789
- } else {
790
- security$ = {};
791
- }
792
- const securitySettings$ = this.resolveGlobalSecurity(security$);
793
-
794
- const response = await this.fetch$(
795
- { security: securitySettings$, method: "get", path: path$, headers: headers$ },
796
- options
797
- );
798
-
799
- const responseFields$ = {
800
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
801
- StatusCode: response.status,
802
- RawResponse: response,
803
- };
804
-
805
- if (this.matchResponse(response, 200, "application/json")) {
806
- const responseBody = await response.json();
807
- const result = operations.ListAgentsResponse$.inboundSchema.parse({
808
- ...responseFields$,
809
- agents: responseBody,
810
- });
811
- return result;
812
- } else if (this.matchResponse(response, 401, "application/json")) {
813
- const responseBody = await response.json();
814
- const result = errors.ListAgentsResponseBody$.inboundSchema.parse({
815
- ...responseFields$,
816
- ...responseBody,
817
- });
818
- throw result;
819
- } else if (this.matchResponse(response, 500, "application/json")) {
820
- const responseBody = await response.json();
821
- const result = errors.ListAgentsResponseResponseBody$.inboundSchema.parse({
822
- ...responseFields$,
823
- ...responseBody,
824
- });
825
- throw result;
826
- } else {
827
- const responseBody = await response.text();
828
- throw new errors.SDKError("Unexpected API response", response, responseBody);
829
- }
544
+ return operations.DeletePhoneNumberResponse$.inboundSchema.parse(
545
+ responseFields$,
546
+ );
547
+ }
548
+
549
+ /**
550
+ * Retrieve details of a specific agent
551
+ */
552
+ async getAgent(
553
+ agentId: string,
554
+ options?: RequestOptions,
555
+ ): Promise<operations.GetAgentResponse> {
556
+ const input$: operations.GetAgentRequest = {
557
+ agentId: agentId,
558
+ };
559
+ const headers$ = new Headers();
560
+ headers$.set("user-agent", SDK_METADATA.userAgent);
561
+ headers$.set("Accept", "application/json");
562
+
563
+ const payload$ = operations.GetAgentRequest$.outboundSchema.parse(input$);
564
+ const body$ = null;
565
+
566
+ const pathParams$ = {
567
+ agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
568
+ explode: false,
569
+ charEncoding: "percent",
570
+ }),
571
+ };
572
+
573
+ const path$ = this.templateURLComponent("/get-agent/{agent_id}")(
574
+ pathParams$,
575
+ );
576
+
577
+ let security$;
578
+ if (typeof this.options$.apiKey === "function") {
579
+ security$ = { apiKey: await this.options$.apiKey() };
580
+ } else if (this.options$.apiKey) {
581
+ security$ = { apiKey: this.options$.apiKey };
582
+ } else {
583
+ security$ = {};
830
584
  }
831
-
832
- /**
833
- * Retrieve call details
834
- */
835
- async listCalls(
836
- filterCriteria?: operations.FilterCriteria | undefined,
837
- limit?: number | undefined,
838
- sortOrder?: operations.SortOrder | undefined,
839
- options?: RequestOptions
840
- ): Promise<operations.ListCallsResponse> {
841
- const input$: operations.ListCallsRequest = {
842
- filterCriteria: filterCriteria,
843
- limit: limit,
844
- sortOrder: sortOrder,
845
- };
846
- const headers$ = new Headers();
847
- headers$.set("user-agent", SDK_METADATA.userAgent);
848
- headers$.set("Accept", "application/json");
849
-
850
- const payload$ = operations.ListCallsRequest$.outboundSchema.parse(input$);
851
- const body$ = null;
852
-
853
- const path$ = this.templateURLComponent("/list-calls")();
854
-
855
- const query$ = [
856
- enc$.encodeForm("filter_criteria", JSON.stringify(payload$.filter_criteria), {
857
- explode: true,
858
- charEncoding: "percent",
859
- }),
860
- enc$.encodeForm("limit", payload$.limit, { explode: true, charEncoding: "percent" }),
861
- enc$.encodeForm("sort_order", payload$.sort_order, {
862
- explode: true,
863
- charEncoding: "percent",
864
- }),
865
- ]
866
- .filter(Boolean)
867
- .join("&");
868
-
869
- let security$;
870
- if (typeof this.options$.apiKey === "function") {
871
- security$ = { apiKey: await this.options$.apiKey() };
872
- } else if (this.options$.apiKey) {
873
- security$ = { apiKey: this.options$.apiKey };
874
- } else {
875
- security$ = {};
876
- }
877
- const securitySettings$ = this.resolveGlobalSecurity(security$);
878
-
879
- const response = await this.fetch$(
880
- {
881
- security: securitySettings$,
882
- method: "get",
883
- path: path$,
884
- headers: headers$,
885
- query: query$,
886
- body: body$,
887
- },
888
- options
889
- );
890
-
891
- const responseFields$ = {
892
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
893
- StatusCode: response.status,
894
- RawResponse: response,
895
- };
896
-
897
- if (this.matchResponse(response, 200, "application/json")) {
898
- const responseBody = await response.json();
899
- const result = operations.ListCallsResponse$.inboundSchema.parse({
900
- ...responseFields$,
901
- calls: responseBody,
902
- });
903
- return result;
904
- } else if (this.matchResponse(response, 400, "application/json")) {
905
- const responseBody = await response.json();
906
- const result = errors.ListCallsResponseBody$.inboundSchema.parse({
907
- ...responseFields$,
908
- ...responseBody,
909
- });
910
- throw result;
911
- } else if (this.matchResponse(response, 401, "application/json")) {
912
- const responseBody = await response.json();
913
- const result = errors.ListCallsResponseResponseBody$.inboundSchema.parse({
914
- ...responseFields$,
915
- ...responseBody,
916
- });
917
- throw result;
918
- } else if (this.matchResponse(response, 500, "application/json")) {
919
- const responseBody = await response.json();
920
- const result = errors.ListCallsResponse500ResponseBody$.inboundSchema.parse({
921
- ...responseFields$,
922
- ...responseBody,
923
- });
924
- throw result;
925
- } else {
926
- const responseBody = await response.text();
927
- throw new errors.SDKError("Unexpected API response", response, responseBody);
928
- }
585
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
586
+
587
+ const response = await this.fetch$(
588
+ {
589
+ security: securitySettings$,
590
+ method: "get",
591
+ path: path$,
592
+ headers: headers$,
593
+ body: body$,
594
+ },
595
+ options,
596
+ );
597
+
598
+ const responseFields$ = {
599
+ ContentType:
600
+ response.headers.get("content-type") ?? "application/octet-stream",
601
+ StatusCode: response.status,
602
+ RawResponse: response,
603
+ };
604
+
605
+ if (this.matchResponse(response, 200, "application/json")) {
606
+ const responseBody = await response.json();
607
+ const result = operations.GetAgentResponse$.inboundSchema.parse({
608
+ ...responseFields$,
609
+ Agent: responseBody,
610
+ });
611
+ return result;
612
+ } else if (this.matchResponse(response, 400, "application/json")) {
613
+ const responseBody = await response.json();
614
+ const result = errors.GetAgentResponseBody$.inboundSchema.parse({
615
+ ...responseFields$,
616
+ ...responseBody,
617
+ });
618
+ throw result;
619
+ } else if (this.matchResponse(response, 401, "application/json")) {
620
+ const responseBody = await response.json();
621
+ const result = errors.GetAgentResponseResponseBody$.inboundSchema.parse({
622
+ ...responseFields$,
623
+ ...responseBody,
624
+ });
625
+ throw result;
626
+ } else if (this.matchResponse(response, 422, "application/json")) {
627
+ const responseBody = await response.json();
628
+ const result =
629
+ errors.GetAgentResponse422ResponseBody$.inboundSchema.parse({
630
+ ...responseFields$,
631
+ ...responseBody,
632
+ });
633
+ throw result;
634
+ } else if (this.matchResponse(response, 500, "application/json")) {
635
+ const responseBody = await response.json();
636
+ const result =
637
+ errors.GetAgentResponse500ResponseBody$.inboundSchema.parse({
638
+ ...responseFields$,
639
+ ...responseBody,
640
+ });
641
+ throw result;
642
+ } else {
643
+ const responseBody = await response.text();
644
+ throw new errors.SDKError(
645
+ "Unexpected API response",
646
+ response,
647
+ responseBody,
648
+ );
929
649
  }
930
-
931
- /**
932
- * List all purchased and active phone numbers
933
- */
934
- async listPhoneNumbers(options?: RequestOptions): Promise<operations.ListPhoneNumbersResponse> {
935
- const headers$ = new Headers();
936
- headers$.set("user-agent", SDK_METADATA.userAgent);
937
- headers$.set("Accept", "application/json");
938
-
939
- const path$ = this.templateURLComponent("/list-phone-numbers")();
940
-
941
- let security$;
942
- if (typeof this.options$.apiKey === "function") {
943
- security$ = { apiKey: await this.options$.apiKey() };
944
- } else if (this.options$.apiKey) {
945
- security$ = { apiKey: this.options$.apiKey };
946
- } else {
947
- security$ = {};
948
- }
949
- const securitySettings$ = this.resolveGlobalSecurity(security$);
950
-
951
- const response = await this.fetch$(
952
- { security: securitySettings$, method: "get", path: path$, headers: headers$ },
953
- options
954
- );
955
-
956
- const responseFields$ = {
957
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
958
- StatusCode: response.status,
959
- RawResponse: response,
960
- };
961
-
962
- if (this.matchResponse(response, 200, "application/json")) {
963
- const responseBody = await response.json();
964
- const result = operations.ListPhoneNumbersResponse$.inboundSchema.parse({
965
- ...responseFields$,
966
- phoneNumbers: responseBody,
967
- });
968
- return result;
969
- } else if (this.matchResponse(response, 400, "application/json")) {
970
- const responseBody = await response.json();
971
- const result = errors.ListPhoneNumbersResponseBody$.inboundSchema.parse({
972
- ...responseFields$,
973
- ...responseBody,
974
- });
975
- throw result;
976
- } else if (this.matchResponse(response, 401, "application/json")) {
977
- const responseBody = await response.json();
978
- const result = errors.ListPhoneNumbersResponseResponseBody$.inboundSchema.parse({
979
- ...responseFields$,
980
- ...responseBody,
981
- });
982
- throw result;
983
- } else if (this.matchResponse(response, 500, "application/json")) {
984
- const responseBody = await response.json();
985
- const result = errors.ListPhoneNumbersResponse500ResponseBody$.inboundSchema.parse({
986
- ...responseFields$,
987
- ...responseBody,
988
- });
989
- throw result;
990
- } else {
991
- const responseBody = await response.text();
992
- throw new errors.SDKError("Unexpected API response", response, responseBody);
993
- }
650
+ }
651
+
652
+ /**
653
+ * Retrieve details of a specific call
654
+ */
655
+ async getCall(
656
+ callId: string,
657
+ options?: RequestOptions,
658
+ ): Promise<operations.GetCallResponse> {
659
+ const input$: operations.GetCallRequest = {
660
+ callId: callId,
661
+ };
662
+ const headers$ = new Headers();
663
+ headers$.set("user-agent", SDK_METADATA.userAgent);
664
+ headers$.set("Accept", "application/json");
665
+
666
+ const payload$ = operations.GetCallRequest$.outboundSchema.parse(input$);
667
+ const body$ = null;
668
+
669
+ const pathParams$ = {
670
+ call_id: enc$.encodeSimple("call_id", payload$.call_id, {
671
+ explode: false,
672
+ charEncoding: "percent",
673
+ }),
674
+ };
675
+
676
+ const path$ = this.templateURLComponent("/get-call/{call_id}")(pathParams$);
677
+
678
+ let security$;
679
+ if (typeof this.options$.apiKey === "function") {
680
+ security$ = { apiKey: await this.options$.apiKey() };
681
+ } else if (this.options$.apiKey) {
682
+ security$ = { apiKey: this.options$.apiKey };
683
+ } else {
684
+ security$ = {};
994
685
  }
995
-
996
- /**
997
- * Update an existing agent
998
- */
999
- async updateAgent(
1000
- requestBody: operations.UpdateAgentRequestBody,
1001
- agentId: string,
1002
- options?: RequestOptions
1003
- ): Promise<operations.UpdateAgentResponse> {
1004
- const input$: operations.UpdateAgentRequest = {
1005
- requestBody: requestBody,
1006
- agentId: agentId,
1007
- };
1008
- const headers$ = new Headers();
1009
- headers$.set("user-agent", SDK_METADATA.userAgent);
1010
- headers$.set("Content-Type", "application/json");
1011
- headers$.set("Accept", "application/json");
1012
-
1013
- const payload$ = operations.UpdateAgentRequest$.outboundSchema.parse(input$);
1014
-
1015
- const body$ = enc$.encodeJSON("body", payload$.RequestBody, { explode: true });
1016
-
1017
- const pathParams$ = {
1018
- agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
1019
- explode: false,
1020
- charEncoding: "percent",
1021
- }),
1022
- };
1023
-
1024
- const path$ = this.templateURLComponent("/update-agent/{agent_id}")(pathParams$);
1025
-
1026
- let security$;
1027
- if (typeof this.options$.apiKey === "function") {
1028
- security$ = { apiKey: await this.options$.apiKey() };
1029
- } else if (this.options$.apiKey) {
1030
- security$ = { apiKey: this.options$.apiKey };
1031
- } else {
1032
- security$ = {};
1033
- }
1034
- const securitySettings$ = this.resolveGlobalSecurity(security$);
1035
-
1036
- const response = await this.fetch$(
1037
- {
1038
- security: securitySettings$,
1039
- method: "PATCH",
1040
- path: path$,
1041
- headers: headers$,
1042
- body: body$,
1043
- },
1044
- options
1045
- );
1046
-
1047
- const responseFields$ = {
1048
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
1049
- StatusCode: response.status,
1050
- RawResponse: response,
1051
- };
1052
-
1053
- if (this.matchResponse(response, 200, "application/json")) {
1054
- const responseBody = await response.json();
1055
- const result = operations.UpdateAgentResponse$.inboundSchema.parse({
1056
- ...responseFields$,
1057
- Agent: responseBody,
1058
- });
1059
- return result;
1060
- } else if (this.matchResponse(response, 400, "application/json")) {
1061
- const responseBody = await response.json();
1062
- const result = errors.UpdateAgentResponseBody$.inboundSchema.parse({
1063
- ...responseFields$,
1064
- ...responseBody,
1065
- });
1066
- throw result;
1067
- } else if (this.matchResponse(response, 401, "application/json")) {
1068
- const responseBody = await response.json();
1069
- const result = errors.UpdateAgentResponseResponseBody$.inboundSchema.parse({
1070
- ...responseFields$,
1071
- ...responseBody,
1072
- });
1073
- throw result;
1074
- } else if (this.matchResponse(response, 422, "application/json")) {
1075
- const responseBody = await response.json();
1076
- const result = errors.UpdateAgentResponse422ResponseBody$.inboundSchema.parse({
1077
- ...responseFields$,
1078
- ...responseBody,
1079
- });
1080
- throw result;
1081
- } else if (this.matchResponse(response, 500, "application/json")) {
1082
- const responseBody = await response.json();
1083
- const result = errors.UpdateAgentResponse500ResponseBody$.inboundSchema.parse({
1084
- ...responseFields$,
1085
- ...responseBody,
1086
- });
1087
- throw result;
1088
- } else {
1089
- const responseBody = await response.text();
1090
- throw new errors.SDKError("Unexpected API response", response, responseBody);
1091
- }
686
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
687
+
688
+ const response = await this.fetch$(
689
+ {
690
+ security: securitySettings$,
691
+ method: "get",
692
+ path: path$,
693
+ headers: headers$,
694
+ body: body$,
695
+ },
696
+ options,
697
+ );
698
+
699
+ const responseFields$ = {
700
+ ContentType:
701
+ response.headers.get("content-type") ?? "application/octet-stream",
702
+ StatusCode: response.status,
703
+ RawResponse: response,
704
+ };
705
+
706
+ if (this.matchResponse(response, 200, "application/json")) {
707
+ const responseBody = await response.json();
708
+ const result = operations.GetCallResponse$.inboundSchema.parse({
709
+ ...responseFields$,
710
+ CallDetail: responseBody,
711
+ });
712
+ return result;
713
+ } else if (this.matchResponse(response, 400, "application/json")) {
714
+ const responseBody = await response.json();
715
+ const result = errors.GetCallResponseBody$.inboundSchema.parse({
716
+ ...responseFields$,
717
+ ...responseBody,
718
+ });
719
+ throw result;
720
+ } else if (this.matchResponse(response, 401, "application/json")) {
721
+ const responseBody = await response.json();
722
+ const result = errors.GetCallResponseResponseBody$.inboundSchema.parse({
723
+ ...responseFields$,
724
+ ...responseBody,
725
+ });
726
+ throw result;
727
+ } else if (this.matchResponse(response, 422, "application/json")) {
728
+ const responseBody = await response.json();
729
+ const result = errors.GetCallResponse422ResponseBody$.inboundSchema.parse(
730
+ {
731
+ ...responseFields$,
732
+ ...responseBody,
733
+ },
734
+ );
735
+ throw result;
736
+ } else if (this.matchResponse(response, 500, "application/json")) {
737
+ const responseBody = await response.json();
738
+ const result = errors.GetCallResponse500ResponseBody$.inboundSchema.parse(
739
+ {
740
+ ...responseFields$,
741
+ ...responseBody,
742
+ },
743
+ );
744
+ throw result;
745
+ } else {
746
+ const responseBody = await response.text();
747
+ throw new errors.SDKError(
748
+ "Unexpected API response",
749
+ response,
750
+ responseBody,
751
+ );
1092
752
  }
1093
-
1094
- /**
1095
- * Update an existing phone number
1096
- */
1097
- async updatePhoneAgent(
1098
- requestBody: operations.UpdatePhoneAgentRequestBody,
1099
- phoneNumber: string,
1100
- options?: RequestOptions
1101
- ): Promise<operations.UpdatePhoneAgentResponse> {
1102
- const input$: operations.UpdatePhoneAgentRequest = {
1103
- requestBody: requestBody,
1104
- phoneNumber: phoneNumber,
1105
- };
1106
- const headers$ = new Headers();
1107
- headers$.set("user-agent", SDK_METADATA.userAgent);
1108
- headers$.set("Content-Type", "application/json");
1109
- headers$.set("Accept", "application/json");
1110
-
1111
- const payload$ = operations.UpdatePhoneAgentRequest$.outboundSchema.parse(input$);
1112
-
1113
- const body$ = enc$.encodeJSON("body", payload$.RequestBody, { explode: true });
1114
-
1115
- const pathParams$ = {
1116
- phone_number: enc$.encodeSimple("phone_number", payload$.phone_number, {
1117
- explode: false,
1118
- charEncoding: "percent",
1119
- }),
1120
- };
1121
-
1122
- const path$ = this.templateURLComponent("/update-phone-agent/{phone_number}")(pathParams$);
1123
-
1124
- let security$;
1125
- if (typeof this.options$.apiKey === "function") {
1126
- security$ = { apiKey: await this.options$.apiKey() };
1127
- } else if (this.options$.apiKey) {
1128
- security$ = { apiKey: this.options$.apiKey };
1129
- } else {
1130
- security$ = {};
1131
- }
1132
- const securitySettings$ = this.resolveGlobalSecurity(security$);
1133
-
1134
- const response = await this.fetch$(
1135
- {
1136
- security: securitySettings$,
1137
- method: "PATCH",
1138
- path: path$,
1139
- headers: headers$,
1140
- body: body$,
1141
- },
1142
- options
1143
- );
1144
-
1145
- const responseFields$ = {
1146
- ContentType: response.headers.get("content-type") ?? "application/octet-stream",
1147
- StatusCode: response.status,
1148
- RawResponse: response,
1149
- };
1150
-
1151
- if (this.matchResponse(response, 200, "application/json")) {
1152
- const responseBody = await response.json();
1153
- const result = operations.UpdatePhoneAgentResponse$.inboundSchema.parse({
1154
- ...responseFields$,
1155
- PhoneNumber: responseBody,
1156
- });
1157
- return result;
1158
- } else if (this.matchResponse(response, 400, "application/json")) {
1159
- const responseBody = await response.json();
1160
- const result = errors.UpdatePhoneAgentResponseBody$.inboundSchema.parse({
1161
- ...responseFields$,
1162
- ...responseBody,
1163
- });
1164
- throw result;
1165
- } else if (this.matchResponse(response, 401, "application/json")) {
1166
- const responseBody = await response.json();
1167
- const result = errors.UpdatePhoneAgentResponseResponseBody$.inboundSchema.parse({
1168
- ...responseFields$,
1169
- ...responseBody,
1170
- });
1171
- throw result;
1172
- } else if (this.matchResponse(response, 422, "application/json")) {
1173
- const responseBody = await response.json();
1174
- const result = errors.UpdatePhoneAgentResponse422ResponseBody$.inboundSchema.parse({
1175
- ...responseFields$,
1176
- ...responseBody,
1177
- });
1178
- throw result;
1179
- } else if (this.matchResponse(response, 500, "application/json")) {
1180
- const responseBody = await response.json();
1181
- const result = errors.UpdatePhoneAgentResponse500ResponseBody$.inboundSchema.parse({
1182
- ...responseFields$,
1183
- ...responseBody,
1184
- });
1185
- throw result;
1186
- } else {
1187
- const responseBody = await response.text();
1188
- throw new errors.SDKError("Unexpected API response", response, responseBody);
1189
- }
753
+ }
754
+
755
+ /**
756
+ * Retrieve info about a specific number
757
+ */
758
+ async getPhoneNumber(
759
+ phoneNumber: string,
760
+ options?: RequestOptions,
761
+ ): Promise<operations.GetPhoneNumberResponse> {
762
+ const input$: operations.GetPhoneNumberRequest = {
763
+ phoneNumber: phoneNumber,
764
+ };
765
+ const headers$ = new Headers();
766
+ headers$.set("user-agent", SDK_METADATA.userAgent);
767
+ headers$.set("Accept", "application/json");
768
+
769
+ const payload$ =
770
+ operations.GetPhoneNumberRequest$.outboundSchema.parse(input$);
771
+ const body$ = null;
772
+
773
+ const pathParams$ = {
774
+ phone_number: enc$.encodeSimple("phone_number", payload$.phone_number, {
775
+ explode: false,
776
+ charEncoding: "percent",
777
+ }),
778
+ };
779
+
780
+ const path$ = this.templateURLComponent("/get-phone-number/{phone_number}")(
781
+ pathParams$,
782
+ );
783
+
784
+ let security$;
785
+ if (typeof this.options$.apiKey === "function") {
786
+ security$ = { apiKey: await this.options$.apiKey() };
787
+ } else if (this.options$.apiKey) {
788
+ security$ = { apiKey: this.options$.apiKey };
789
+ } else {
790
+ security$ = {};
791
+ }
792
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
793
+
794
+ const response = await this.fetch$(
795
+ {
796
+ security: securitySettings$,
797
+ method: "get",
798
+ path: path$,
799
+ headers: headers$,
800
+ body: body$,
801
+ },
802
+ options,
803
+ );
804
+
805
+ const responseFields$ = {
806
+ ContentType:
807
+ response.headers.get("content-type") ?? "application/octet-stream",
808
+ StatusCode: response.status,
809
+ RawResponse: response,
810
+ };
811
+
812
+ if (this.matchResponse(response, 200, "application/json")) {
813
+ const responseBody = await response.json();
814
+ const result = operations.GetPhoneNumberResponse$.inboundSchema.parse({
815
+ ...responseFields$,
816
+ PhoneNumber: responseBody,
817
+ });
818
+ return result;
819
+ } else if (this.matchResponse(response, 400, "application/json")) {
820
+ const responseBody = await response.json();
821
+ const result = errors.GetPhoneNumberResponseBody$.inboundSchema.parse({
822
+ ...responseFields$,
823
+ ...responseBody,
824
+ });
825
+ throw result;
826
+ } else if (this.matchResponse(response, 401, "application/json")) {
827
+ const responseBody = await response.json();
828
+ const result =
829
+ errors.GetPhoneNumberResponseResponseBody$.inboundSchema.parse({
830
+ ...responseFields$,
831
+ ...responseBody,
832
+ });
833
+ throw result;
834
+ } else if (this.matchResponse(response, 422, "application/json")) {
835
+ const responseBody = await response.json();
836
+ const result =
837
+ errors.GetPhoneNumberResponse422ResponseBody$.inboundSchema.parse({
838
+ ...responseFields$,
839
+ ...responseBody,
840
+ });
841
+ throw result;
842
+ } else if (this.matchResponse(response, 500, "application/json")) {
843
+ const responseBody = await response.json();
844
+ const result =
845
+ errors.GetPhoneNumberResponse500ResponseBody$.inboundSchema.parse({
846
+ ...responseFields$,
847
+ ...responseBody,
848
+ });
849
+ throw result;
850
+ } else {
851
+ const responseBody = await response.text();
852
+ throw new errors.SDKError(
853
+ "Unexpected API response",
854
+ response,
855
+ responseBody,
856
+ );
857
+ }
858
+ }
859
+
860
+ /**
861
+ * List all agents
862
+ */
863
+ async listAgents(
864
+ options?: RequestOptions,
865
+ ): Promise<operations.ListAgentsResponse> {
866
+ const headers$ = new Headers();
867
+ headers$.set("user-agent", SDK_METADATA.userAgent);
868
+ headers$.set("Accept", "application/json");
869
+
870
+ const path$ = this.templateURLComponent("/list-agents")();
871
+
872
+ let security$;
873
+ if (typeof this.options$.apiKey === "function") {
874
+ security$ = { apiKey: await this.options$.apiKey() };
875
+ } else if (this.options$.apiKey) {
876
+ security$ = { apiKey: this.options$.apiKey };
877
+ } else {
878
+ security$ = {};
879
+ }
880
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
881
+
882
+ const response = await this.fetch$(
883
+ {
884
+ security: securitySettings$,
885
+ method: "get",
886
+ path: path$,
887
+ headers: headers$,
888
+ },
889
+ options,
890
+ );
891
+
892
+ const responseFields$ = {
893
+ ContentType:
894
+ response.headers.get("content-type") ?? "application/octet-stream",
895
+ StatusCode: response.status,
896
+ RawResponse: response,
897
+ };
898
+
899
+ if (this.matchResponse(response, 200, "application/json")) {
900
+ const responseBody = await response.json();
901
+ const result = operations.ListAgentsResponse$.inboundSchema.parse({
902
+ ...responseFields$,
903
+ agents: responseBody,
904
+ });
905
+ return result;
906
+ } else if (this.matchResponse(response, 401, "application/json")) {
907
+ const responseBody = await response.json();
908
+ const result = errors.ListAgentsResponseBody$.inboundSchema.parse({
909
+ ...responseFields$,
910
+ ...responseBody,
911
+ });
912
+ throw result;
913
+ } else if (this.matchResponse(response, 500, "application/json")) {
914
+ const responseBody = await response.json();
915
+ const result = errors.ListAgentsResponseResponseBody$.inboundSchema.parse(
916
+ {
917
+ ...responseFields$,
918
+ ...responseBody,
919
+ },
920
+ );
921
+ throw result;
922
+ } else {
923
+ const responseBody = await response.text();
924
+ throw new errors.SDKError(
925
+ "Unexpected API response",
926
+ response,
927
+ responseBody,
928
+ );
929
+ }
930
+ }
931
+
932
+ /**
933
+ * Retrieve call details
934
+ */
935
+ async listCalls(
936
+ filterCriteria?: operations.FilterCriteria | undefined,
937
+ limit?: number | undefined,
938
+ sortOrder?: operations.SortOrder | undefined,
939
+ options?: RequestOptions,
940
+ ): Promise<operations.ListCallsResponse> {
941
+ const input$: operations.ListCallsRequest = {
942
+ filterCriteria: filterCriteria,
943
+ limit: limit,
944
+ sortOrder: sortOrder,
945
+ };
946
+ const headers$ = new Headers();
947
+ headers$.set("user-agent", SDK_METADATA.userAgent);
948
+ headers$.set("Accept", "application/json");
949
+
950
+ const payload$ = operations.ListCallsRequest$.outboundSchema.parse(input$);
951
+ const body$ = null;
952
+
953
+ const path$ = this.templateURLComponent("/list-calls")();
954
+
955
+ const query$ = [
956
+ enc$.encodeForm(
957
+ "filter_criteria",
958
+ JSON.stringify(payload$.filter_criteria),
959
+ {
960
+ explode: true,
961
+ charEncoding: "percent",
962
+ },
963
+ ),
964
+ enc$.encodeForm("limit", payload$.limit, {
965
+ explode: true,
966
+ charEncoding: "percent",
967
+ }),
968
+ enc$.encodeForm("sort_order", payload$.sort_order, {
969
+ explode: true,
970
+ charEncoding: "percent",
971
+ }),
972
+ ]
973
+ .filter(Boolean)
974
+ .join("&");
975
+
976
+ let security$;
977
+ if (typeof this.options$.apiKey === "function") {
978
+ security$ = { apiKey: await this.options$.apiKey() };
979
+ } else if (this.options$.apiKey) {
980
+ security$ = { apiKey: this.options$.apiKey };
981
+ } else {
982
+ security$ = {};
983
+ }
984
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
985
+
986
+ const response = await this.fetch$(
987
+ {
988
+ security: securitySettings$,
989
+ method: "get",
990
+ path: path$,
991
+ headers: headers$,
992
+ query: query$,
993
+ body: body$,
994
+ },
995
+ options,
996
+ );
997
+
998
+ const responseFields$ = {
999
+ ContentType:
1000
+ response.headers.get("content-type") ?? "application/octet-stream",
1001
+ StatusCode: response.status,
1002
+ RawResponse: response,
1003
+ };
1004
+
1005
+ if (this.matchResponse(response, 200, "application/json")) {
1006
+ const responseBody = await response.json();
1007
+ const result = operations.ListCallsResponse$.inboundSchema.parse({
1008
+ ...responseFields$,
1009
+ calls: responseBody,
1010
+ });
1011
+ return result;
1012
+ } else if (this.matchResponse(response, 400, "application/json")) {
1013
+ const responseBody = await response.json();
1014
+ const result = errors.ListCallsResponseBody$.inboundSchema.parse({
1015
+ ...responseFields$,
1016
+ ...responseBody,
1017
+ });
1018
+ throw result;
1019
+ } else if (this.matchResponse(response, 401, "application/json")) {
1020
+ const responseBody = await response.json();
1021
+ const result = errors.ListCallsResponseResponseBody$.inboundSchema.parse({
1022
+ ...responseFields$,
1023
+ ...responseBody,
1024
+ });
1025
+ throw result;
1026
+ } else if (this.matchResponse(response, 500, "application/json")) {
1027
+ const responseBody = await response.json();
1028
+ const result =
1029
+ errors.ListCallsResponse500ResponseBody$.inboundSchema.parse({
1030
+ ...responseFields$,
1031
+ ...responseBody,
1032
+ });
1033
+ throw result;
1034
+ } else {
1035
+ const responseBody = await response.text();
1036
+ throw new errors.SDKError(
1037
+ "Unexpected API response",
1038
+ response,
1039
+ responseBody,
1040
+ );
1041
+ }
1042
+ }
1043
+
1044
+ /**
1045
+ * List all purchased and active phone numbers
1046
+ */
1047
+ async listPhoneNumbers(
1048
+ options?: RequestOptions,
1049
+ ): Promise<operations.ListPhoneNumbersResponse> {
1050
+ const headers$ = new Headers();
1051
+ headers$.set("user-agent", SDK_METADATA.userAgent);
1052
+ headers$.set("Accept", "application/json");
1053
+
1054
+ const path$ = this.templateURLComponent("/list-phone-numbers")();
1055
+
1056
+ let security$;
1057
+ if (typeof this.options$.apiKey === "function") {
1058
+ security$ = { apiKey: await this.options$.apiKey() };
1059
+ } else if (this.options$.apiKey) {
1060
+ security$ = { apiKey: this.options$.apiKey };
1061
+ } else {
1062
+ security$ = {};
1063
+ }
1064
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
1065
+
1066
+ const response = await this.fetch$(
1067
+ {
1068
+ security: securitySettings$,
1069
+ method: "get",
1070
+ path: path$,
1071
+ headers: headers$,
1072
+ },
1073
+ options,
1074
+ );
1075
+
1076
+ const responseFields$ = {
1077
+ ContentType:
1078
+ response.headers.get("content-type") ?? "application/octet-stream",
1079
+ StatusCode: response.status,
1080
+ RawResponse: response,
1081
+ };
1082
+
1083
+ if (this.matchResponse(response, 200, "application/json")) {
1084
+ const responseBody = await response.json();
1085
+ const result = operations.ListPhoneNumbersResponse$.inboundSchema.parse({
1086
+ ...responseFields$,
1087
+ phoneNumbers: responseBody,
1088
+ });
1089
+ return result;
1090
+ } else if (this.matchResponse(response, 400, "application/json")) {
1091
+ const responseBody = await response.json();
1092
+ const result = errors.ListPhoneNumbersResponseBody$.inboundSchema.parse({
1093
+ ...responseFields$,
1094
+ ...responseBody,
1095
+ });
1096
+ throw result;
1097
+ } else if (this.matchResponse(response, 401, "application/json")) {
1098
+ const responseBody = await response.json();
1099
+ const result =
1100
+ errors.ListPhoneNumbersResponseResponseBody$.inboundSchema.parse({
1101
+ ...responseFields$,
1102
+ ...responseBody,
1103
+ });
1104
+ throw result;
1105
+ } else if (this.matchResponse(response, 500, "application/json")) {
1106
+ const responseBody = await response.json();
1107
+ const result =
1108
+ errors.ListPhoneNumbersResponse500ResponseBody$.inboundSchema.parse({
1109
+ ...responseFields$,
1110
+ ...responseBody,
1111
+ });
1112
+ throw result;
1113
+ } else {
1114
+ const responseBody = await response.text();
1115
+ throw new errors.SDKError(
1116
+ "Unexpected API response",
1117
+ response,
1118
+ responseBody,
1119
+ );
1120
+ }
1121
+ }
1122
+
1123
+ /**
1124
+ * Update an existing agent
1125
+ */
1126
+ async updateAgent(
1127
+ requestBody: operations.UpdateAgentRequestBody,
1128
+ agentId: string,
1129
+ options?: RequestOptions,
1130
+ ): Promise<operations.UpdateAgentResponse> {
1131
+ const input$: operations.UpdateAgentRequest = {
1132
+ requestBody: requestBody,
1133
+ agentId: agentId,
1134
+ };
1135
+ const headers$ = new Headers();
1136
+ headers$.set("user-agent", SDK_METADATA.userAgent);
1137
+ headers$.set("Content-Type", "application/json");
1138
+ headers$.set("Accept", "application/json");
1139
+
1140
+ const payload$ =
1141
+ operations.UpdateAgentRequest$.outboundSchema.parse(input$);
1142
+
1143
+ const body$ = enc$.encodeJSON("body", payload$.RequestBody, {
1144
+ explode: true,
1145
+ });
1146
+
1147
+ const pathParams$ = {
1148
+ agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
1149
+ explode: false,
1150
+ charEncoding: "percent",
1151
+ }),
1152
+ };
1153
+
1154
+ const path$ = this.templateURLComponent("/update-agent/{agent_id}")(
1155
+ pathParams$,
1156
+ );
1157
+
1158
+ let security$;
1159
+ if (typeof this.options$.apiKey === "function") {
1160
+ security$ = { apiKey: await this.options$.apiKey() };
1161
+ } else if (this.options$.apiKey) {
1162
+ security$ = { apiKey: this.options$.apiKey };
1163
+ } else {
1164
+ security$ = {};
1165
+ }
1166
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
1167
+
1168
+ const response = await this.fetch$(
1169
+ {
1170
+ security: securitySettings$,
1171
+ method: "PATCH",
1172
+ path: path$,
1173
+ headers: headers$,
1174
+ body: body$,
1175
+ },
1176
+ options,
1177
+ );
1178
+
1179
+ const responseFields$ = {
1180
+ ContentType:
1181
+ response.headers.get("content-type") ?? "application/octet-stream",
1182
+ StatusCode: response.status,
1183
+ RawResponse: response,
1184
+ };
1185
+
1186
+ if (this.matchResponse(response, 200, "application/json")) {
1187
+ const responseBody = await response.json();
1188
+ const result = operations.UpdateAgentResponse$.inboundSchema.parse({
1189
+ ...responseFields$,
1190
+ Agent: responseBody,
1191
+ });
1192
+ return result;
1193
+ } else if (this.matchResponse(response, 400, "application/json")) {
1194
+ const responseBody = await response.json();
1195
+ const result = errors.UpdateAgentResponseBody$.inboundSchema.parse({
1196
+ ...responseFields$,
1197
+ ...responseBody,
1198
+ });
1199
+ throw result;
1200
+ } else if (this.matchResponse(response, 401, "application/json")) {
1201
+ const responseBody = await response.json();
1202
+ const result =
1203
+ errors.UpdateAgentResponseResponseBody$.inboundSchema.parse({
1204
+ ...responseFields$,
1205
+ ...responseBody,
1206
+ });
1207
+ throw result;
1208
+ } else if (this.matchResponse(response, 422, "application/json")) {
1209
+ const responseBody = await response.json();
1210
+ const result =
1211
+ errors.UpdateAgentResponse422ResponseBody$.inboundSchema.parse({
1212
+ ...responseFields$,
1213
+ ...responseBody,
1214
+ });
1215
+ throw result;
1216
+ } else if (this.matchResponse(response, 500, "application/json")) {
1217
+ const responseBody = await response.json();
1218
+ const result =
1219
+ errors.UpdateAgentResponse500ResponseBody$.inboundSchema.parse({
1220
+ ...responseFields$,
1221
+ ...responseBody,
1222
+ });
1223
+ throw result;
1224
+ } else {
1225
+ const responseBody = await response.text();
1226
+ throw new errors.SDKError(
1227
+ "Unexpected API response",
1228
+ response,
1229
+ responseBody,
1230
+ );
1231
+ }
1232
+ }
1233
+
1234
+ /**
1235
+ * Update an existing phone number
1236
+ */
1237
+ async updatePhoneAgent(
1238
+ requestBody: operations.UpdatePhoneAgentRequestBody,
1239
+ phoneNumber: string,
1240
+ options?: RequestOptions,
1241
+ ): Promise<operations.UpdatePhoneAgentResponse> {
1242
+ const input$: operations.UpdatePhoneAgentRequest = {
1243
+ requestBody: requestBody,
1244
+ phoneNumber: phoneNumber,
1245
+ };
1246
+ const headers$ = new Headers();
1247
+ headers$.set("user-agent", SDK_METADATA.userAgent);
1248
+ headers$.set("Content-Type", "application/json");
1249
+ headers$.set("Accept", "application/json");
1250
+
1251
+ const payload$ =
1252
+ operations.UpdatePhoneAgentRequest$.outboundSchema.parse(input$);
1253
+
1254
+ const body$ = enc$.encodeJSON("body", payload$.RequestBody, {
1255
+ explode: true,
1256
+ });
1257
+
1258
+ const pathParams$ = {
1259
+ phone_number: enc$.encodeSimple("phone_number", payload$.phone_number, {
1260
+ explode: false,
1261
+ charEncoding: "percent",
1262
+ }),
1263
+ };
1264
+
1265
+ const path$ = this.templateURLComponent(
1266
+ "/update-phone-agent/{phone_number}",
1267
+ )(pathParams$);
1268
+
1269
+ let security$;
1270
+ if (typeof this.options$.apiKey === "function") {
1271
+ security$ = { apiKey: await this.options$.apiKey() };
1272
+ } else if (this.options$.apiKey) {
1273
+ security$ = { apiKey: this.options$.apiKey };
1274
+ } else {
1275
+ security$ = {};
1276
+ }
1277
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
1278
+
1279
+ const response = await this.fetch$(
1280
+ {
1281
+ security: securitySettings$,
1282
+ method: "PATCH",
1283
+ path: path$,
1284
+ headers: headers$,
1285
+ body: body$,
1286
+ },
1287
+ options,
1288
+ );
1289
+
1290
+ const responseFields$ = {
1291
+ ContentType:
1292
+ response.headers.get("content-type") ?? "application/octet-stream",
1293
+ StatusCode: response.status,
1294
+ RawResponse: response,
1295
+ };
1296
+
1297
+ if (this.matchResponse(response, 200, "application/json")) {
1298
+ const responseBody = await response.json();
1299
+ const result = operations.UpdatePhoneAgentResponse$.inboundSchema.parse({
1300
+ ...responseFields$,
1301
+ PhoneNumber: responseBody,
1302
+ });
1303
+ return result;
1304
+ } else if (this.matchResponse(response, 400, "application/json")) {
1305
+ const responseBody = await response.json();
1306
+ const result = errors.UpdatePhoneAgentResponseBody$.inboundSchema.parse({
1307
+ ...responseFields$,
1308
+ ...responseBody,
1309
+ });
1310
+ throw result;
1311
+ } else if (this.matchResponse(response, 401, "application/json")) {
1312
+ const responseBody = await response.json();
1313
+ const result =
1314
+ errors.UpdatePhoneAgentResponseResponseBody$.inboundSchema.parse({
1315
+ ...responseFields$,
1316
+ ...responseBody,
1317
+ });
1318
+ throw result;
1319
+ } else if (this.matchResponse(response, 422, "application/json")) {
1320
+ const responseBody = await response.json();
1321
+ const result =
1322
+ errors.UpdatePhoneAgentResponse422ResponseBody$.inboundSchema.parse({
1323
+ ...responseFields$,
1324
+ ...responseBody,
1325
+ });
1326
+ throw result;
1327
+ } else if (this.matchResponse(response, 500, "application/json")) {
1328
+ const responseBody = await response.json();
1329
+ const result =
1330
+ errors.UpdatePhoneAgentResponse500ResponseBody$.inboundSchema.parse({
1331
+ ...responseFields$,
1332
+ ...responseBody,
1333
+ });
1334
+ throw result;
1335
+ } else {
1336
+ const responseBody = await response.text();
1337
+ throw new errors.SDKError(
1338
+ "Unexpected API response",
1339
+ response,
1340
+ responseBody,
1341
+ );
1190
1342
  }
1343
+ }
1191
1344
  }