retell-sdk 2.2.3 → 2.2.6

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 (184) hide show
  1. package/example.js +48 -5
  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 +3 -205
  11. package/models/components/agent.d.ts.map +1 -1
  12. package/models/components/agent.js +5 -187
  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 +33 -22
  17. package/models/components/calldetail.d.ts.map +1 -1
  18. package/models/components/calldetail.js +44 -31
  19. package/models/components/calldetail.js.map +1 -1
  20. package/models/components/callphonenumber.d.ts.map +1 -1
  21. package/models/components/callphonenumber.js.map +1 -1
  22. package/models/components/index.d.ts +0 -3
  23. package/models/components/index.d.ts.map +1 -1
  24. package/models/components/index.js +0 -3
  25. package/models/components/index.js.map +1 -1
  26. package/models/components/phonenumber.d.ts.map +1 -1
  27. package/models/components/phonenumber.js.map +1 -1
  28. package/models/components/security.d.ts.map +1 -1
  29. package/models/errors/createagent.d.ts.map +1 -1
  30. package/models/errors/createagent.js +36 -12
  31. package/models/errors/createagent.js.map +1 -1
  32. package/models/errors/createphonecall.d.ts.map +1 -1
  33. package/models/errors/createphonecall.js +54 -18
  34. package/models/errors/createphonecall.js.map +1 -1
  35. package/models/errors/createphonenumber.d.ts.map +1 -1
  36. package/models/errors/createphonenumber.js +42 -14
  37. package/models/errors/createphonenumber.js.map +1 -1
  38. package/models/errors/deleteagent.d.ts.map +1 -1
  39. package/models/errors/deleteagent.js +36 -12
  40. package/models/errors/deleteagent.js.map +1 -1
  41. package/models/errors/deletephonenumber.d.ts.map +1 -1
  42. package/models/errors/deletephonenumber.js +33 -11
  43. package/models/errors/deletephonenumber.js.map +1 -1
  44. package/models/errors/getagent.d.ts.map +1 -1
  45. package/models/errors/getagent.js +36 -12
  46. package/models/errors/getagent.js.map +1 -1
  47. package/models/errors/getcall.d.ts.map +1 -1
  48. package/models/errors/getcall.js +30 -10
  49. package/models/errors/getcall.js.map +1 -1
  50. package/models/errors/getphonenumber.d.ts.map +1 -1
  51. package/models/errors/getphonenumber.js +36 -12
  52. package/models/errors/getphonenumber.js.map +1 -1
  53. package/models/errors/index.d.ts +1 -6
  54. package/models/errors/index.d.ts.map +1 -1
  55. package/models/errors/index.js +1 -6
  56. package/models/errors/index.js.map +1 -1
  57. package/models/errors/listagents.d.ts.map +1 -1
  58. package/models/errors/listagents.js +15 -5
  59. package/models/errors/listagents.js.map +1 -1
  60. package/models/errors/listcalls.d.ts.map +1 -1
  61. package/models/errors/listcalls.js +24 -8
  62. package/models/errors/listcalls.js.map +1 -1
  63. package/models/errors/listphonenumbers.d.ts.map +1 -1
  64. package/models/errors/listphonenumbers.js +27 -9
  65. package/models/errors/listphonenumbers.js.map +1 -1
  66. package/models/errors/registercall.d.ts +218 -0
  67. package/models/errors/registercall.d.ts.map +1 -0
  68. package/models/errors/registercall.js +386 -0
  69. package/models/errors/registercall.js.map +1 -0
  70. package/models/errors/updateagent.d.ts.map +1 -1
  71. package/models/errors/updateagent.js +36 -12
  72. package/models/errors/updateagent.js.map +1 -1
  73. package/models/errors/updatephoneagent.d.ts.map +1 -1
  74. package/models/errors/updatephoneagent.js +36 -12
  75. package/models/errors/updatephoneagent.js.map +1 -1
  76. package/models/operations/createagent.d.ts +3 -16
  77. package/models/operations/createagent.d.ts.map +1 -1
  78. package/models/operations/createagent.js +4 -12
  79. package/models/operations/createagent.js.map +1 -1
  80. package/models/operations/createphonecall.d.ts.map +1 -1
  81. package/models/operations/createphonecall.js +18 -6
  82. package/models/operations/createphonecall.js.map +1 -1
  83. package/models/operations/createphonenumber.d.ts.map +1 -1
  84. package/models/operations/createphonenumber.js +6 -2
  85. package/models/operations/createphonenumber.js.map +1 -1
  86. package/models/operations/createwebcall.d.ts.map +1 -1
  87. package/models/operations/deleteagent.d.ts.map +1 -1
  88. package/models/operations/deleteagent.js.map +1 -1
  89. package/models/operations/deletephonenumber.d.ts.map +1 -1
  90. package/models/operations/deletephonenumber.js.map +1 -1
  91. package/models/operations/getagent.d.ts.map +1 -1
  92. package/models/operations/getagent.js.map +1 -1
  93. package/models/operations/getcall.d.ts +1 -1
  94. package/models/operations/getcall.d.ts.map +1 -1
  95. package/models/operations/getcall.js.map +1 -1
  96. package/models/operations/getphonenumber.d.ts.map +1 -1
  97. package/models/operations/getphonenumber.js +6 -2
  98. package/models/operations/getphonenumber.js.map +1 -1
  99. package/models/operations/index.d.ts +1 -7
  100. package/models/operations/index.d.ts.map +1 -1
  101. package/models/operations/index.js +1 -7
  102. package/models/operations/index.js.map +1 -1
  103. package/models/operations/listagents.d.ts.map +1 -1
  104. package/models/operations/listagents.js.map +1 -1
  105. package/models/operations/listcalls.d.ts +1 -7
  106. package/models/operations/listcalls.d.ts.map +1 -1
  107. package/models/operations/listcalls.js +6 -6
  108. package/models/operations/listcalls.js.map +1 -1
  109. package/models/operations/listphonenumbers.d.ts.map +1 -1
  110. package/models/operations/listphonenumbers.js +6 -2
  111. package/models/operations/listphonenumbers.js.map +1 -1
  112. package/models/operations/registercall.d.ts +74 -0
  113. package/models/operations/registercall.d.ts.map +1 -0
  114. package/models/operations/registercall.js +104 -0
  115. package/models/operations/registercall.js.map +1 -0
  116. package/models/operations/updateagent.d.ts +3 -16
  117. package/models/operations/updateagent.d.ts.map +1 -1
  118. package/models/operations/updateagent.js +9 -13
  119. package/models/operations/updateagent.js.map +1 -1
  120. package/models/operations/updatephoneagent.d.ts.map +1 -1
  121. package/models/operations/updatephoneagent.js +6 -2
  122. package/models/operations/updatephoneagent.js.map +1 -1
  123. package/package.json +1 -1
  124. package/sdk/audioWsClient.d.ts +10 -0
  125. package/sdk/audioWsClient.d.ts.map +1 -0
  126. package/sdk/audioWsClient.js +60 -0
  127. package/sdk/audioWsClient.js.map +1 -0
  128. package/sdk/index.d.ts +1 -1
  129. package/sdk/index.d.ts.map +1 -1
  130. package/sdk/index.js +1 -1
  131. package/sdk/index.js.map +1 -1
  132. package/sdk/liveClient.d.ts.map +1 -1
  133. package/sdk/liveClient.js +7 -2
  134. package/sdk/liveClient.js.map +1 -1
  135. package/sdk/sdk.d.ts +1 -23
  136. package/sdk/sdk.d.ts.map +1 -1
  137. package/sdk/sdk.js +21 -430
  138. package/sdk/sdk.js.map +1 -1
  139. package/src/example.ts +136 -88
  140. package/src/lib/config.ts +32 -32
  141. package/src/lib/sdks.ts +91 -82
  142. package/src/lib/security.ts +133 -118
  143. package/src/models/components/agent.ts +71 -451
  144. package/src/models/components/calldetail.ts +147 -130
  145. package/src/models/components/index.ts +0 -3
  146. package/src/models/components/security.ts +1 -1
  147. package/src/models/errors/createagent.ts +359 -311
  148. package/src/models/errors/deleteagent.ts +359 -311
  149. package/src/models/errors/getagent.ts +358 -302
  150. package/src/models/errors/getcall.ts +348 -294
  151. package/src/models/errors/index.ts +1 -6
  152. package/src/models/errors/listagents.ts +174 -147
  153. package/src/models/errors/listcalls.ts +251 -211
  154. package/src/models/errors/registercall.ts +662 -0
  155. package/src/models/errors/updateagent.ts +359 -311
  156. package/src/models/operations/createagent.ts +124 -130
  157. package/src/models/operations/deleteagent.ts +94 -78
  158. package/src/models/operations/getagent.ts +104 -88
  159. package/src/models/operations/getcall.ts +101 -88
  160. package/src/models/operations/index.ts +1 -7
  161. package/src/models/operations/listagents.ts +68 -60
  162. package/src/models/operations/listcalls.ts +228 -213
  163. package/src/models/operations/registercall.ts +167 -0
  164. package/src/models/operations/updateagent.ts +180 -174
  165. package/src/sdk/audioWsClient.ts +63 -0
  166. package/src/sdk/index.ts +1 -1
  167. package/src/sdk/sdk.ts +802 -1162
  168. package/src/models/components/agentpromptparams.ts +0 -53
  169. package/src/models/components/callphonenumber.ts +0 -56
  170. package/src/models/components/phonenumber.ts +0 -83
  171. package/src/models/errors/createphonecall.ts +0 -597
  172. package/src/models/errors/createphonenumber.ts +0 -500
  173. package/src/models/errors/deletephonenumber.ts +0 -400
  174. package/src/models/errors/getphonenumber.ts +0 -397
  175. package/src/models/errors/listphonenumbers.ts +0 -297
  176. package/src/models/errors/updatephoneagent.ts +0 -397
  177. package/src/models/operations/createphonecall.ts +0 -308
  178. package/src/models/operations/createphonenumber.ts +0 -124
  179. package/src/models/operations/createwebcall.ts +0 -16
  180. package/src/models/operations/deletephonenumber.ts +0 -103
  181. package/src/models/operations/getphonenumber.ts +0 -114
  182. package/src/models/operations/listphonenumbers.ts +0 -76
  183. package/src/models/operations/updatephoneagent.ts +0 -159
  184. package/src/sdk/liveClient.ts +0 -109
