Skip to content

feat: Include URL into FetchOptions (box/box-codegen#549) #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "6dfffba", "specHash": "57614c2", "version": "1.4.0" }
{ "engineHash": "2bf4a47", "specHash": "57614c2", "version": "1.4.0" }
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 35 additions & 38 deletions src/managers/ai.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,20 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/ai/ask') as string,
{
method: 'POST',
headers: headersMap,
data: serializeAiAsk(requestBody),
contentType: 'application/json',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/ask'
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiAsk(requestBody),
contentType: 'application/json',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return deserializeAiResponseFull(response.data);
}
/**
Expand All @@ -255,22 +256,20 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/text_gen'
) as string,
{
method: 'POST',
headers: headersMap,
data: serializeAiTextGen(requestBody),
contentType: 'application/json',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'POST',
headers: headersMap,
data: serializeAiTextGen(requestBody),
contentType: 'application/json',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return deserializeAiResponse(response.data);
}
/**
Expand Down Expand Up @@ -300,21 +299,19 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai_agent_default'
) as string,
{
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return deserializeAiAgentAskOrAiAgentTextGen(response.data);
}
}
Expand Down
97 changes: 46 additions & 51 deletions src/managers/authorization.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,19 @@ export class AuthorizationManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(this.networkSession.baseUrls.oauth2Url, '/authorize') as string,
{
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: void 0,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.oauth2Url,
'/authorize'
) as string,
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: void 0,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return void 0;
}
/**
Expand Down Expand Up @@ -348,22 +349,20 @@ export class AuthorizationManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/oauth2/token'
) as string,
{
method: 'POST',
headers: headersMap,
data: serializePostOAuth2Token(requestBody),
contentType: 'application/x-www-form-urlencoded',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'POST',
headers: headersMap,
data: serializePostOAuth2Token(requestBody),
contentType: 'application/x-www-form-urlencoded',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return deserializeAccessToken(response.data);
}
/**
Expand Down Expand Up @@ -393,22 +392,20 @@ export class AuthorizationManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/oauth2/token#refresh'
) as string,
{
method: 'POST',
headers: headersMap,
data: serializePostOAuth2TokenRefreshAccessToken(requestBody),
contentType: 'application/x-www-form-urlencoded',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'POST',
headers: headersMap,
data: serializePostOAuth2TokenRefreshAccessToken(requestBody),
contentType: 'application/x-www-form-urlencoded',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return deserializeAccessToken(response.data);
}
/**
Expand All @@ -432,22 +429,20 @@ export class AuthorizationManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/oauth2/revoke'
) as string,
{
method: 'POST',
headers: headersMap,
data: serializePostOAuth2Revoke(requestBody),
contentType: 'application/x-www-form-urlencoded',
responseFormat: void 0,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'POST',
headers: headersMap,
data: serializePostOAuth2Revoke(requestBody),
contentType: 'application/x-www-form-urlencoded',
responseFormat: void 0,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return void 0;
}
}
Expand Down
78 changes: 36 additions & 42 deletions src/managers/avatars.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,20 @@ export class AvatarsManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/users/',
toString(userId) as string,
'/avatar'
) as string,
{
method: 'GET',
headers: headersMap,
responseFormat: 'binary',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'GET',
headers: headersMap,
responseFormat: 'binary',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return response.content;
}
/**
Expand All @@ -240,31 +238,29 @@ export class AvatarsManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/users/',
toString(userId) as string,
'/avatar'
) as string,
{
method: 'POST',
headers: headersMap,
multipartData: [
{
partName: 'pic',
fileStream: requestBody.pic,
fileName: requestBody.picFileName,
contentType: requestBody.picContentType,
} satisfies MultipartItem,
],
contentType: 'multipart/form-data',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'POST',
headers: headersMap,
multipartData: [
{
partName: 'pic',
fileStream: requestBody.pic,
fileName: requestBody.picFileName,
contentType: requestBody.picContentType,
} satisfies MultipartItem,
],
contentType: 'multipart/form-data',
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return deserializeUserAvatar(response.data);
}
/**
Expand All @@ -288,22 +284,20 @@ export class AvatarsManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
''.concat(
const response: FetchResponse = (await fetch({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/users/',
toString(userId) as string,
'/avatar'
) as string,
{
method: 'DELETE',
headers: headersMap,
responseFormat: void 0,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions
)) as FetchResponse;
method: 'DELETE',
headers: headersMap,
responseFormat: void 0,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
} satisfies FetchOptions)) as FetchResponse;
return void 0;
}
}
Expand Down
Loading
Loading