@@ -20,22 +20,21 @@ import { ResponseFormat } from '../networking/fetchOptions.generated.js';
20
20
import { AiResponseFull } from '../schemas/aiResponseFull.generated.js' ;
21
21
import { ClientError } from '../schemas/clientError.generated.js' ;
22
22
import { AiAsk } from '../schemas/aiAsk.generated.js' ;
23
- import { BoxSdkError } from '../box/errors.js' ;
24
23
import { AiResponse } from '../schemas/aiResponse.generated.js' ;
25
24
import { AiTextGen } from '../schemas/aiTextGen.generated.js' ;
26
25
import { AiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen.generated.js' ;
27
26
import { AiExtract } from '../schemas/aiExtract.generated.js' ;
28
27
import { AiExtractResponse } from '../schemas/aiExtractResponse.generated.js' ;
29
28
import { AiExtractStructured } from '../schemas/aiExtractStructured.generated.js' ;
29
+ import { BoxSdkError } from '../box/errors.js' ;
30
30
import { Authentication } from '../networking/auth.generated.js' ;
31
31
import { NetworkSession } from '../networking/network.generated.js' ;
32
+ import { FetchOptions } from '../networking/fetchOptions.generated.js' ;
33
+ import { FetchResponse } from '../networking/fetchResponse.generated.js' ;
32
34
import { prepareParams } from '../internal/utils.js' ;
33
35
import { toString } from '../internal/utils.js' ;
34
36
import { ByteStream } from '../internal/utils.js' ;
35
37
import { CancellationToken } from '../internal/utils.js' ;
36
- import { FetchOptions } from '../networking/fetchOptions.generated.js' ;
37
- import { FetchResponse } from '../networking/fetchResponse.generated.js' ;
38
- import { fetch } from '../networking/fetch.js' ;
39
38
import { SerializedData } from '../serialization/json.js' ;
40
39
import { sdToJson } from '../serialization/json.js' ;
41
40
import { sdIsEmpty } from '../serialization/json.js' ;
@@ -332,22 +331,23 @@ export class AiManager {
332
331
const headersMap : {
333
332
readonly [ key : string ] : string ;
334
333
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
335
- const response : FetchResponse = ( await fetch (
336
- new FetchOptions ( {
337
- url : '' . concat (
338
- this . networkSession . baseUrls . baseUrl ,
339
- '/2.0/ai/ask' ,
340
- ) as string ,
341
- method : 'POST' ,
342
- headers : headersMap ,
343
- data : serializeAiAsk ( requestBody ) ,
344
- contentType : 'application/json' ,
345
- responseFormat : 'json' as ResponseFormat ,
346
- auth : this . auth ,
347
- networkSession : this . networkSession ,
348
- cancellationToken : cancellationToken ,
349
- } ) ,
350
- ) ) as FetchResponse ;
334
+ const response : FetchResponse =
335
+ await this . networkSession . networkClient . fetch (
336
+ new FetchOptions ( {
337
+ url : '' . concat (
338
+ this . networkSession . baseUrls . baseUrl ,
339
+ '/2.0/ai/ask' ,
340
+ ) as string ,
341
+ method : 'POST' ,
342
+ headers : headersMap ,
343
+ data : serializeAiAsk ( requestBody ) ,
344
+ contentType : 'application/json' ,
345
+ responseFormat : 'json' as ResponseFormat ,
346
+ auth : this . auth ,
347
+ networkSession : this . networkSession ,
348
+ cancellationToken : cancellationToken ,
349
+ } ) ,
350
+ ) ;
351
351
return {
352
352
...deserializeAiResponseFull ( response . data ! ) ,
353
353
rawData : response . data ! ,
@@ -372,22 +372,23 @@ export class AiManager {
372
372
const headersMap : {
373
373
readonly [ key : string ] : string ;
374
374
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
375
- const response : FetchResponse = ( await fetch (
376
- new FetchOptions ( {
377
- url : '' . concat (
378
- this . networkSession . baseUrls . baseUrl ,
379
- '/2.0/ai/text_gen' ,
380
- ) as string ,
381
- method : 'POST' ,
382
- headers : headersMap ,
383
- data : serializeAiTextGen ( requestBody ) ,
384
- contentType : 'application/json' ,
385
- responseFormat : 'json' as ResponseFormat ,
386
- auth : this . auth ,
387
- networkSession : this . networkSession ,
388
- cancellationToken : cancellationToken ,
389
- } ) ,
390
- ) ) as FetchResponse ;
375
+ const response : FetchResponse =
376
+ await this . networkSession . networkClient . fetch (
377
+ new FetchOptions ( {
378
+ url : '' . concat (
379
+ this . networkSession . baseUrls . baseUrl ,
380
+ '/2.0/ai/text_gen' ,
381
+ ) as string ,
382
+ method : 'POST' ,
383
+ headers : headersMap ,
384
+ data : serializeAiTextGen ( requestBody ) ,
385
+ contentType : 'application/json' ,
386
+ responseFormat : 'json' as ResponseFormat ,
387
+ auth : this . auth ,
388
+ networkSession : this . networkSession ,
389
+ cancellationToken : cancellationToken ,
390
+ } ) ,
391
+ ) ;
391
392
return {
392
393
...deserializeAiResponse ( response . data ! ) ,
393
394
rawData : response . data ! ,
@@ -420,21 +421,22 @@ export class AiManager {
420
421
const headersMap : {
421
422
readonly [ key : string ] : string ;
422
423
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
423
- const response : FetchResponse = ( await fetch (
424
- new FetchOptions ( {
425
- url : '' . concat (
426
- this . networkSession . baseUrls . baseUrl ,
427
- '/2.0/ai_agent_default' ,
428
- ) as string ,
429
- method : 'GET' ,
430
- params : queryParamsMap ,
431
- headers : headersMap ,
432
- responseFormat : 'json' as ResponseFormat ,
433
- auth : this . auth ,
434
- networkSession : this . networkSession ,
435
- cancellationToken : cancellationToken ,
436
- } ) ,
437
- ) ) as FetchResponse ;
424
+ const response : FetchResponse =
425
+ await this . networkSession . networkClient . fetch (
426
+ new FetchOptions ( {
427
+ url : '' . concat (
428
+ this . networkSession . baseUrls . baseUrl ,
429
+ '/2.0/ai_agent_default' ,
430
+ ) as string ,
431
+ method : 'GET' ,
432
+ params : queryParamsMap ,
433
+ headers : headersMap ,
434
+ responseFormat : 'json' as ResponseFormat ,
435
+ auth : this . auth ,
436
+ networkSession : this . networkSession ,
437
+ cancellationToken : cancellationToken ,
438
+ } ) ,
439
+ ) ;
438
440
return {
439
441
...deserializeAiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen (
440
442
response . data ! ,
@@ -463,22 +465,23 @@ export class AiManager {
463
465
const headersMap : {
464
466
readonly [ key : string ] : string ;
465
467
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
466
- const response : FetchResponse = ( await fetch (
467
- new FetchOptions ( {
468
- url : '' . concat (
469
- this . networkSession . baseUrls . baseUrl ,
470
- '/2.0/ai/extract' ,
471
- ) as string ,
472
- method : 'POST' ,
473
- headers : headersMap ,
474
- data : serializeAiExtract ( requestBody ) ,
475
- contentType : 'application/json' ,
476
- responseFormat : 'json' as ResponseFormat ,
477
- auth : this . auth ,
478
- networkSession : this . networkSession ,
479
- cancellationToken : cancellationToken ,
480
- } ) ,
481
- ) ) as FetchResponse ;
468
+ const response : FetchResponse =
469
+ await this . networkSession . networkClient . fetch (
470
+ new FetchOptions ( {
471
+ url : '' . concat (
472
+ this . networkSession . baseUrls . baseUrl ,
473
+ '/2.0/ai/extract' ,
474
+ ) as string ,
475
+ method : 'POST' ,
476
+ headers : headersMap ,
477
+ data : serializeAiExtract ( requestBody ) ,
478
+ contentType : 'application/json' ,
479
+ responseFormat : 'json' as ResponseFormat ,
480
+ auth : this . auth ,
481
+ networkSession : this . networkSession ,
482
+ cancellationToken : cancellationToken ,
483
+ } ) ,
484
+ ) ;
482
485
return {
483
486
...deserializeAiResponse ( response . data ! ) ,
484
487
rawData : response . data ! ,
@@ -508,22 +511,23 @@ export class AiManager {
508
511
const headersMap : {
509
512
readonly [ key : string ] : string ;
510
513
} = prepareParams ( { ...{ } , ...headers . extraHeaders } ) ;
511
- const response : FetchResponse = ( await fetch (
512
- new FetchOptions ( {
513
- url : '' . concat (
514
- this . networkSession . baseUrls . baseUrl ,
515
- '/2.0/ai/extract_structured' ,
516
- ) as string ,
517
- method : 'POST' ,
518
- headers : headersMap ,
519
- data : serializeAiExtractStructured ( requestBody ) ,
520
- contentType : 'application/json' ,
521
- responseFormat : 'json' as ResponseFormat ,
522
- auth : this . auth ,
523
- networkSession : this . networkSession ,
524
- cancellationToken : cancellationToken ,
525
- } ) ,
526
- ) ) as FetchResponse ;
514
+ const response : FetchResponse =
515
+ await this . networkSession . networkClient . fetch (
516
+ new FetchOptions ( {
517
+ url : '' . concat (
518
+ this . networkSession . baseUrls . baseUrl ,
519
+ '/2.0/ai/extract_structured' ,
520
+ ) as string ,
521
+ method : 'POST' ,
522
+ headers : headersMap ,
523
+ data : serializeAiExtractStructured ( requestBody ) ,
524
+ contentType : 'application/json' ,
525
+ responseFormat : 'json' as ResponseFormat ,
526
+ auth : this . auth ,
527
+ networkSession : this . networkSession ,
528
+ cancellationToken : cancellationToken ,
529
+ } ) ,
530
+ ) ;
527
531
return {
528
532
...deserializeAiExtractResponse ( response . data ! ) ,
529
533
rawData : response . data ! ,
0 commit comments