package/src/sdk/sdk.ts CHANGED
@@ -8,1184 +8,824 @@ import { HTTPClient } from "../lib/http";
8
8
  import { ClientSDK, RequestOptions } from "../lib/sdks";
9
9
  import * as errors from "../models/errors";
10
10
  import * as operations from "../models/operations";
11
- import { LiveClient } from "./liveClient";
12
11
 
13
12
  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),
13
+ private readonly options$: SDKOptions;
14
+
15
+ constructor(options: SDKOptions = {}) {
16
+ super({
17
+ client: options.httpClient || new HTTPClient(),
18
+ baseURL: serverURLFromOptions(options),
19
+ });
20
+
21
+ this.options$ = options;
22
+ void this.options$;
23
+ }
24
+
25
+ /**
26
+ * Create a new agent
27
+ */
28
+ async createAgent(
29
+ input: operations.CreateAgentRequestBody,
30
+ options?: RequestOptions,
31
+ ): Promise<operations.CreateAgentResponse> {
32
+ const headers$ = new Headers();
33
+ headers$.set("user-agent", SDK_METADATA.userAgent);
34
+ headers$.set("Content-Type", "application/json");
35
+ headers$.set("Accept", "application/json");
36
+
37
+ const payload$ =
38
+ operations.CreateAgentRequestBody$.outboundSchema.parse(input);
39
+ const body$ = enc$.encodeJSON("body", payload$, { explode: true });
40
+
41
+ const path$ = this.templateURLComponent("/create-agent")();
42
+
43
+ let security$;
44
+ if (typeof this.options$.apiKey === "function") {
45
+ security$ = { apiKey: await this.options$.apiKey() };
46
+ } else if (this.options$.apiKey) {
47
+ security$ = { apiKey: this.options$.apiKey };
48
+ } else {
49
+ security$ = {};
50
+ }
51
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
52
+
53
+ const response = await this.fetch$(
54
+ {
55
+ security: securitySettings$,
56
+ method: "post",
57
+ path: path$,
58
+ headers: headers$,
59
+ body: body$,
60
+ },
61
+ options,
62
+ );
63
+
64
+ const responseFields$ = {
65
+ ContentType:
66
+ response.headers.get("content-type") ?? "application/octet-stream",
67
+ StatusCode: response.status,
68
+ RawResponse: response,
69
+ };
70
+
71
+ if (this.matchResponse(response, 201, "application/json")) {
72
+ const responseBody = await response.json();
73
+ const result = operations.CreateAgentResponse$.inboundSchema.parse({
74
+ ...responseFields$,
75
+ Agent: responseBody,
76
+ });
77
+ return result;
78
+ } else if (this.matchResponse(response, 400, "application/json")) {
79
+ const responseBody = await response.json();
80
+ const result = errors.CreateAgentResponseBody$.inboundSchema.parse({
81
+ ...responseFields$,
82
+ ...responseBody,
83
+ });
84
+ throw result;
85
+ } else if (this.matchResponse(response, 401, "application/json")) {
86
+ const responseBody = await response.json();
87
+ const result =
88
+ errors.CreateAgentResponseResponseBody$.inboundSchema.parse({
89
+ ...responseFields$,
90
+ ...responseBody,
20
91
  });
21
-
22
- this.options$ = options;
23
- void this.options$;
92
+ throw result;
93
+ } else if (this.matchResponse(response, 422, "application/json")) {
94
+ const responseBody = await response.json();
95
+ const result =
96
+ errors.CreateAgentResponse422ResponseBody$.inboundSchema.parse({
97
+ ...responseFields$,
98
+ ...responseBody,
99
+ });
100
+ throw result;
101
+ } else if (this.matchResponse(response, 500, "application/json")) {
102
+ const responseBody = await response.json();
103
+ const result =
104
+ errors.CreateAgentResponse500ResponseBody$.inboundSchema.parse({
105
+ ...responseFields$,
106
+ ...responseBody,
107
+ });
108
+ throw result;
109
+ } else {
110
+ const responseBody = await response.text();
111
+ throw new errors.SDKError(
112
+ "Unexpected API response",
113
+ response,
114
+ responseBody,
115
+ );
24
116
  }
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
- }
117
+ }
118
+
119
+ /**
120
+ * Initiate an outbound phone call.
121
+ */
122
+ async registerCall(
123
+ input: operations.RegisterCallRequestBody,
124
+ options?: RequestOptions,
125
+ ): Promise<operations.RegisterCallResponse> {
126
+ const headers$ = new Headers();
127
+ headers$.set("user-agent", SDK_METADATA.userAgent);
128
+ headers$.set("Content-Type", "application/json");
129
+ headers$.set("Accept", "application/json");
130
+
131
+ const payload$ =
132
+ operations.RegisterCallRequestBody$.outboundSchema.parse(input);
133
+ const body$ = enc$.encodeJSON("body", payload$, { explode: true });
134
+
135
+ const path$ = this.templateURLComponent("/register-call")();
136
+
137
+ let security$;
138
+ if (typeof this.options$.apiKey === "function") {
139
+ security$ = { apiKey: await this.options$.apiKey() };
140
+ } else if (this.options$.apiKey) {
141
+ security$ = { apiKey: this.options$.apiKey };
142
+ } else {
143
+ security$ = {};
120
144
  }
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
- }
145
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
146
+
147
+ const response = await this.fetch$(
148
+ {
149
+ security: securitySettings$,
150
+ method: "post",
151
+ path: path$,
152
+ headers: headers$,
153
+ body: body$,
154
+ },
155
+ options,
156
+ );
157
+
158
+ const responseFields$ = {
159
+ ContentType:
160
+ response.headers.get("content-type") ?? "application/octet-stream",
161
+ StatusCode: response.status,
162
+ RawResponse: response,
163
+ };
164
+
165
+ if (this.matchResponse(response, 201, "application/json")) {
166
+ const responseBody = await response.json();
167
+ const result = operations.RegisterCallResponse$.inboundSchema.parse({
168
+ ...responseFields$,
169
+ CallDetail: responseBody,
170
+ });
171
+ return result;
172
+ } else if (this.matchResponse(response, 400, "application/json")) {
173
+ const responseBody = await response.json();
174
+ const result = errors.RegisterCallResponseBody$.inboundSchema.parse({
175
+ ...responseFields$,
176
+ ...responseBody,
177
+ });
178
+ throw result;
179
+ } else if (this.matchResponse(response, 401, "application/json")) {
180
+ const responseBody = await response.json();
181
+ const result =
182
+ errors.RegisterCallResponseResponseBody$.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 =
190
+ errors.RegisterCallResponse402ResponseBody$.inboundSchema.parse({
191
+ ...responseFields$,
192
+ ...responseBody,
193
+ });
194
+ throw result;
195
+ } else if (this.matchResponse(response, 422, "application/json")) {
196
+ const responseBody = await response.json();
197
+ const result =
198
+ errors.RegisterCallResponse422ResponseBody$.inboundSchema.parse({
199
+ ...responseFields$,
200
+ ...responseBody,
201
+ });
202
+ throw result;
203
+ } else if (this.matchResponse(response, 429, "application/json")) {
204
+ const responseBody = await response.json();
205
+ const result =
206
+ errors.RegisterCallResponse429ResponseBody$.inboundSchema.parse({
207
+ ...responseFields$,
208
+ ...responseBody,
209
+ });
210
+ throw result;
211
+ } else if (this.matchResponse(response, 500, "application/json")) {
212
+ const responseBody = await response.json();
213
+ const result =
214
+ errors.RegisterCallResponse500ResponseBody$.inboundSchema.parse({
215
+ ...responseFields$,
216
+ ...responseBody,
217
+ });
218
+ throw result;
219
+ } else {
220
+ const responseBody = await response.text();
221
+ throw new errors.SDKError(
222
+ "Unexpected API response",
223
+ response,
224
+ responseBody,
225
+ );
219
226
  }
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
- }
227
+ }
228
+
229
+ /**
230
+ * Delete an existing agent
231
+ */
232
+ async deleteAgent(
233
+ agentId: string,
234
+ options?: RequestOptions,
235
+ ): Promise<operations.DeleteAgentResponse> {
236
+ const input$: operations.DeleteAgentRequest = {
237
+ agentId: agentId,
238
+ };
239
+ const headers$ = new Headers();
240
+ headers$.set("user-agent", SDK_METADATA.userAgent);
241
+ headers$.set("Accept", "application/json");
242
+
243
+ const payload$ =
244
+ operations.DeleteAgentRequest$.outboundSchema.parse(input$);
245
+ const body$ = null;
246
+
247
+ const pathParams$ = {
248
+ agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
249
+ explode: false,
250
+ charEncoding: "percent",
251
+ }),
252
+ };
253
+
254
+ const path$ = this.templateURLComponent("/delete-agent/{agent_id}")(
255
+ pathParams$,
256
+ );
257
+
258
+ let security$;
259
+ if (typeof this.options$.apiKey === "function") {
260
+ security$ = { apiKey: await this.options$.apiKey() };
261
+ } else if (this.options$.apiKey) {
262
+ security$ = { apiKey: this.options$.apiKey };
263
+ } else {
264
+ security$ = {};
311
265
  }
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$);
266
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
267
+
268
+ const response = await this.fetch$(
269
+ {
270
+ security: securitySettings$,
271
+ method: "delete",
272
+ path: path$,
273
+ headers: headers$,
274
+ body: body$,
275
+ },
276
+ options,
277
+ );
278
+
279
+ const responseFields$ = {
280
+ ContentType:
281
+ response.headers.get("content-type") ?? "application/octet-stream",
282
+ StatusCode: response.status,
283
+ RawResponse: response,
284
+ };
285
+
286
+ if (this.matchStatusCode(response, 204)) {
287
+ // fallthrough
288
+ } else if (this.matchResponse(response, 400, "application/json")) {
289
+ const responseBody = await response.json();
290
+ const result = errors.DeleteAgentResponseBody$.inboundSchema.parse({
291
+ ...responseFields$,
292
+ ...responseBody,
293
+ });
294
+ throw result;
295
+ } else if (this.matchResponse(response, 401, "application/json")) {
296
+ const responseBody = await response.json();
297
+ const result =
298
+ errors.DeleteAgentResponseResponseBody$.inboundSchema.parse({
299
+ ...responseFields$,
300
+ ...responseBody,
301
+ });
302
+ throw result;
303
+ } else if (this.matchResponse(response, 422, "application/json")) {
304
+ const responseBody = await response.json();
305
+ const result =
306
+ errors.DeleteAgentResponse422ResponseBody$.inboundSchema.parse({
307
+ ...responseFields$,
308
+ ...responseBody,
309
+ });
310
+ throw result;
311
+ } else if (this.matchResponse(response, 500, "application/json")) {
312
+ const responseBody = await response.json();
313
+ const result =
314
+ errors.DeleteAgentResponse500ResponseBody$.inboundSchema.parse({
315
+ ...responseFields$,
316
+ ...responseBody,
317
+ });
318
+ throw result;
319
+ } else {
320
+ const responseBody = await response.text();
321
+ throw new errors.SDKError(
322
+ "Unexpected API response",
323
+ response,
324
+ responseBody,
325
+ );
402
326
  }
