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.
- package/example.js +48 -5
- 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 +3 -205
- package/models/components/agent.d.ts.map +1 -1
- package/models/components/agent.js +5 -187
- 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 +33 -22
- package/models/components/calldetail.d.ts.map +1 -1
- package/models/components/calldetail.js +44 -31
- 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/index.d.ts +0 -3
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +0 -3
- package/models/components/index.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/index.d.ts +1 -6
- package/models/errors/index.d.ts.map +1 -1
- package/models/errors/index.js +1 -6
- package/models/errors/index.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/registercall.d.ts +218 -0
- package/models/errors/registercall.d.ts.map +1 -0
- package/models/errors/registercall.js +386 -0
- package/models/errors/registercall.js.map +1 -0
- 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 +3 -16
- package/models/operations/createagent.d.ts.map +1 -1
- package/models/operations/createagent.js +4 -12
- 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 +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/index.d.ts +1 -7
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +1 -7
- package/models/operations/index.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 +1 -7
- package/models/operations/listcalls.d.ts.map +1 -1
- package/models/operations/listcalls.js +6 -6
- 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/registercall.d.ts +74 -0
- package/models/operations/registercall.d.ts.map +1 -0
- package/models/operations/registercall.js +104 -0
- package/models/operations/registercall.js.map +1 -0
- package/models/operations/updateagent.d.ts +3 -16
- package/models/operations/updateagent.d.ts.map +1 -1
- package/models/operations/updateagent.js +9 -13
- 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/audioWsClient.d.ts +10 -0
- package/sdk/audioWsClient.d.ts.map +1 -0
- package/sdk/audioWsClient.js +60 -0
- package/sdk/audioWsClient.js.map +1 -0
- package/sdk/index.d.ts +1 -1
- package/sdk/index.d.ts.map +1 -1
- package/sdk/index.js +1 -1
- package/sdk/index.js.map +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 +1 -23
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +21 -430
- package/sdk/sdk.js.map +1 -1
- package/src/example.ts +136 -88
- 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 +71 -451
- package/src/models/components/calldetail.ts +147 -130
- package/src/models/components/index.ts +0 -3
- package/src/models/components/security.ts +1 -1
- package/src/models/errors/createagent.ts +359 -311
- package/src/models/errors/deleteagent.ts +359 -311
- package/src/models/errors/getagent.ts +358 -302
- package/src/models/errors/getcall.ts +348 -294
- package/src/models/errors/index.ts +1 -6
- package/src/models/errors/listagents.ts +174 -147
- package/src/models/errors/listcalls.ts +251 -211
- package/src/models/errors/registercall.ts +662 -0
- package/src/models/errors/updateagent.ts +359 -311
- package/src/models/operations/createagent.ts +124 -130
- package/src/models/operations/deleteagent.ts +94 -78
- package/src/models/operations/getagent.ts +104 -88
- package/src/models/operations/getcall.ts +101 -88
- package/src/models/operations/index.ts +1 -7
- package/src/models/operations/listagents.ts +68 -60
- package/src/models/operations/listcalls.ts +228 -213
- package/src/models/operations/registercall.ts +167 -0
- package/src/models/operations/updateagent.ts +180 -174
- package/src/sdk/audioWsClient.ts +63 -0
- package/src/sdk/index.ts +1 -1
- package/src/sdk/sdk.ts +802 -1162
- package/src/models/components/agentpromptparams.ts +0 -53
- package/src/models/components/callphonenumber.ts +0 -56
- package/src/models/components/phonenumber.ts +0 -83
- package/src/models/errors/createphonecall.ts +0 -597
- package/src/models/errors/createphonenumber.ts +0 -500
- package/src/models/errors/deletephonenumber.ts +0 -400
- package/src/models/errors/getphonenumber.ts +0 -397
- package/src/models/errors/listphonenumbers.ts +0 -297
- package/src/models/errors/updatephoneagent.ts +0 -397
- package/src/models/operations/createphonecall.ts +0 -308
- package/src/models/operations/createphonenumber.ts +0 -124
- package/src/models/operations/createwebcall.ts +0 -16
- package/src/models/operations/deletephonenumber.ts +0 -103
- package/src/models/operations/getphonenumber.ts +0 -114
- package/src/models/operations/listphonenumbers.ts +0 -76
- package/src/models/operations/updatephoneagent.ts +0 -159
- 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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
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
|
-
...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
|
-
|
|
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$);
|
|
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
|
-
|
|
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
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
-
|
|
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
|
-
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
|
-
|
|
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
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
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
|
-
|
|
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
|
-
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
|
-
|
|
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
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
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
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
headers
|
|
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
|
-
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
|
-
|
|
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
|
-
|
|
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
|
}
|