@servicetitan/titan-chatbot-api 4.4.4 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,14 +8,23 @@
8
8
  /* eslint-disable */
9
9
  // ReSharper disable InconsistentNaming
10
10
 
11
+ import axios, {
12
+ AxiosError,
13
+ AxiosInstance,
14
+ AxiosRequestConfig,
15
+ AxiosResponse,
16
+ CancelToken,
17
+ } from 'axios';
18
+
11
19
  export class Client {
12
- private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
13
- private baseUrl: string;
20
+ protected instance: AxiosInstance;
21
+ protected baseUrl: string;
14
22
  protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
15
23
 
16
- constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
17
- this.http = http ? http : window as any;
18
- this.baseUrl = baseUrl ?? "";
24
+ constructor(baseUrl?: string, instance?: AxiosInstance) {
25
+ this.instance = instance || axios.create();
26
+
27
+ this.baseUrl = baseUrl ?? '';
19
28
  }
20
29
 
21
30
  /**
@@ -23,45 +32,71 @@ export class Client {
23
32
  * @param body (optional)
24
33
  * @return Success
25
34
  */
26
- feedback(version: string, x_Client_ID: any | undefined, body: Feedback | undefined, signal?: AbortSignal): Promise<Feedback> {
27
- let url_ = this.baseUrl + "/api/v{version}/feedback";
35
+ feedback(
36
+ version: string,
37
+ x_Client_ID: any | undefined,
38
+ body: Feedback | undefined,
39
+ signal?: AbortSignal
40
+ ): Promise<Feedback> {
41
+ let url_ = this.baseUrl + '/api/v{version}/feedback';
28
42
  if (version === undefined || version === null)
29
43
  throw new Error("The parameter 'version' must be defined.");
30
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
31
- url_ = url_.replace(/[?&]$/, "");
44
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
45
+ url_ = url_.replace(/[?&]$/, '');
32
46
 
33
47
  const content_ = JSON.stringify(body);
34
48
 
35
- let options_: RequestInit = {
36
- body: content_,
37
- method: "POST",
38
- signal,
49
+ let options_: AxiosRequestConfig = {
50
+ data: content_,
51
+ method: 'POST',
52
+ url: url_,
39
53
  headers: {
40
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
41
- "Content-Type": "application/json",
42
- "Accept": "text/plain"
43
- }
54
+ 'X-Client-ID':
55
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
56
+ 'Content-Type': 'application/json',
57
+ 'Accept': 'text/plain',
58
+ },
59
+ signal,
44
60
  };
45
61
 
46
- return this.http.fetch(url_, options_).then((_response: Response) => {
47
- return this.processFeedback(_response);
48
- });
62
+ return this.instance
63
+ .request(options_)
64
+ .catch((_error: any) => {
65
+ if (isAxiosError(_error) && _error.response) {
66
+ return _error.response;
67
+ } else {
68
+ throw _error;
69
+ }
70
+ })
71
+ .then((_response: AxiosResponse) => {
72
+ return this.processFeedback(_response);
73
+ });
49
74
  }
50
75
 
51
- protected processFeedback(response: Response): Promise<Feedback> {
76
+ protected processFeedback(response: AxiosResponse): Promise<Feedback> {
52
77
  const status = response.status;
53
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
78
+ let _headers: any = {};
79
+ if (response.headers && typeof response.headers === 'object') {
80
+ for (const k in response.headers) {
81
+ if (response.headers.hasOwnProperty(k)) {
82
+ _headers[k] = response.headers[k];
83
+ }
84
+ }
85
+ }
54
86
  if (status === 200) {
55
- return response.text().then((_responseText) => {
56
- let result200: any = null;
57
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
58
- result200 = Feedback.fromJS(resultData200);
59
- return result200;
60
- });
87
+ const _responseText = response.data;
88
+ let result200: any = null;
89
+ let resultData200 = _responseText;
90
+ result200 = Feedback.fromJS(resultData200);
91
+ return Promise.resolve<Feedback>(result200);
61
92
  } else if (status !== 200 && status !== 204) {
62
- return response.text().then((_responseText) => {
63
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
64
- });
93
+ const _responseText = response.data;
94
+ return throwException(
95
+ 'An unexpected server error occurred.',
96
+ status,
97
+ _responseText,
98
+ _headers
99
+ );
65
100
  }
66
101
  return Promise.resolve<Feedback>(null as any);
67
102
  }
@@ -71,100 +106,231 @@ export class Client {
71
106
  * @param body (optional)
72
107
  * @return Success
73
108
  */
74
- message(version: string, x_Client_ID: any | undefined, body: UserMessage | undefined, signal?: AbortSignal): Promise<BotMessage> {
75
- let url_ = this.baseUrl + "/api/v{version}/message";
109
+ followUpEmail(
110
+ version: string,
111
+ x_Client_ID: any | undefined,
112
+ body: UserMessage | undefined,
113
+ signal?: AbortSignal
114
+ ): Promise<BotMessage> {
115
+ let url_ = this.baseUrl + '/api/v{version}/follow-up-email';
76
116
  if (version === undefined || version === null)
77
117
  throw new Error("The parameter 'version' must be defined.");
78
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
79
- url_ = url_.replace(/[?&]$/, "");
118
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
119
+ url_ = url_.replace(/[?&]$/, '');
80
120
 
81
121
  const content_ = JSON.stringify(body);
82
122
 
83
- let options_: RequestInit = {
84
- body: content_,
85
- method: "POST",
86
- signal,
123
+ let options_: AxiosRequestConfig = {
124
+ data: content_,
125
+ method: 'POST',
126
+ url: url_,
87
127
  headers: {
88
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
89
- "Content-Type": "application/json",
90
- "Accept": "text/plain"
91
- }
128
+ 'X-Client-ID':
129
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
130
+ 'Content-Type': 'application/json',
131
+ 'Accept': 'text/plain',
132
+ },
133
+ signal,
92
134
  };
93
135
 
94
- return this.http.fetch(url_, options_).then((_response: Response) => {
95
- return this.processMessage(_response);
96
- });
136
+ return this.instance
137
+ .request(options_)
138
+ .catch((_error: any) => {
139
+ if (isAxiosError(_error) && _error.response) {
140
+ return _error.response;
141
+ } else {
142
+ throw _error;
143
+ }
144
+ })
145
+ .then((_response: AxiosResponse) => {
146
+ return this.processFollowUpEmail(_response);
147
+ });
97
148
  }
98
149
 
99
- protected processMessage(response: Response): Promise<BotMessage> {
150
+ protected processFollowUpEmail(response: AxiosResponse): Promise<BotMessage> {
100
151
  const status = response.status;
101
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
152
+ let _headers: any = {};
153
+ if (response.headers && typeof response.headers === 'object') {
154
+ for (const k in response.headers) {
155
+ if (response.headers.hasOwnProperty(k)) {
156
+ _headers[k] = response.headers[k];
157
+ }
158
+ }
159
+ }
102
160
  if (status === 200) {
103
- return response.text().then((_responseText) => {
104
- let result200: any = null;
105
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
106
- result200 = BotMessage.fromJS(resultData200);
107
- return result200;
108
- });
161
+ const _responseText = response.data;
162
+ let result200: any = null;
163
+ let resultData200 = _responseText;
164
+ result200 = BotMessage.fromJS(resultData200);
165
+ return Promise.resolve<BotMessage>(result200);
109
166
  } else if (status === 500) {
110
- return response.text().then((_responseText) => {
111
- return throwException("Server Error", status, _responseText, _headers);
112
- });
167
+ const _responseText = response.data;
168
+ return throwException('Server Error', status, _responseText, _headers);
113
169
  } else if (status === 502) {
114
- return response.text().then((_responseText) => {
115
- return throwException("Server Error", status, _responseText, _headers);
116
- });
170
+ const _responseText = response.data;
171
+ return throwException('Server Error', status, _responseText, _headers);
117
172
  } else if (status === 504) {
118
- return response.text().then((_responseText) => {
119
- return throwException("Server Error", status, _responseText, _headers);
120
- });
173
+ const _responseText = response.data;
174
+ return throwException('Server Error', status, _responseText, _headers);
121
175
  } else if (status !== 200 && status !== 204) {
122
- return response.text().then((_responseText) => {
123
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
124
- });
176
+ const _responseText = response.data;
177
+ return throwException(
178
+ 'An unexpected server error occurred.',
179
+ status,
180
+ _responseText,
181
+ _headers
182
+ );
125
183
  }
126
184
  return Promise.resolve<BotMessage>(null as any);
127
185
  }
128
186
 
129
187
  /**
130
188
  * @param x_Client_ID (optional)
189
+ * @param body (optional)
131
190
  * @return Success
132
191
  */
133
- options(version: string, x_Client_ID: any | undefined, signal?: AbortSignal): Promise<FrontendModel> {
134
- let url_ = this.baseUrl + "/api/v{version}/options";
192
+ message(
193
+ version: string,
194
+ x_Client_ID: any | undefined,
195
+ body: UserMessage | undefined,
196
+ signal?: AbortSignal
197
+ ): Promise<BotMessage> {
198
+ let url_ = this.baseUrl + '/api/v{version}/message';
135
199
  if (version === undefined || version === null)
136
200
  throw new Error("The parameter 'version' must be defined.");
137
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
138
- url_ = url_.replace(/[?&]$/, "");
201
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
202
+ url_ = url_.replace(/[?&]$/, '');
139
203
 
140
- let options_: RequestInit = {
141
- method: "GET",
142
- signal,
204
+ const content_ = JSON.stringify(body);
205
+
206
+ let options_: AxiosRequestConfig = {
207
+ data: content_,
208
+ method: 'POST',
209
+ url: url_,
143
210
  headers: {
144
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
145
- "Accept": "text/plain"
146
- }
211
+ 'X-Client-ID':
212
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
213
+ 'Content-Type': 'application/json',
214
+ 'Accept': 'text/plain',
215
+ },
216
+ signal,
147
217
  };
148
218
 
149
- return this.http.fetch(url_, options_).then((_response: Response) => {
150
- return this.processOptions(_response);
151
- });
219
+ return this.instance
220
+ .request(options_)
221
+ .catch((_error: any) => {
222
+ if (isAxiosError(_error) && _error.response) {
223
+ return _error.response;
224
+ } else {
225
+ throw _error;
226
+ }
227
+ })
228
+ .then((_response: AxiosResponse) => {
229
+ return this.processMessage(_response);
230
+ });
152
231
  }
153
232
 
154
- protected processOptions(response: Response): Promise<FrontendModel> {
233
+ protected processMessage(response: AxiosResponse): Promise<BotMessage> {
155
234
  const status = response.status;
156
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
235
+ let _headers: any = {};
236
+ if (response.headers && typeof response.headers === 'object') {
237
+ for (const k in response.headers) {
238
+ if (response.headers.hasOwnProperty(k)) {
239
+ _headers[k] = response.headers[k];
240
+ }
241
+ }
242
+ }
157
243
  if (status === 200) {
158
- return response.text().then((_responseText) => {
159
- let result200: any = null;
160
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
161
- result200 = FrontendModel.fromJS(resultData200);
162
- return result200;
163
- });
244
+ const _responseText = response.data;
245
+ let result200: any = null;
246
+ let resultData200 = _responseText;
247
+ result200 = BotMessage.fromJS(resultData200);
248
+ return Promise.resolve<BotMessage>(result200);
249
+ } else if (status === 500) {
250
+ const _responseText = response.data;
251
+ return throwException('Server Error', status, _responseText, _headers);
252
+ } else if (status === 502) {
253
+ const _responseText = response.data;
254
+ return throwException('Server Error', status, _responseText, _headers);
255
+ } else if (status === 504) {
256
+ const _responseText = response.data;
257
+ return throwException('Server Error', status, _responseText, _headers);
164
258
  } else if (status !== 200 && status !== 204) {
165
- return response.text().then((_responseText) => {
166
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
259
+ const _responseText = response.data;
260
+ return throwException(
261
+ 'An unexpected server error occurred.',
262
+ status,
263
+ _responseText,
264
+ _headers
265
+ );
266
+ }
267
+ return Promise.resolve<BotMessage>(null as any);
268
+ }
269
+
270
+ /**
271
+ * @param x_Client_ID (optional)
272
+ * @return Success
273
+ */
274
+ options(
275
+ version: string,
276
+ x_Client_ID: any | undefined,
277
+ signal?: AbortSignal
278
+ ): Promise<FrontendModel> {
279
+ let url_ = this.baseUrl + '/api/v{version}/options';
280
+ if (version === undefined || version === null)
281
+ throw new Error("The parameter 'version' must be defined.");
282
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
283
+ url_ = url_.replace(/[?&]$/, '');
284
+
285
+ let options_: AxiosRequestConfig = {
286
+ method: 'GET',
287
+ url: url_,
288
+ headers: {
289
+ 'X-Client-ID':
290
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
291
+ 'Accept': 'text/plain',
292
+ },
293
+ signal,
294
+ };
295
+
296
+ return this.instance
297
+ .request(options_)
298
+ .catch((_error: any) => {
299
+ if (isAxiosError(_error) && _error.response) {
300
+ return _error.response;
301
+ } else {
302
+ throw _error;
303
+ }
304
+ })
305
+ .then((_response: AxiosResponse) => {
306
+ return this.processOptions(_response);
167
307
  });
308
+ }
309
+
310
+ protected processOptions(response: AxiosResponse): Promise<FrontendModel> {
311
+ const status = response.status;
312
+ let _headers: any = {};
313
+ if (response.headers && typeof response.headers === 'object') {
314
+ for (const k in response.headers) {
315
+ if (response.headers.hasOwnProperty(k)) {
316
+ _headers[k] = response.headers[k];
317
+ }
318
+ }
319
+ }
320
+ if (status === 200) {
321
+ const _responseText = response.data;
322
+ let result200: any = null;
323
+ let resultData200 = _responseText;
324
+ result200 = FrontendModel.fromJS(resultData200);
325
+ return Promise.resolve<FrontendModel>(result200);
326
+ } else if (status !== 200 && status !== 204) {
327
+ const _responseText = response.data;
328
+ return throwException(
329
+ 'An unexpected server error occurred.',
330
+ status,
331
+ _responseText,
332
+ _headers
333
+ );
168
334
  }
169
335
  return Promise.resolve<FrontendModel>(null as any);
170
336
  }
@@ -174,45 +340,71 @@ export class Client {
174
340
  * @param body (optional)
175
341
  * @return Success
176
342
  */
177
- sessionPOST(version: string, x_Client_ID: any | undefined, body: Session | undefined, signal?: AbortSignal): Promise<Session> {
178
- let url_ = this.baseUrl + "/api/v{version}/session";
343
+ sessionPOST(
344
+ version: string,
345
+ x_Client_ID: any | undefined,
346
+ body: Session | undefined,
347
+ signal?: AbortSignal
348
+ ): Promise<Session> {
349
+ let url_ = this.baseUrl + '/api/v{version}/session';
179
350
  if (version === undefined || version === null)
180
351
  throw new Error("The parameter 'version' must be defined.");
181
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
182
- url_ = url_.replace(/[?&]$/, "");
352
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
353
+ url_ = url_.replace(/[?&]$/, '');
183
354
 
184
355
  const content_ = JSON.stringify(body);
185
356
 
186
- let options_: RequestInit = {
187
- body: content_,
188
- method: "POST",
189
- signal,
357
+ let options_: AxiosRequestConfig = {
358
+ data: content_,
359
+ method: 'POST',
360
+ url: url_,
190
361
  headers: {
191
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
192
- "Content-Type": "application/json",
193
- "Accept": "text/plain"
194
- }
362
+ 'X-Client-ID':
363
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
364
+ 'Content-Type': 'application/json',
365
+ 'Accept': 'text/plain',
366
+ },
367
+ signal,
195
368
  };
196
369
 
197
- return this.http.fetch(url_, options_).then((_response: Response) => {
198
- return this.processSessionPOST(_response);
199
- });
370
+ return this.instance
371
+ .request(options_)
372
+ .catch((_error: any) => {
373
+ if (isAxiosError(_error) && _error.response) {
374
+ return _error.response;
375
+ } else {
376
+ throw _error;
377
+ }
378
+ })
379
+ .then((_response: AxiosResponse) => {
380
+ return this.processSessionPOST(_response);
381
+ });
200
382
  }
201
383
 
202
- protected processSessionPOST(response: Response): Promise<Session> {
384
+ protected processSessionPOST(response: AxiosResponse): Promise<Session> {
203
385
  const status = response.status;
204
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
386
+ let _headers: any = {};
387
+ if (response.headers && typeof response.headers === 'object') {
388
+ for (const k in response.headers) {
389
+ if (response.headers.hasOwnProperty(k)) {
390
+ _headers[k] = response.headers[k];
391
+ }
392
+ }
393
+ }
205
394
  if (status === 200) {
206
- return response.text().then((_responseText) => {
207
- let result200: any = null;
208
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
209
- result200 = Session.fromJS(resultData200);
210
- return result200;
211
- });
395
+ const _responseText = response.data;
396
+ let result200: any = null;
397
+ let resultData200 = _responseText;
398
+ result200 = Session.fromJS(resultData200);
399
+ return Promise.resolve<Session>(result200);
212
400
  } else if (status !== 200 && status !== 204) {
213
- return response.text().then((_responseText) => {
214
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
215
- });
401
+ const _responseText = response.data;
402
+ return throwException(
403
+ 'An unexpected server error occurred.',
404
+ status,
405
+ _responseText,
406
+ _headers
407
+ );
216
408
  }
217
409
  return Promise.resolve<Session>(null as any);
218
410
  }
@@ -222,45 +414,71 @@ export class Client {
222
414
  * @param body (optional)
223
415
  * @return Success
224
416
  */
225
- sessionPATCH(version: string, x_Client_ID: any | undefined, body: Session | undefined, signal?: AbortSignal): Promise<Session> {
226
- let url_ = this.baseUrl + "/api/v{version}/session";
417
+ sessionPATCH(
418
+ version: string,
419
+ x_Client_ID: any | undefined,
420
+ body: Session | undefined,
421
+ signal?: AbortSignal
422
+ ): Promise<Session> {
423
+ let url_ = this.baseUrl + '/api/v{version}/session';
227
424
  if (version === undefined || version === null)
228
425
  throw new Error("The parameter 'version' must be defined.");
229
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
230
- url_ = url_.replace(/[?&]$/, "");
426
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
427
+ url_ = url_.replace(/[?&]$/, '');
231
428
 
232
429
  const content_ = JSON.stringify(body);
233
430
 
234
- let options_: RequestInit = {
235
- body: content_,
236
- method: "PATCH",
237
- signal,
431
+ let options_: AxiosRequestConfig = {
432
+ data: content_,
433
+ method: 'PATCH',
434
+ url: url_,
238
435
  headers: {
239
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
240
- "Content-Type": "application/json",
241
- "Accept": "text/plain"
242
- }
436
+ 'X-Client-ID':
437
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
438
+ 'Content-Type': 'application/json',
439
+ 'Accept': 'text/plain',
440
+ },
441
+ signal,
243
442
  };
244
443
 
245
- return this.http.fetch(url_, options_).then((_response: Response) => {
246
- return this.processSessionPATCH(_response);
247
- });
444
+ return this.instance
445
+ .request(options_)
446
+ .catch((_error: any) => {
447
+ if (isAxiosError(_error) && _error.response) {
448
+ return _error.response;
449
+ } else {
450
+ throw _error;
451
+ }
452
+ })
453
+ .then((_response: AxiosResponse) => {
454
+ return this.processSessionPATCH(_response);
455
+ });
248
456
  }
249
457
 
250
- protected processSessionPATCH(response: Response): Promise<Session> {
458
+ protected processSessionPATCH(response: AxiosResponse): Promise<Session> {
251
459
  const status = response.status;
252
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
460
+ let _headers: any = {};
461
+ if (response.headers && typeof response.headers === 'object') {
462
+ for (const k in response.headers) {
463
+ if (response.headers.hasOwnProperty(k)) {
464
+ _headers[k] = response.headers[k];
465
+ }
466
+ }
467
+ }
253
468
  if (status === 200) {
254
- return response.text().then((_responseText) => {
255
- let result200: any = null;
256
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
257
- result200 = Session.fromJS(resultData200);
258
- return result200;
259
- });
469
+ const _responseText = response.data;
470
+ let result200: any = null;
471
+ let resultData200 = _responseText;
472
+ result200 = Session.fromJS(resultData200);
473
+ return Promise.resolve<Session>(result200);
260
474
  } else if (status !== 200 && status !== 204) {
261
- return response.text().then((_responseText) => {
262
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
263
- });
475
+ const _responseText = response.data;
476
+ return throwException(
477
+ 'An unexpected server error occurred.',
478
+ status,
479
+ _responseText,
480
+ _headers
481
+ );
264
482
  }
265
483
  return Promise.resolve<Session>(null as any);
266
484
  }
@@ -270,45 +488,71 @@ export class Client {
270
488
  * @param body (optional)
271
489
  * @return Success
272
490
  */
273
- sessionDELETE(version: string, x_Client_ID: any | undefined, body: Session | undefined, signal?: AbortSignal): Promise<Session> {
274
- let url_ = this.baseUrl + "/api/v{version}/session";
491
+ sessionDELETE(
492
+ version: string,
493
+ x_Client_ID: any | undefined,
494
+ body: Session | undefined,
495
+ signal?: AbortSignal
496
+ ): Promise<Session> {
497
+ let url_ = this.baseUrl + '/api/v{version}/session';
275
498
  if (version === undefined || version === null)
276
499
  throw new Error("The parameter 'version' must be defined.");
277
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
278
- url_ = url_.replace(/[?&]$/, "");
500
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
501
+ url_ = url_.replace(/[?&]$/, '');
279
502
 
280
503
  const content_ = JSON.stringify(body);
281
504
 
282
- let options_: RequestInit = {
283
- body: content_,
284
- method: "DELETE",
285
- signal,
505
+ let options_: AxiosRequestConfig = {
506
+ data: content_,
507
+ method: 'DELETE',
508
+ url: url_,
286
509
  headers: {
287
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
288
- "Content-Type": "application/json",
289
- "Accept": "text/plain"
290
- }
510
+ 'X-Client-ID':
511
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
512
+ 'Content-Type': 'application/json',
513
+ 'Accept': 'text/plain',
514
+ },
515
+ signal,
291
516
  };
292
517
 
293
- return this.http.fetch(url_, options_).then((_response: Response) => {
294
- return this.processSessionDELETE(_response);
295
- });
518
+ return this.instance
519
+ .request(options_)
520
+ .catch((_error: any) => {
521
+ if (isAxiosError(_error) && _error.response) {
522
+ return _error.response;
523
+ } else {
524
+ throw _error;
525
+ }
526
+ })
527
+ .then((_response: AxiosResponse) => {
528
+ return this.processSessionDELETE(_response);
529
+ });
296
530
  }
297
531
 
298
- protected processSessionDELETE(response: Response): Promise<Session> {
532
+ protected processSessionDELETE(response: AxiosResponse): Promise<Session> {
299
533
  const status = response.status;
300
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
534
+ let _headers: any = {};
535
+ if (response.headers && typeof response.headers === 'object') {
536
+ for (const k in response.headers) {
537
+ if (response.headers.hasOwnProperty(k)) {
538
+ _headers[k] = response.headers[k];
539
+ }
540
+ }
541
+ }
301
542
  if (status === 200) {
302
- return response.text().then((_responseText) => {
303
- let result200: any = null;
304
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
305
- result200 = Session.fromJS(resultData200);
306
- return result200;
307
- });
543
+ const _responseText = response.data;
544
+ let result200: any = null;
545
+ let resultData200 = _responseText;
546
+ result200 = Session.fromJS(resultData200);
547
+ return Promise.resolve<Session>(result200);
308
548
  } else if (status !== 200 && status !== 204) {
309
- return response.text().then((_responseText) => {
310
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
311
- });
549
+ const _responseText = response.data;
550
+ return throwException(
551
+ 'An unexpected server error occurred.',
552
+ status,
553
+ _responseText,
554
+ _headers
555
+ );
312
556
  }
313
557
  return Promise.resolve<Session>(null as any);
314
558
  }
@@ -319,56 +563,79 @@ export class Client {
319
563
  * @param x_Client_ID (optional)
320
564
  * @return Success
321
565
  */
322
- transcripts(start: Date | undefined, end: Date | undefined, version: string, x_Client_ID: any | undefined, signal?: AbortSignal): Promise<ExportHistoryMessage[]> {
323
- let url_ = this.baseUrl + "/api/v{version}/transcripts?";
566
+ transcripts(
567
+ start: Date | undefined,
568
+ end: Date | undefined,
569
+ version: string,
570
+ x_Client_ID: any | undefined,
571
+ signal?: AbortSignal
572
+ ): Promise<ExportHistoryMessage[]> {
573
+ let url_ = this.baseUrl + '/api/v{version}/transcripts?';
324
574
  if (version === undefined || version === null)
325
575
  throw new Error("The parameter 'version' must be defined.");
326
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
327
- if (start === null)
328
- throw new Error("The parameter 'start' cannot be null.");
576
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
577
+ if (start === null) throw new Error("The parameter 'start' cannot be null.");
329
578
  else if (start !== undefined)
330
- url_ += "start=" + encodeURIComponent(start ? "" + start.toISOString() : "") + "&";
331
- if (end === null)
332
- throw new Error("The parameter 'end' cannot be null.");
579
+ url_ += 'start=' + encodeURIComponent(start ? '' + start.toISOString() : '') + '&';
580
+ if (end === null) throw new Error("The parameter 'end' cannot be null.");
333
581
  else if (end !== undefined)
334
- url_ += "end=" + encodeURIComponent(end ? "" + end.toISOString() : "") + "&";
335
- url_ = url_.replace(/[?&]$/, "");
582
+ url_ += 'end=' + encodeURIComponent(end ? '' + end.toISOString() : '') + '&';
583
+ url_ = url_.replace(/[?&]$/, '');
336
584
 
337
- let options_: RequestInit = {
338
- method: "GET",
339
- signal,
585
+ let options_: AxiosRequestConfig = {
586
+ method: 'GET',
587
+ url: url_,
340
588
  headers: {
341
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
342
- "Accept": "text/plain"
343
- }
589
+ 'X-Client-ID':
590
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
591
+ 'Accept': 'text/plain',
592
+ },
593
+ signal,
344
594
  };
345
595
 
346
- return this.http.fetch(url_, options_).then((_response: Response) => {
347
- return this.processTranscripts(_response);
348
- });
596
+ return this.instance
597
+ .request(options_)
598
+ .catch((_error: any) => {
599
+ if (isAxiosError(_error) && _error.response) {
600
+ return _error.response;
601
+ } else {
602
+ throw _error;
603
+ }
604
+ })
605
+ .then((_response: AxiosResponse) => {
606
+ return this.processTranscripts(_response);
607
+ });
349
608
  }
350
609
 
351
- protected processTranscripts(response: Response): Promise<ExportHistoryMessage[]> {
610
+ protected processTranscripts(response: AxiosResponse): Promise<ExportHistoryMessage[]> {
352
611
  const status = response.status;
353
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
354
- if (status === 200) {
355
- return response.text().then((_responseText) => {
356
- let result200: any = null;
357
- let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
358
- if (Array.isArray(resultData200)) {
359
- result200 = [] as any;
360
- for (let item of resultData200)
361
- result200!.push(ExportHistoryMessage.fromJS(item));
612
+ let _headers: any = {};
613
+ if (response.headers && typeof response.headers === 'object') {
614
+ for (const k in response.headers) {
615
+ if (response.headers.hasOwnProperty(k)) {
616
+ _headers[k] = response.headers[k];
362
617
  }
363
- else {
364
- result200 = <any>null;
365
- }
366
- return result200;
367
- });
618
+ }
619
+ }
620
+ if (status === 200) {
621
+ const _responseText = response.data;
622
+ let result200: any = null;
623
+ let resultData200 = _responseText;
624
+ if (Array.isArray(resultData200)) {
625
+ result200 = [] as any;
626
+ for (let item of resultData200) result200!.push(ExportHistoryMessage.fromJS(item));
627
+ } else {
628
+ result200 = <any>null;
629
+ }
630
+ return Promise.resolve<ExportHistoryMessage[]>(result200);
368
631
  } else if (status !== 200 && status !== 204) {
369
- return response.text().then((_responseText) => {
370
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
371
- });
632
+ const _responseText = response.data;
633
+ return throwException(
634
+ 'An unexpected server error occurred.',
635
+ status,
636
+ _responseText,
637
+ _headers
638
+ );
372
639
  }
373
640
  return Promise.resolve<ExportHistoryMessage[]>(null as any);
374
641
  }
@@ -378,46 +645,71 @@ export class Client {
378
645
  * @param x_Client_ID (optional)
379
646
  * @return Success
380
647
  */
381
- summary(sessionId: number | undefined, version: string, x_Client_ID: any | undefined, signal?: AbortSignal): Promise<string> {
382
- let url_ = this.baseUrl + "/api/v{version}/transcripts/summary?";
648
+ summary(
649
+ sessionId: number | undefined,
650
+ version: string,
651
+ x_Client_ID: any | undefined,
652
+ signal?: AbortSignal
653
+ ): Promise<string> {
654
+ let url_ = this.baseUrl + '/api/v{version}/transcripts/summary?';
383
655
  if (version === undefined || version === null)
384
656
  throw new Error("The parameter 'version' must be defined.");
385
- url_ = url_.replace("{version}", encodeURIComponent("" + version));
386
- if (sessionId === null)
387
- throw new Error("The parameter 'sessionId' cannot be null.");
657
+ url_ = url_.replace('{version}', encodeURIComponent('' + version));
658
+ if (sessionId === null) throw new Error("The parameter 'sessionId' cannot be null.");
388
659
  else if (sessionId !== undefined)
389
- url_ += "sessionId=" + encodeURIComponent("" + sessionId) + "&";
390
- url_ = url_.replace(/[?&]$/, "");
660
+ url_ += 'sessionId=' + encodeURIComponent('' + sessionId) + '&';
661
+ url_ = url_.replace(/[?&]$/, '');
391
662
 
392
- let options_: RequestInit = {
393
- method: "GET",
394
- signal,
663
+ let options_: AxiosRequestConfig = {
664
+ method: 'GET',
665
+ url: url_,
395
666
  headers: {
396
- "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
397
- "Accept": "text/plain"
398
- }
667
+ 'X-Client-ID':
668
+ x_Client_ID !== undefined && x_Client_ID !== null ? '' + x_Client_ID : '',
669
+ 'Accept': 'text/plain',
670
+ },
671
+ signal,
399
672
  };
400
673
 
401
- return this.http.fetch(url_, options_).then((_response: Response) => {
402
- return this.processSummary(_response);
403
- });
674
+ return this.instance
675
+ .request(options_)
676
+ .catch((_error: any) => {
677
+ if (isAxiosError(_error) && _error.response) {
678
+ return _error.response;
679
+ } else {
680
+ throw _error;
681
+ }
682
+ })
683
+ .then((_response: AxiosResponse) => {
684
+ return this.processSummary(_response);
685
+ });
404
686
  }
405
687
 
406
- protected processSummary(response: Response): Promise<string> {
688
+ protected processSummary(response: AxiosResponse): Promise<string> {
407
689
  const status = response.status;
408
- let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
690
+ let _headers: any = {};
691
+ if (response.headers && typeof response.headers === 'object') {
692
+ for (const k in response.headers) {
693
+ if (response.headers.hasOwnProperty(k)) {
694
+ _headers[k] = response.headers[k];
695
+ }
696
+ }
697
+ }
409
698
  if (status === 200) {
410
- return response.text().then((_responseText) => {
411
- let result200: any = null;
412
- let resultData200 = _responseText === "" ? null : _responseText;
413
- result200 = resultData200 !== undefined ? resultData200 : <any>null;
699
+ const _responseText = response.data;
700
+ let result200: any = null;
701
+ let resultData200 = _responseText;
702
+ result200 = resultData200 !== undefined ? resultData200 : <any>null;
414
703
 
415
- return result200;
416
- });
704
+ return Promise.resolve<string>(result200);
417
705
  } else if (status !== 200 && status !== 204) {
418
- return response.text().then((_responseText) => {
419
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
420
- });
706
+ const _responseText = response.data;
707
+ return throwException(
708
+ 'An unexpected server error occurred.',
709
+ status,
710
+ _responseText,
711
+ _headers
712
+ );
421
713
  }
422
714
  return Promise.resolve<string>(null as any);
423
715
  }
@@ -449,32 +741,35 @@ export class BotMessage implements IBotMessage {
449
741
  modelVersion?: string | undefined;
450
742
  /** Various metadata for diagnostics purposes. */
451
743
  meta?: any | undefined;
744
+ /** How confident is the chatbot in its response. */
745
+ confidenceScore?: number | undefined;
452
746
 
453
747
  constructor(data?: IBotMessage) {
454
748
  if (data) {
455
749
  for (var property in data) {
456
- if (data.hasOwnProperty(property))
457
- (<any>this)[property] = (<any>data)[property];
750
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
458
751
  }
459
752
  }
460
753
  }
461
754
 
462
755
  init(_data?: any) {
463
756
  if (_data) {
464
- this.id = _data["id"];
465
- this.sessionId = _data["sessionId"];
466
- this.timeStamp = _data["timeStamp"] ? new Date(_data["timeStamp"].toString()) : <any>undefined;
467
- this.answer = _data["answer"];
468
- if (Array.isArray(_data["scoredUrls"])) {
757
+ this.id = _data['id'];
758
+ this.sessionId = _data['sessionId'];
759
+ this.timeStamp = _data['timeStamp']
760
+ ? new Date(_data['timeStamp'].toString())
761
+ : <any>undefined;
762
+ this.answer = _data['answer'];
763
+ if (Array.isArray(_data['scoredUrls'])) {
469
764
  this.scoredUrls = [] as any;
470
- for (let item of _data["scoredUrls"])
471
- this.scoredUrls!.push(ScoredUrl.fromJS(item));
765
+ for (let item of _data['scoredUrls']) this.scoredUrls!.push(ScoredUrl.fromJS(item));
472
766
  }
473
- this.guardFlag = _data["guardFlag"];
474
- this.isGuardrailed = _data["isGuardrailed"];
475
- this.botVersion = _data["botVersion"];
476
- this.modelVersion = _data["modelVersion"];
477
- this.meta = _data["meta"];
767
+ this.guardFlag = _data['guardFlag'];
768
+ this.isGuardrailed = _data['isGuardrailed'];
769
+ this.botVersion = _data['botVersion'];
770
+ this.modelVersion = _data['modelVersion'];
771
+ this.meta = _data['meta'];
772
+ this.confidenceScore = _data['confidenceScore'];
478
773
  }
479
774
  }
480
775
 
@@ -487,20 +782,20 @@ export class BotMessage implements IBotMessage {
487
782
 
488
783
  toJSON(data?: any) {
489
784
  data = typeof data === 'object' ? data : {};
490
- data["id"] = this.id;
491
- data["sessionId"] = this.sessionId;
492
- data["timeStamp"] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
493
- data["answer"] = this.answer;
785
+ data['id'] = this.id;
786
+ data['sessionId'] = this.sessionId;
787
+ data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
788
+ data['answer'] = this.answer;
494
789
  if (Array.isArray(this.scoredUrls)) {
495
- data["scoredUrls"] = [];
496
- for (let item of this.scoredUrls)
497
- data["scoredUrls"].push(item.toJSON());
790
+ data['scoredUrls'] = [];
791
+ for (let item of this.scoredUrls) data['scoredUrls'].push(item.toJSON());
498
792
  }
499
- data["guardFlag"] = this.guardFlag;
500
- data["isGuardrailed"] = this.isGuardrailed;
501
- data["botVersion"] = this.botVersion;
502
- data["modelVersion"] = this.modelVersion;
503
- data["meta"] = this.meta;
793
+ data['guardFlag'] = this.guardFlag;
794
+ data['isGuardrailed'] = this.isGuardrailed;
795
+ data['botVersion'] = this.botVersion;
796
+ data['modelVersion'] = this.modelVersion;
797
+ data['meta'] = this.meta;
798
+ data['confidenceScore'] = this.confidenceScore;
504
799
  return data;
505
800
  }
506
801
  }
@@ -531,6 +826,8 @@ export interface IBotMessage {
531
826
  modelVersion?: string | undefined;
532
827
  /** Various metadata for diagnostics purposes. */
533
828
  meta?: any | undefined;
829
+ /** How confident is the chatbot in its response. */
830
+ confidenceScore?: number | undefined;
534
831
  }
535
832
 
536
833
  export enum Experience {
@@ -563,32 +860,39 @@ export class ExportHistoryMessage implements IExportHistoryMessage {
563
860
  constructor(data?: IExportHistoryMessage) {
564
861
  if (data) {
565
862
  for (var property in data) {
566
- if (data.hasOwnProperty(property))
567
- (<any>this)[property] = (<any>data)[property];
863
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
568
864
  }
569
865
  }
570
866
  }
571
867
 
572
868
  init(_data?: any) {
573
869
  if (_data) {
574
- this.id = _data["id"];
575
- this.sessionId = _data["sessionId"];
576
- this.timeStamp = _data["timeStamp"] ? new Date(_data["timeStamp"].toString()) : <any>undefined;
577
- this.userId = _data["userId"];
578
- this.sessionStartTime = _data["sessionStartTime"] ? new Date(_data["sessionStartTime"].toString()) : <any>undefined;
579
- this.sessionEndTime = _data["sessionEndTime"] ? new Date(_data["sessionEndTime"].toString()) : <any>undefined;
580
- this.userName = _data["userName"];
581
- this.userEmail = _data["userEmail"];
582
- this.question = _data["question"];
583
- this.answer = _data["answer"];
584
- this.messageType = _data["messageType"];
585
- this.salesforceCaseId = _data["salesforceCaseId"];
586
- this.guardFlag = _data["guardFlag"];
587
- this.isGuardrailed = _data["isGuardrailed"];
588
- this.botVersion = _data["botVersion"];
589
- this.metadata = _data["metadata"];
590
- this.feedback = _data["feedback"] ? Feedback.fromJS(_data["feedback"]) : <any>undefined;
591
- this.sessionFeedback = _data["sessionFeedback"] ? Feedback.fromJS(_data["sessionFeedback"]) : <any>undefined;
870
+ this.id = _data['id'];
871
+ this.sessionId = _data['sessionId'];
872
+ this.timeStamp = _data['timeStamp']
873
+ ? new Date(_data['timeStamp'].toString())
874
+ : <any>undefined;
875
+ this.userId = _data['userId'];
876
+ this.sessionStartTime = _data['sessionStartTime']
877
+ ? new Date(_data['sessionStartTime'].toString())
878
+ : <any>undefined;
879
+ this.sessionEndTime = _data['sessionEndTime']
880
+ ? new Date(_data['sessionEndTime'].toString())
881
+ : <any>undefined;
882
+ this.userName = _data['userName'];
883
+ this.userEmail = _data['userEmail'];
884
+ this.question = _data['question'];
885
+ this.answer = _data['answer'];
886
+ this.messageType = _data['messageType'];
887
+ this.salesforceCaseId = _data['salesforceCaseId'];
888
+ this.guardFlag = _data['guardFlag'];
889
+ this.isGuardrailed = _data['isGuardrailed'];
890
+ this.botVersion = _data['botVersion'];
891
+ this.metadata = _data['metadata'];
892
+ this.feedback = _data['feedback'] ? Feedback.fromJS(_data['feedback']) : <any>undefined;
893
+ this.sessionFeedback = _data['sessionFeedback']
894
+ ? Feedback.fromJS(_data['sessionFeedback'])
895
+ : <any>undefined;
592
896
  }
593
897
  }
594
898
 
@@ -601,24 +905,30 @@ export class ExportHistoryMessage implements IExportHistoryMessage {
601
905
 
602
906
  toJSON(data?: any) {
603
907
  data = typeof data === 'object' ? data : {};
604
- data["id"] = this.id;
605
- data["sessionId"] = this.sessionId;
606
- data["timeStamp"] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
607
- data["userId"] = this.userId;
608
- data["sessionStartTime"] = this.sessionStartTime ? this.sessionStartTime.toISOString() : <any>undefined;
609
- data["sessionEndTime"] = this.sessionEndTime ? this.sessionEndTime.toISOString() : <any>undefined;
610
- data["userName"] = this.userName;
611
- data["userEmail"] = this.userEmail;
612
- data["question"] = this.question;
613
- data["answer"] = this.answer;
614
- data["messageType"] = this.messageType;
615
- data["salesforceCaseId"] = this.salesforceCaseId;
616
- data["guardFlag"] = this.guardFlag;
617
- data["isGuardrailed"] = this.isGuardrailed;
618
- data["botVersion"] = this.botVersion;
619
- data["metadata"] = this.metadata;
620
- data["feedback"] = this.feedback ? this.feedback.toJSON() : <any>undefined;
621
- data["sessionFeedback"] = this.sessionFeedback ? this.sessionFeedback.toJSON() : <any>undefined;
908
+ data['id'] = this.id;
909
+ data['sessionId'] = this.sessionId;
910
+ data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
911
+ data['userId'] = this.userId;
912
+ data['sessionStartTime'] = this.sessionStartTime
913
+ ? this.sessionStartTime.toISOString()
914
+ : <any>undefined;
915
+ data['sessionEndTime'] = this.sessionEndTime
916
+ ? this.sessionEndTime.toISOString()
917
+ : <any>undefined;
918
+ data['userName'] = this.userName;
919
+ data['userEmail'] = this.userEmail;
920
+ data['question'] = this.question;
921
+ data['answer'] = this.answer;
922
+ data['messageType'] = this.messageType;
923
+ data['salesforceCaseId'] = this.salesforceCaseId;
924
+ data['guardFlag'] = this.guardFlag;
925
+ data['isGuardrailed'] = this.isGuardrailed;
926
+ data['botVersion'] = this.botVersion;
927
+ data['metadata'] = this.metadata;
928
+ data['feedback'] = this.feedback ? this.feedback.toJSON() : <any>undefined;
929
+ data['sessionFeedback'] = this.sessionFeedback
930
+ ? this.sessionFeedback.toJSON()
931
+ : <any>undefined;
622
932
  return data;
623
933
  }
624
934
  }
@@ -663,24 +973,22 @@ export class Feedback implements IFeedback {
663
973
  constructor(data?: IFeedback) {
664
974
  if (data) {
665
975
  for (var property in data) {
666
- if (data.hasOwnProperty(property))
667
- (<any>this)[property] = (<any>data)[property];
976
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
668
977
  }
669
978
  }
670
979
  }
671
980
 
672
981
  init(_data?: any) {
673
982
  if (_data) {
674
- this.linkUrl = _data["linkUrl"];
675
- this.description = _data["description"];
676
- this.sessionId = _data["sessionId"];
677
- this.messageId = _data["messageId"];
678
- if (Array.isArray(_data["options"])) {
983
+ this.linkUrl = _data['linkUrl'];
984
+ this.description = _data['description'];
985
+ this.sessionId = _data['sessionId'];
986
+ this.messageId = _data['messageId'];
987
+ if (Array.isArray(_data['options'])) {
679
988
  this.options = [] as any;
680
- for (let item of _data["options"])
681
- this.options!.push(item);
989
+ for (let item of _data['options']) this.options!.push(item);
682
990
  }
683
- this.rating = _data["rating"];
991
+ this.rating = _data['rating'];
684
992
  }
685
993
  }
686
994
 
@@ -693,16 +1001,15 @@ export class Feedback implements IFeedback {
693
1001
 
694
1002
  toJSON(data?: any) {
695
1003
  data = typeof data === 'object' ? data : {};
696
- data["linkUrl"] = this.linkUrl;
697
- data["description"] = this.description;
698
- data["sessionId"] = this.sessionId;
699
- data["messageId"] = this.messageId;
1004
+ data['linkUrl'] = this.linkUrl;
1005
+ data['description'] = this.description;
1006
+ data['sessionId'] = this.sessionId;
1007
+ data['messageId'] = this.messageId;
700
1008
  if (Array.isArray(this.options)) {
701
- data["options"] = [];
702
- for (let item of this.options)
703
- data["options"].push(item);
1009
+ data['options'] = [];
1010
+ for (let item of this.options) data['options'].push(item);
704
1011
  }
705
- data["rating"] = this.rating;
1012
+ data['rating'] = this.rating;
706
1013
  return data;
707
1014
  }
708
1015
  }
@@ -742,8 +1049,7 @@ export class FrontendModel implements IFrontendModel {
742
1049
  constructor(data?: IFrontendModel) {
743
1050
  if (data) {
744
1051
  for (var property in data) {
745
- if (data.hasOwnProperty(property))
746
- (<any>this)[property] = (<any>data)[property];
1052
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
747
1053
  }
748
1054
  }
749
1055
  if (!data) {
@@ -753,7 +1059,7 @@ export class FrontendModel implements IFrontendModel {
753
1059
 
754
1060
  init(_data?: any) {
755
1061
  if (_data) {
756
- this.options = _data["options"] ? Option.fromJS(_data["options"]) : new Option();
1062
+ this.options = _data['options'] ? Option.fromJS(_data['options']) : new Option();
757
1063
  }
758
1064
  }
759
1065
 
@@ -766,7 +1072,7 @@ export class FrontendModel implements IFrontendModel {
766
1072
 
767
1073
  toJSON(data?: any) {
768
1074
  data = typeof data === 'object' ? data : {};
769
- data["options"] = this.options ? this.options.toJSON() : <any>undefined;
1075
+ data['options'] = this.options ? this.options.toJSON() : <any>undefined;
770
1076
  return data;
771
1077
  }
772
1078
  }
@@ -788,21 +1094,19 @@ export class Option implements IOption {
788
1094
  constructor(data?: IOption) {
789
1095
  if (data) {
790
1096
  for (var property in data) {
791
- if (data.hasOwnProperty(property))
792
- (<any>this)[property] = (<any>data)[property];
1097
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
793
1098
  }
794
1099
  }
795
1100
  }
796
1101
 
797
1102
  init(_data?: any) {
798
1103
  if (_data) {
799
- this.key = _data["key"];
800
- this.displayName = _data["displayName"];
801
- this.type = _data["type"];
802
- if (Array.isArray(_data["subOptions"])) {
1104
+ this.key = _data['key'];
1105
+ this.displayName = _data['displayName'];
1106
+ this.type = _data['type'];
1107
+ if (Array.isArray(_data['subOptions'])) {
803
1108
  this.subOptions = [] as any;
804
- for (let item of _data["subOptions"])
805
- this.subOptions!.push(Option.fromJS(item));
1109
+ for (let item of _data['subOptions']) this.subOptions!.push(Option.fromJS(item));
806
1110
  }
807
1111
  }
808
1112
  }
@@ -816,13 +1120,12 @@ export class Option implements IOption {
816
1120
 
817
1121
  toJSON(data?: any) {
818
1122
  data = typeof data === 'object' ? data : {};
819
- data["key"] = this.key;
820
- data["displayName"] = this.displayName;
821
- data["type"] = this.type;
1123
+ data['key'] = this.key;
1124
+ data['displayName'] = this.displayName;
1125
+ data['type'] = this.type;
822
1126
  if (Array.isArray(this.subOptions)) {
823
- data["subOptions"] = [];
824
- for (let item of this.subOptions)
825
- data["subOptions"].push(item.toJSON());
1127
+ data['subOptions'] = [];
1128
+ for (let item of this.subOptions) data['subOptions'].push(item.toJSON());
826
1129
  }
827
1130
  return data;
828
1131
  }
@@ -854,17 +1157,16 @@ export class ScoredUrl implements IScoredUrl {
854
1157
  constructor(data?: IScoredUrl) {
855
1158
  if (data) {
856
1159
  for (var property in data) {
857
- if (data.hasOwnProperty(property))
858
- (<any>this)[property] = (<any>data)[property];
1160
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
859
1161
  }
860
1162
  }
861
1163
  }
862
1164
 
863
1165
  init(_data?: any) {
864
1166
  if (_data) {
865
- this.url = _data["url"];
866
- this.score = _data["score"];
867
- this.title = _data["title"];
1167
+ this.url = _data['url'];
1168
+ this.score = _data['score'];
1169
+ this.title = _data['title'];
868
1170
  }
869
1171
  }
870
1172
 
@@ -877,9 +1179,9 @@ export class ScoredUrl implements IScoredUrl {
877
1179
 
878
1180
  toJSON(data?: any) {
879
1181
  data = typeof data === 'object' ? data : {};
880
- data["url"] = this.url;
881
- data["score"] = this.score;
882
- data["title"] = this.title;
1182
+ data['url'] = this.url;
1183
+ data['score'] = this.score;
1184
+ data['title'] = this.title;
883
1185
  return data;
884
1186
  }
885
1187
  }
@@ -896,29 +1198,29 @@ export class Selections implements ISelections {
896
1198
  /** Selected values. */
897
1199
  values?: string[] | undefined;
898
1200
  /** Child selections down the hierarchy. */
899
- subOptions?: { [key: string]: Selections; } | undefined;
1201
+ subOptions?: { [key: string]: Selections } | undefined;
900
1202
 
901
1203
  constructor(data?: ISelections) {
902
1204
  if (data) {
903
1205
  for (var property in data) {
904
- if (data.hasOwnProperty(property))
905
- (<any>this)[property] = (<any>data)[property];
1206
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
906
1207
  }
907
1208
  }
908
1209
  }
909
1210
 
910
1211
  init(_data?: any) {
911
1212
  if (_data) {
912
- if (Array.isArray(_data["values"])) {
1213
+ if (Array.isArray(_data['values'])) {
913
1214
  this.values = [] as any;
914
- for (let item of _data["values"])
915
- this.values!.push(item);
1215
+ for (let item of _data['values']) this.values!.push(item);
916
1216
  }
917
- if (_data["subOptions"]) {
1217
+ if (_data['subOptions']) {
918
1218
  this.subOptions = {} as any;
919
- for (let key in _data["subOptions"]) {
920
- if (_data["subOptions"].hasOwnProperty(key))
921
- (<any>this.subOptions)![key] = _data["subOptions"][key] ? Selections.fromJS(_data["subOptions"][key]) : new Selections();
1219
+ for (let key in _data['subOptions']) {
1220
+ if (_data['subOptions'].hasOwnProperty(key))
1221
+ (<any>this.subOptions)![key] = _data['subOptions'][key]
1222
+ ? Selections.fromJS(_data['subOptions'][key])
1223
+ : new Selections();
922
1224
  }
923
1225
  }
924
1226
  }
@@ -934,15 +1236,16 @@ export class Selections implements ISelections {
934
1236
  toJSON(data?: any) {
935
1237
  data = typeof data === 'object' ? data : {};
936
1238
  if (Array.isArray(this.values)) {
937
- data["values"] = [];
938
- for (let item of this.values)
939
- data["values"].push(item);
1239
+ data['values'] = [];
1240
+ for (let item of this.values) data['values'].push(item);
940
1241
  }
941
1242
  if (this.subOptions) {
942
- data["subOptions"] = {};
1243
+ data['subOptions'] = {};
943
1244
  for (let key in this.subOptions) {
944
1245
  if (this.subOptions.hasOwnProperty(key))
945
- (<any>data["subOptions"])[key] = this.subOptions[key] ? this.subOptions[key].toJSON() : <any>undefined;
1246
+ (<any>data['subOptions'])[key] = this.subOptions[key]
1247
+ ? this.subOptions[key].toJSON()
1248
+ : <any>undefined;
946
1249
  }
947
1250
  }
948
1251
  return data;
@@ -954,7 +1257,7 @@ export interface ISelections {
954
1257
  /** Selected values. */
955
1258
  values?: string[] | undefined;
956
1259
  /** Child selections down the hierarchy. */
957
- subOptions?: { [key: string]: Selections; } | undefined;
1260
+ subOptions?: { [key: string]: Selections } | undefined;
958
1261
  }
959
1262
 
960
1263
  /** Series of chatbot exchanges making a conversation. */
@@ -962,25 +1265,24 @@ export class Session implements ISession {
962
1265
  /** Primary key. */
963
1266
  id?: number;
964
1267
  /** Arbitrary data to be stored in session. */
965
- data?: { [key: string]: string; } | undefined;
1268
+ data?: { [key: string]: string } | undefined;
966
1269
 
967
1270
  constructor(data?: ISession) {
968
1271
  if (data) {
969
1272
  for (var property in data) {
970
- if (data.hasOwnProperty(property))
971
- (<any>this)[property] = (<any>data)[property];
1273
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
972
1274
  }
973
1275
  }
974
1276
  }
975
1277
 
976
1278
  init(_data?: any) {
977
1279
  if (_data) {
978
- this.id = _data["id"];
979
- if (_data["data"]) {
1280
+ this.id = _data['id'];
1281
+ if (_data['data']) {
980
1282
  this.data = {} as any;
981
- for (let key in _data["data"]) {
982
- if (_data["data"].hasOwnProperty(key))
983
- (<any>this.data)![key] = _data["data"][key];
1283
+ for (let key in _data['data']) {
1284
+ if (_data['data'].hasOwnProperty(key))
1285
+ (<any>this.data)![key] = _data['data'][key];
984
1286
  }
985
1287
  }
986
1288
  }
@@ -995,12 +1297,11 @@ export class Session implements ISession {
995
1297
 
996
1298
  toJSON(data?: any) {
997
1299
  data = typeof data === 'object' ? data : {};
998
- data["id"] = this.id;
1300
+ data['id'] = this.id;
999
1301
  if (this.data) {
1000
- data["data"] = {};
1302
+ data['data'] = {};
1001
1303
  for (let key in this.data) {
1002
- if (this.data.hasOwnProperty(key))
1003
- (<any>data["data"])[key] = (<any>this.data)[key];
1304
+ if (this.data.hasOwnProperty(key)) (<any>data['data'])[key] = (<any>this.data)[key];
1004
1305
  }
1005
1306
  }
1006
1307
  return data;
@@ -1012,7 +1313,7 @@ export interface ISession {
1012
1313
  /** Primary key. */
1013
1314
  id?: number;
1014
1315
  /** Arbitrary data to be stored in session. */
1015
- data?: { [key: string]: string; } | undefined;
1316
+ data?: { [key: string]: string } | undefined;
1016
1317
  }
1017
1318
 
1018
1319
  /** User request message. */
@@ -1027,30 +1328,33 @@ export class UserMessage implements IUserMessage {
1027
1328
  experience!: Experience;
1028
1329
  selections?: Selections;
1029
1330
  /** Additional context. */
1030
- context?: { [key: string]: any; } | undefined;
1331
+ context?: { [key: string]: any } | undefined;
1031
1332
 
1032
1333
  constructor(data?: IUserMessage) {
1033
1334
  if (data) {
1034
1335
  for (var property in data) {
1035
- if (data.hasOwnProperty(property))
1036
- (<any>this)[property] = (<any>data)[property];
1336
+ if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property];
1037
1337
  }
1038
1338
  }
1039
1339
  }
1040
1340
 
1041
1341
  init(_data?: any) {
1042
1342
  if (_data) {
1043
- this.id = _data["id"];
1044
- this.sessionId = _data["sessionId"];
1045
- this.timeStamp = _data["timeStamp"] ? new Date(_data["timeStamp"].toString()) : <any>undefined;
1046
- this.question = _data["question"];
1047
- this.experience = _data["experience"];
1048
- this.selections = _data["selections"] ? Selections.fromJS(_data["selections"]) : <any>undefined;
1049
- if (_data["context"]) {
1343
+ this.id = _data['id'];
1344
+ this.sessionId = _data['sessionId'];
1345
+ this.timeStamp = _data['timeStamp']
1346
+ ? new Date(_data['timeStamp'].toString())
1347
+ : <any>undefined;
1348
+ this.question = _data['question'];
1349
+ this.experience = _data['experience'];
1350
+ this.selections = _data['selections']
1351
+ ? Selections.fromJS(_data['selections'])
1352
+ : <any>undefined;
1353
+ if (_data['context']) {
1050
1354
  this.context = {} as any;
1051
- for (let key in _data["context"]) {
1052
- if (_data["context"].hasOwnProperty(key))
1053
- (<any>this.context)![key] = _data["context"][key];
1355
+ for (let key in _data['context']) {
1356
+ if (_data['context'].hasOwnProperty(key))
1357
+ (<any>this.context)![key] = _data['context'][key];
1054
1358
  }
1055
1359
  }
1056
1360
  }
@@ -1065,17 +1369,17 @@ export class UserMessage implements IUserMessage {
1065
1369
 
1066
1370
  toJSON(data?: any) {
1067
1371
  data = typeof data === 'object' ? data : {};
1068
- data["id"] = this.id;
1069
- data["sessionId"] = this.sessionId;
1070
- data["timeStamp"] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
1071
- data["question"] = this.question;
1072
- data["experience"] = this.experience;
1073
- data["selections"] = this.selections ? this.selections.toJSON() : <any>undefined;
1372
+ data['id'] = this.id;
1373
+ data['sessionId'] = this.sessionId;
1374
+ data['timeStamp'] = this.timeStamp ? this.timeStamp.toISOString() : <any>undefined;
1375
+ data['question'] = this.question;
1376
+ data['experience'] = this.experience;
1377
+ data['selections'] = this.selections ? this.selections.toJSON() : <any>undefined;
1074
1378
  if (this.context) {
1075
- data["context"] = {};
1379
+ data['context'] = {};
1076
1380
  for (let key in this.context) {
1077
1381
  if (this.context.hasOwnProperty(key))
1078
- (<any>data["context"])[key] = (<any>this.context)[key];
1382
+ (<any>data['context'])[key] = (<any>this.context)[key];
1079
1383
  }
1080
1384
  }
1081
1385
  return data;
@@ -1094,17 +1398,23 @@ export interface IUserMessage {
1094
1398
  experience: Experience;
1095
1399
  selections?: Selections;
1096
1400
  /** Additional context. */
1097
- context?: { [key: string]: any; } | undefined;
1401
+ context?: { [key: string]: any } | undefined;
1098
1402
  }
1099
1403
 
1100
1404
  export class ApiException extends Error {
1101
1405
  message: string;
1102
1406
  status: number;
1103
1407
  response: string;
1104
- headers: { [key: string]: any; };
1408
+ headers: { [key: string]: any };
1105
1409
  result: any;
1106
1410
 
1107
- constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
1411
+ constructor(
1412
+ message: string,
1413
+ status: number,
1414
+ response: string,
1415
+ headers: { [key: string]: any },
1416
+ result: any
1417
+ ) {
1108
1418
  super();
1109
1419
 
1110
1420
  this.message = message;
@@ -1121,9 +1431,17 @@ export class ApiException extends Error {
1121
1431
  }
1122
1432
  }
1123
1433
 
1124
- function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any {
1125
- if (result !== null && result !== undefined)
1126
- throw result;
1127
- else
1128
- throw new ApiException(message, status, response, headers, null);
1129
- }
1434
+ function throwException(
1435
+ message: string,
1436
+ status: number,
1437
+ response: string,
1438
+ headers: { [key: string]: any },
1439
+ result?: any
1440
+ ): any {
1441
+ if (result !== null && result !== undefined) throw result;
1442
+ else throw new ApiException(message, status, response, headers, null);
1443
+ }
1444
+
1445
+ function isAxiosError(obj: any): obj is AxiosError {
1446
+ return obj && obj.isAxiosError === true;
1447
+ }