403
327
 
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$);
328
+ return operations.DeleteAgentResponse$.inboundSchema.parse(responseFields$);
329
+ }
330
+
331
+ /**
332
+ * Retrieve details of a specific agent
333
+ */
334
+ async getAgent(
335
+ agentId: string,
336
+ options?: RequestOptions,
337
+ ): Promise<operations.GetAgentResponse> {
338
+ const input$: operations.GetAgentRequest = {
339
+ agentId: agentId,
340
+ };
341
+ const headers$ = new Headers();
342
+ headers$.set("user-agent", SDK_METADATA.userAgent);
343
+ headers$.set("Accept", "application/json");
344
+
345
+ const payload$ = operations.GetAgentRequest$.outboundSchema.parse(input$);
346
+ const body$ = null;
347
+
348
+ const pathParams$ = {
349
+ agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
350
+ explode: false,
351
+ charEncoding: "percent",
352
+ }),
353
+ };
354
+
355
+ const path$ = this.templateURLComponent("/get-agent/{agent_id}")(
356
+ pathParams$,
357
+ );
358
+
359
+ let security$;
360
+ if (typeof this.options$.apiKey === "function") {
361
+ security$ = { apiKey: await this.options$.apiKey() };
362
+ } else if (this.options$.apiKey) {
363
+ security$ = { apiKey: this.options$.apiKey };
364
+ } else {
365
+ security$ = {};
493
366
  }
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
- }
367
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
368
+
369
+ const response = await this.fetch$(
370
+ {
371
+ security: securitySettings$,
372
+ method: "get",
373
+ path: path$,
374
+ headers: headers$,
375
+ body: body$,
376
+ },
377
+ options,
378
+ );
379
+
380
+ const responseFields$ = {
381
+ ContentType:
382
+ response.headers.get("content-type") ?? "application/octet-stream",
383
+ StatusCode: response.status,
384
+ RawResponse: response,
385
+ };
386
+
387
+ if (this.matchResponse(response, 200, "application/json")) {
388
+ const responseBody = await response.json();
389
+ const result = operations.GetAgentResponse$.inboundSchema.parse({
390
+ ...responseFields$,
391
+ Agent: responseBody,
392
+ });
393
+ return result;
394
+ } else if (this.matchResponse(response, 400, "application/json")) {
395
+ const responseBody = await response.json();
396
+ const result = errors.GetAgentResponseBody$.inboundSchema.parse({
397
+ ...responseFields$,
398
+ ...responseBody,
399
+ });
400
+ throw result;
401
+ } else if (this.matchResponse(response, 401, "application/json")) {
402
+ const responseBody = await response.json();
403
+ const result = errors.GetAgentResponseResponseBody$.inboundSchema.parse({
404
+ ...responseFields$,
405
+ ...responseBody,
406
+ });
407
+ throw result;
408
+ } else if (this.matchResponse(response, 422, "application/json")) {
409
+ const responseBody = await response.json();
410
+ const result =
411
+ errors.GetAgentResponse422ResponseBody$.inboundSchema.parse({
412
+ ...responseFields$,
413
+ ...responseBody,
414
+ });
415
+ throw result;
416
+ } else if (this.matchResponse(response, 500, "application/json")) {
417
+ const responseBody = await response.json();
418
+ const result =
419
+ errors.GetAgentResponse500ResponseBody$.inboundSchema.parse({
420
+ ...responseFields$,
421
+ ...responseBody,
422
+ });
423
+ throw result;
424
+ } else {
425
+ const responseBody = await response.text();
426
+ throw new errors.SDKError(
427
+ "Unexpected API response",
428
+ response,
429
+ responseBody,
430
+ );
587
431
  }
