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.
- package/example.js +61 -7
- package/example.js.map +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/sdks.d.ts.map +1 -1
- package/lib/sdks.js.map +1 -1
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js +5 -1
- package/lib/security.js.map +1 -1
- package/models/components/agent.d.ts +62 -0
- package/models/components/agent.d.ts.map +1 -1
- package/models/components/agent.js +95 -15
- package/models/components/agent.js.map +1 -1
- package/models/components/agentpromptparams.d.ts.map +1 -1
- package/models/components/agentpromptparams.js.map +1 -1
- package/models/components/calldetail.d.ts.map +1 -1
- package/models/components/calldetail.js +18 -6
- package/models/components/calldetail.js.map +1 -1
- package/models/components/callphonenumber.d.ts.map +1 -1
- package/models/components/callphonenumber.js.map +1 -1
- package/models/components/phonenumber.d.ts.map +1 -1
- package/models/components/phonenumber.js.map +1 -1
- package/models/components/security.d.ts.map +1 -1
- package/models/errors/createagent.d.ts.map +1 -1
- package/models/errors/createagent.js +36 -12
- package/models/errors/createagent.js.map +1 -1
- package/models/errors/createphonecall.d.ts.map +1 -1
- package/models/errors/createphonecall.js +54 -18
- package/models/errors/createphonecall.js.map +1 -1
- package/models/errors/createphonenumber.d.ts.map +1 -1
- package/models/errors/createphonenumber.js +42 -14
- package/models/errors/createphonenumber.js.map +1 -1
- package/models/errors/deleteagent.d.ts.map +1 -1
- package/models/errors/deleteagent.js +36 -12
- package/models/errors/deleteagent.js.map +1 -1
- package/models/errors/deletephonenumber.d.ts.map +1 -1
- package/models/errors/deletephonenumber.js +33 -11
- package/models/errors/deletephonenumber.js.map +1 -1
- package/models/errors/getagent.d.ts.map +1 -1
- package/models/errors/getagent.js +36 -12
- package/models/errors/getagent.js.map +1 -1
- package/models/errors/getcall.d.ts.map +1 -1
- package/models/errors/getcall.js +30 -10
- package/models/errors/getcall.js.map +1 -1
- package/models/errors/getphonenumber.d.ts.map +1 -1
- package/models/errors/getphonenumber.js +36 -12
- package/models/errors/getphonenumber.js.map +1 -1
- package/models/errors/listagents.d.ts.map +1 -1
- package/models/errors/listagents.js +15 -5
- package/models/errors/listagents.js.map +1 -1
- package/models/errors/listcalls.d.ts.map +1 -1
- package/models/errors/listcalls.js +24 -8
- package/models/errors/listcalls.js.map +1 -1
- package/models/errors/listphonenumbers.d.ts.map +1 -1
- package/models/errors/listphonenumbers.js +27 -9
- package/models/errors/listphonenumbers.js.map +1 -1
- package/models/errors/updateagent.d.ts.map +1 -1
- package/models/errors/updateagent.js +36 -12
- package/models/errors/updateagent.js.map +1 -1
- package/models/errors/updatephoneagent.d.ts.map +1 -1
- package/models/errors/updatephoneagent.js +36 -12
- package/models/errors/updatephoneagent.js.map +1 -1
- package/models/operations/createagent.d.ts +7 -0
- package/models/operations/createagent.d.ts.map +1 -1
- package/models/operations/createagent.js +18 -4
- package/models/operations/createagent.js.map +1 -1
- package/models/operations/createphonecall.d.ts.map +1 -1
- package/models/operations/createphonecall.js +18 -6
- package/models/operations/createphonecall.js.map +1 -1
- package/models/operations/createphonenumber.d.ts.map +1 -1
- package/models/operations/createphonenumber.js +6 -2
- package/models/operations/createphonenumber.js.map +1 -1
- package/models/operations/createwebcall.d.ts.map +1 -1
- package/models/operations/deleteagent.d.ts.map +1 -1
- package/models/operations/deleteagent.js.map +1 -1
- package/models/operations/deletephonenumber.d.ts.map +1 -1
- package/models/operations/deletephonenumber.js.map +1 -1
- package/models/operations/getagent.d.ts.map +1 -1
- package/models/operations/getagent.js.map +1 -1
- package/models/operations/getcall.d.ts.map +1 -1
- package/models/operations/getcall.js.map +1 -1
- package/models/operations/getphonenumber.d.ts.map +1 -1
- package/models/operations/getphonenumber.js +6 -2
- package/models/operations/getphonenumber.js.map +1 -1
- package/models/operations/listagents.d.ts.map +1 -1
- package/models/operations/listagents.js.map +1 -1
- package/models/operations/listcalls.d.ts.map +1 -1
- package/models/operations/listcalls.js +6 -2
- package/models/operations/listcalls.js.map +1 -1
- package/models/operations/listphonenumbers.d.ts.map +1 -1
- package/models/operations/listphonenumbers.js +6 -2
- package/models/operations/listphonenumbers.js.map +1 -1
- package/models/operations/updateagent.d.ts +7 -0
- package/models/operations/updateagent.d.ts.map +1 -1
- package/models/operations/updateagent.js +22 -4
- package/models/operations/updateagent.js.map +1 -1
- package/models/operations/updatephoneagent.d.ts.map +1 -1
- package/models/operations/updatephoneagent.js +6 -2
- package/models/operations/updatephoneagent.js.map +1 -1
- package/package.json +1 -1
- package/sdk/liveClient.d.ts.map +1 -1
- package/sdk/liveClient.js +7 -2
- package/sdk/liveClient.js.map +1 -1
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +22 -5
- package/sdk/sdk.js.map +1 -1
- package/src/example.ts +122 -65
- package/src/lib/config.ts +32 -32
- package/src/lib/sdks.ts +91 -82
- package/src/lib/security.ts +133 -118
- package/src/models/components/agent.ts +482 -303
- package/src/models/components/agentpromptparams.ts +46 -38
- package/src/models/components/calldetail.ts +137 -125
- package/src/models/components/callphonenumber.ts +46 -38
- package/src/models/components/phonenumber.ts +69 -68
- package/src/models/components/security.ts +1 -1
- package/src/models/errors/createagent.ts +359 -311
- package/src/models/errors/createphonecall.ts +537 -472
- package/src/models/errors/createphonenumber.ts +447 -395
- package/src/models/errors/deleteagent.ts +359 -311
- package/src/models/errors/deletephonenumber.ts +357 -315
- package/src/models/errors/getagent.ts +358 -302
- package/src/models/errors/getcall.ts +348 -294
- package/src/models/errors/getphonenumber.ts +357 -312
- package/src/models/errors/listagents.ts +174 -147
- package/src/models/errors/listcalls.ts +251 -211
- package/src/models/errors/listphonenumbers.ts +252 -217
- package/src/models/errors/updateagent.ts +359 -311
- package/src/models/errors/updatephoneagent.ts +357 -312
- package/src/models/operations/createagent.ts +166 -119
- package/src/models/operations/createphonecall.ts +283 -238
- package/src/models/operations/createphonenumber.ts +118 -98
- package/src/models/operations/createwebcall.ts +13 -13
- package/src/models/operations/deleteagent.ts +94 -78
- package/src/models/operations/deletephonenumber.ts +94 -78
- package/src/models/operations/getagent.ts +104 -88
- package/src/models/operations/getcall.ts +101 -88
- package/src/models/operations/getphonenumber.ts +108 -88
- package/src/models/operations/listagents.ts +68 -60
- package/src/models/operations/listcalls.ts +238 -213
- package/src/models/operations/listphonenumbers.ts +72 -60
- package/src/models/operations/updateagent.ts +227 -163
- package/src/models/operations/updatephoneagent.ts +160 -132
- package/src/sdk/liveClient.ts +11 -7
- 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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
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
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
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
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
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
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
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
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
headers
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
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
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
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
|
}
|