588
-
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
- }
432
+ }
433
+
434
+ /**
435
+ * Retrieve details of a specific call
436
+ */
437
+ async getCall(
438
+ callId: string,
439
+ options?: RequestOptions,
440
+ ): Promise<operations.GetCallResponse> {
441
+ const input$: operations.GetCallRequest = {
442
+ callId: callId,
443
+ };
444
+ const headers$ = new Headers();
445
+ headers$.set("user-agent", SDK_METADATA.userAgent);
446
+ headers$.set("Accept", "application/json");
447
+
448
+ const payload$ = operations.GetCallRequest$.outboundSchema.parse(input$);
449
+ const body$ = null;
450
+
451
+ const pathParams$ = {
452
+ call_id: enc$.encodeSimple("call_id", payload$.call_id, {
453
+ explode: false,
454
+ charEncoding: "percent",
455
+ }),
456
+ };
457
+
458
+ const path$ = this.templateURLComponent("/get-call/{call_id}")(pathParams$);
459
+
460
+ let security$;
461
+ if (typeof this.options$.apiKey === "function") {
462
+ security$ = { apiKey: await this.options$.apiKey() };
463
+ } else if (this.options$.apiKey) {
464
+ security$ = { apiKey: this.options$.apiKey };
465
+ } else {
466
+ security$ = {};
678
467
  }
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
- }
468
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
469
+
470
+ const response = await this.fetch$(
471
+ {
472
+ security: securitySettings$,
473
+ method: "get",
474
+ path: path$,
475
+ headers: headers$,
476
+ body: body$,
477
+ },
478
+ options,
479
+ );
480
+
481
+ const responseFields$ = {
482
+ ContentType:
483
+ response.headers.get("content-type") ?? "application/octet-stream",
484
+ StatusCode: response.status,
485
+ RawResponse: response,
486
+ };
487
+
488
+ if (this.matchResponse(response, 200, "application/json")) {
489
+ const responseBody = await response.json();
490
+ const result = operations.GetCallResponse$.inboundSchema.parse({
491
+ ...responseFields$,
492
+ CallDetail: responseBody,
493
+ });
494
+ return result;
495
+ } else if (this.matchResponse(response, 400, "application/json")) {
496
+ const responseBody = await response.json();
497
+ const result = errors.GetCallResponseBody$.inboundSchema.parse({
498
+ ...responseFields$,
499
+ ...responseBody,
500
+ });
501
+ throw result;
502
+ } else if (this.matchResponse(response, 401, "application/json")) {
503
+ const responseBody = await response.json();
504
+ const result = errors.GetCallResponseResponseBody$.inboundSchema.parse({
505
+ ...responseFields$,
506
+ ...responseBody,
507
+ });
508
+ throw result;
509
+ } else if (this.matchResponse(response, 422, "application/json")) {
510
+ const responseBody = await response.json();
511
+ const result = errors.GetCallResponse422ResponseBody$.inboundSchema.parse(
512
+ {
513
+ ...responseFields$,
514
+ ...responseBody,
515
+ },
516
+ );
517
+ throw result;
518
+ } else if (this.matchResponse(response, 500, "application/json")) {
519
+ const responseBody = await response.json();
520
+ const result = errors.GetCallResponse500ResponseBody$.inboundSchema.parse(
521
+ {
522
+ ...responseFields$,
523
+ ...responseBody,
524
+ },
525
+ );
526
+ throw result;
527
+ } else {
528
+ const responseBody = await response.text();
529
+ throw new errors.SDKError(
530
+ "Unexpected API response",
531
+ response,
532
+ responseBody,
533
+ );
772
534
  }
773
-
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
- }
535
+ }
536
+
537
+ /**
538
+ * List all agents
539
+ */
540
+ async listAgents(
541
+ options?: RequestOptions,
542
+ ): Promise<operations.ListAgentsResponse> {
543
+ const headers$ = new Headers();
544
+ headers$.set("user-agent", SDK_METADATA.userAgent);
545
+ headers$.set("Accept", "application/json");
546
+
547
+ const path$ = this.templateURLComponent("/list-agents")();
548
+
549
+ let security$;
550
+ if (typeof this.options$.apiKey === "function") {
551
+ security$ = { apiKey: await this.options$.apiKey() };
552
+ } else if (this.options$.apiKey) {
553
+ security$ = { apiKey: this.options$.apiKey };
554
+ } else {
555
+ security$ = {};
830
556
  }
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
- }
557
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
558
+
559
+ const response = await this.fetch$(
560
+ {
561
+ security: securitySettings$,
562
+ method: "get",
563
+ path: path$,
564
+ headers: headers$,
565
+ },
566
+ options,
567
+ );
568
+
569
+ const responseFields$ = {
570
+ ContentType:
571
+ response.headers.get("content-type") ?? "application/octet-stream",
572
+ StatusCode: response.status,
573
+ RawResponse: response,
574
+ };
575
+
576
+ if (this.matchResponse(response, 200, "application/json")) {
577
+ const responseBody = await response.json();
578
+ const result = operations.ListAgentsResponse$.inboundSchema.parse({
579
+ ...responseFields$,
580
+ agents: responseBody,
581
+ });
582
+ return result;
583
+ } else if (this.matchResponse(response, 401, "application/json")) {
584
+ const responseBody = await response.json();
585
+ const result = errors.ListAgentsResponseBody$.inboundSchema.parse({
586
+ ...responseFields$,
587
+ ...responseBody,
588
+ });
589
+ throw result;
590
+ } else if (this.matchResponse(response, 500, "application/json")) {
591
+ const responseBody = await response.json();
592
+ const result = errors.ListAgentsResponseResponseBody$.inboundSchema.parse(
593
+ {
594
+ ...responseFields$,
595
+ ...responseBody,
596
+ },
597
+ );
598
+ throw result;
599
+ } else {
600
+ const responseBody = await response.text();
601
+ throw new errors.SDKError(
602
+ "Unexpected API response",
603
+ response,
604
+ responseBody,
605
+ );
929
606
  }
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
- }
607
+ }
608
+
609
+ /**
610
+ * Retrieve call details
611
+ */
612
+ async listCalls(
613
+ filterCriteria?: operations.FilterCriteria | undefined,
614
+ limit?: number | undefined,
615
+ sortOrder?: operations.SortOrder | undefined,
616
+ options?: RequestOptions,
617
+ ): Promise<operations.ListCallsResponse> {
618
+ const input$: operations.ListCallsRequest = {
619
+ filterCriteria: filterCriteria,
620
+ limit: limit,
621
+ sortOrder: sortOrder,
622
+ };
623
+ const headers$ = new Headers();
624
+ headers$.set("user-agent", SDK_METADATA.userAgent);
625
+ headers$.set("Accept", "application/json");
626
+
627
+ const payload$ = operations.ListCallsRequest$.outboundSchema.parse(input$);
628
+ const body$ = null;
629
+
630
+ const path$ = this.templateURLComponent("/list-calls")();
631
+
632
+ const query$ = [
633
+ enc$.encodeForm(
634
+ "filter_criteria",
635
+ JSON.stringify(payload$.filter_criteria),
636
+ {
637
+ explode: true,
638
+ charEncoding: "percent",
639
+ },
640
+ ),
641
+ enc$.encodeForm("limit", payload$.limit, {
642
+ explode: true,
643
+ charEncoding: "percent",
644
+ }),
645
+ enc$.encodeForm("sort_order", payload$.sort_order, {
646
+ explode: true,
647
+ charEncoding: "percent",
648
+ }),
649
+ ]
650
+ .filter(Boolean)
651
+ .join("&");
652
+
653
+ let security$;
654
+ if (typeof this.options$.apiKey === "function") {
655
+ security$ = { apiKey: await this.options$.apiKey() };
656
+ } else if (this.options$.apiKey) {
657
+ security$ = { apiKey: this.options$.apiKey };
658
+ } else {
659
+ security$ = {};
994
660
  }
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
- }
661
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
662
+
663
+ const response = await this.fetch$(
664
+ {
665
+ security: securitySettings$,
666
+ method: "get",
667
+ path: path$,
668
+ headers: headers$,
669
+ query: query$,
670
+ body: body$,
671
+ },
672
+ options,
673
+ );
674
+
675
+ const responseFields$ = {
676
+ ContentType:
677
+ response.headers.get("content-type") ?? "application/octet-stream",
678
+ StatusCode: response.status,
679
+ RawResponse: response,
680
+ };
681
+
682
+ if (this.matchResponse(response, 200, "application/json")) {
683
+ const responseBody = await response.json();
684
+ const result = operations.ListCallsResponse$.inboundSchema.parse({
685
+ ...responseFields$,
686
+ calls: responseBody,
687
+ });
688
+ return result;
689
+ } else if (this.matchResponse(response, 400, "application/json")) {
690
+ const responseBody = await response.json();
691
+ const result = errors.ListCallsResponseBody$.inboundSchema.parse({
692
+ ...responseFields$,
693
+ ...responseBody,
694
+ });
695
+ throw result;
696
+ } else if (this.matchResponse(response, 401, "application/json")) {
697
+ const responseBody = await response.json();
698
+ const result = errors.ListCallsResponseResponseBody$.inboundSchema.parse({
699
+ ...responseFields$,
700
+ ...responseBody,
701
+ });
702
+ throw result;
703
+ } else if (this.matchResponse(response, 500, "application/json")) {
704
+ const responseBody = await response.json();
705
+ const result =
706
+ errors.ListCallsResponse500ResponseBody$.inboundSchema.parse({
707
+ ...responseFields$,
708
+ ...responseBody,
709
+ });
710
+ throw result;
711
+ } else {
712
+ const responseBody = await response.text();
713
+ throw new errors.SDKError(
714
+ "Unexpected API response",
715
+ response,
716
+ responseBody,
717
+ );
1092
718
  }
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
- }
719
+ }
720
+
721
+ /**
722
+ * Update an existing agent
723
+ */
724
+ async updateAgent(
725
+ requestBody: operations.UpdateAgentRequestBody,
726
+ agentId: string,
727
+ options?: RequestOptions,
728
+ ): Promise<operations.UpdateAgentResponse> {
729
+ const input$: operations.UpdateAgentRequest = {
730
+ requestBody: requestBody,
731
+ agentId: agentId,
732
+ };
733
+ const headers$ = new Headers();
734
+ headers$.set("user-agent", SDK_METADATA.userAgent);
735
+ headers$.set("Content-Type", "application/json");
736
+ headers$.set("Accept", "application/json");
737
+
738
+ const payload$ =
739
+ operations.UpdateAgentRequest$.outboundSchema.parse(input$);
740
+
741
+ const body$ = enc$.encodeJSON("body", payload$.RequestBody, {
742
+ explode: true,
743
+ });
744
+
745
+ const pathParams$ = {
746
+ agent_id: enc$.encodeSimple("agent_id", payload$.agent_id, {
747
+ explode: false,
748
+ charEncoding: "percent",
749
+ }),
750
+ };
751
+
752
+ const path$ = this.templateURLComponent("/update-agent/{agent_id}")(
753
+ pathParams$,
754
+ );
755
+
756
+ let security$;
757
+ if (typeof this.options$.apiKey === "function") {
758
+ security$ = { apiKey: await this.options$.apiKey() };
759
+ } else if (this.options$.apiKey) {
760
+ security$ = { apiKey: this.options$.apiKey };
761
+ } else {
762
+ security$ = {};
763
+ }
764
+ const securitySettings$ = this.resolveGlobalSecurity(security$);
765
+
766
+ const response = await this.fetch$(
767
+ {
768
+ security: securitySettings$,
769
+ method: "PATCH",
770
+ path: path$,
771
+ headers: headers$,
772
+ body: body$,
773
+ },
774
+ options,
775
+ );
776
+
777
+ const responseFields$ = {
778
+ ContentType:
779
+ response.headers.get("content-type") ?? "application/octet-stream",
780
+ StatusCode: response.status,
781
+ RawResponse: response,
782
+ };
783
+
784
+ if (this.matchResponse(response, 200, "application/json")) {
785
+ const responseBody = await response.json();
786
+ const result = operations.UpdateAgentResponse$.inboundSchema.parse({
787
+ ...responseFields$,
788
+ Agent: responseBody,
789
+ });
790
+ return result;
791
+ } else if (this.matchResponse(response, 400, "application/json")) {
792
+ const responseBody = await response.json();
793
+ const result = errors.UpdateAgentResponseBody$.inboundSchema.parse({
794
+ ...responseFields$,
795
+ ...responseBody,
796
+ });
797
+ throw result;
798
+ } else if (this.matchResponse(response, 401, "application/json")) {
799
+ const responseBody = await response.json();
800
+ const result =
801
+ errors.UpdateAgentResponseResponseBody$.inboundSchema.parse({
802
+ ...responseFields$,
803
+ ...responseBody,
804
+ });
805
+ throw result;
806
+ } else if (this.matchResponse(response, 422, "application/json")) {
807
+ const responseBody = await response.json();
808
+ const result =
809
+ errors.UpdateAgentResponse422ResponseBody$.inboundSchema.parse({
810
+ ...responseFields$,
811
+ ...responseBody,
812
+ });
813
+ throw result;
814
+ } else if (this.matchResponse(response, 500, "application/json")) {
815
+ const responseBody = await response.json();
816
+ const result =
817
+ errors.UpdateAgentResponse500ResponseBody$.inboundSchema.parse({
818
+ ...responseFields$,
819
+ ...responseBody,
820
+ });
821
+ throw result;
822
+ } else {
823
+ const responseBody = await response.text();
824
+ throw new errors.SDKError(
825
+ "Unexpected API response",
826
+ response,
827
+ responseBody,
828
+ );
1190
829
  }
830
+ }
1191
831
  }