Skip to content

Commit 3124249

Browse files
committed
fix(services/usenet): add missing schemas and remove manually set form-data header
1 parent d39a690 commit 3124249

File tree

5 files changed

+203
-13
lines changed

5 files changed

+203
-13
lines changed

src/services/usenet/models/create-usenet-download-ok-response-data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const createUsenetDownloadOkResponseData = z.lazy(() => {
77
return z.object({
88
authId: z.string().optional(),
99
hash: z.string().optional(),
10-
usenetdownloadId: z.string().optional(),
10+
usenetdownloadId: z.number().optional(),
1111
});
1212
});
1313

@@ -29,7 +29,7 @@ export const createUsenetDownloadOkResponseDataResponse = z.lazy(() => {
2929
.object({
3030
auth_id: z.string().optional(),
3131
hash: z.string().optional(),
32-
usenetdownload_id: z.string().optional(),
32+
usenetdownload_id: z.number().optional(),
3333
})
3434
.transform((data) => ({
3535
authId: data['auth_id'],
@@ -47,7 +47,7 @@ export const createUsenetDownloadOkResponseDataRequest = z.lazy(() => {
4747
.object({
4848
authId: z.string().optional(),
4949
hash: z.string().optional(),
50-
usenetdownloadId: z.string().optional(),
50+
usenetdownloadId: z.number().optional(),
5151
})
5252
.transform((data) => ({
5353
auth_id: data['authId'],
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { z } from 'zod';
2+
3+
/**
4+
* The shape of the model inside the application code - what the users use
5+
*/
6+
export const getUsenetCachedAvailabilityOkResponseData = z.lazy(() => {
7+
return z.object({
8+
name: z.string().optional(),
9+
size: z.number().optional(),
10+
hash: z.string().optional(),
11+
});
12+
});
13+
14+
/**
15+
*
16+
* @typedef {GetUsenetCachedAvailabilityOkResponseData} getUsenetCachedAvailabilityOkResponseData
17+
* @property {string}
18+
* @property {number}
19+
* @property {string}
20+
*/
21+
export type GetUsenetCachedAvailabilityOkResponseData = z.infer<typeof getUsenetCachedAvailabilityOkResponseData>;
22+
23+
/**
24+
* The shape of the model mapping from the api schema into the application shape.
25+
* Is equal to application shape if all property names match the api schema
26+
*/
27+
export const getUsenetCachedAvailabilityOkResponseDataResponse = z.lazy(() => {
28+
return z
29+
.object({
30+
name: z.string().optional(),
31+
size: z.number().optional(),
32+
hash: z.string().optional(),
33+
})
34+
.transform((data) => ({
35+
name: data['name'],
36+
size: data['size'],
37+
hash: data['hash'],
38+
}));
39+
});
40+
41+
/**
42+
* The shape of the model mapping from the application shape into the api schema.
43+
* Is equal to application shape if all property names match the api schema
44+
*/
45+
export const getUsenetCachedAvailabilityOkResponseDataRequest = z.lazy(() => {
46+
return z
47+
.object({
48+
name: z.string().optional(),
49+
size: z.number().optional(),
50+
hash: z.string().optional(),
51+
})
52+
.transform((data) => ({
53+
name: data['name'],
54+
size: data['size'],
55+
hash: data['hash'],
56+
}));
57+
});
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { z } from 'zod';
2+
import { getUsenetCachedAvailabilityOkResponseData, getUsenetCachedAvailabilityOkResponseDataResponse } from './get-usenet-cached-availability-response-data';
3+
4+
/**
5+
* The shape of the model inside the application code - what the users use
6+
*/
7+
export const getUsenetCachedAvailabilityOkResponse = z.lazy(() => {
8+
return z.object({
9+
data: z.union([z.array(getUsenetCachedAvailabilityOkResponseData), z.record(z.string(), getUsenetCachedAvailabilityOkResponseData)]).optional(),
10+
detail: z.string().optional(),
11+
error: z.string().optional().nullable(),
12+
success: z.boolean().optional(),
13+
});
14+
});
15+
16+
/**
17+
*
18+
* @typedef {GetUsenetCachedAvailabilityOkResponse} getUsenetCachedAvailabilityOkResponse
19+
* @property {any}
20+
* @property {string}
21+
* @property {string}
22+
* @property {boolean}
23+
*/
24+
export type GetUsenetCachedAvailabilityOkResponse = z.infer<typeof getUsenetCachedAvailabilityOkResponse>;
25+
26+
/**
27+
* The shape of the model mapping from the api schema into the application shape.
28+
* Is equal to application shape if all property names match the api schema
29+
*/
30+
export const getUsenetCachedAvailabilityOkResponseResponse = z.lazy(() => {
31+
return z
32+
.object({
33+
data: z.union([z.array(getUsenetCachedAvailabilityOkResponseDataResponse), z.record(z.string(), getUsenetCachedAvailabilityOkResponseDataResponse)]).optional(),
34+
detail: z.string().optional(),
35+
error: z.string().optional().nullable(),
36+
success: z.boolean().optional(),
37+
})
38+
.transform((data) => ({
39+
data: data['data'],
40+
detail: data['detail'],
41+
error: data['error'],
42+
success: data['success'],
43+
}));
44+
});
45+
46+
/**
47+
* The shape of the model mapping from the application shape into the api schema.
48+
* Is equal to application shape if all property names match the api schema
49+
*/
50+
export const getUsenetCachedAvailabilityOkResponseRequest = z.lazy(() => {
51+
return z
52+
.object({
53+
data: z.union([z.array(getUsenetCachedAvailabilityOkResponseDataResponse), z.record(z.string(), getUsenetCachedAvailabilityOkResponseDataResponse)]).optional(),
54+
detail: z.string().optional(),
55+
error: z.string().optional().nullable(),
56+
success: z.boolean().optional(),
57+
})
58+
.transform((data) => ({
59+
data: data['data'],
60+
detail: data['detail'],
61+
error: data['error'],
62+
success: data['success'],
63+
}));
64+
});
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { z } from 'zod';
2+
3+
/**
4+
* The shape of the model inside the application code - what the users use
5+
*/
6+
export const requestDownloadLinkOkResponse = z.lazy(() => {
7+
return z.object({
8+
data: z.string().optional(),
9+
detail: z.string().optional(),
10+
error: z.any().optional().nullable(),
11+
success: z.boolean().optional(),
12+
});
13+
});
14+
15+
/**
16+
*
17+
* @typedef {RequestDownloadLinkOkResponse} requestDownloadLinkOkResponse
18+
* @property {string}
19+
* @property {string}
20+
* @property {any}
21+
* @property {boolean}
22+
*/
23+
export type RequestDownloadLinkOkResponse = z.infer<typeof requestDownloadLinkOkResponse>;
24+
25+
/**
26+
* The shape of the model mapping from the api schema into the application shape.
27+
* Is equal to application shape if all property names match the api schema
28+
*/
29+
export const requestDownloadLinkOkResponseResponse = z.lazy(() => {
30+
return z
31+
.object({
32+
data: z.string().optional(),
33+
detail: z.string().optional(),
34+
error: z.any().optional().nullable(),
35+
success: z.boolean().optional(),
36+
})
37+
.transform((data) => ({
38+
data: data['data'],
39+
detail: data['detail'],
40+
error: data['error'],
41+
success: data['success'],
42+
}));
43+
});
44+
45+
/**
46+
* The shape of the model mapping from the application shape into the api schema.
47+
* Is equal to application shape if all property names match the api schema
48+
*/
49+
export const requestDownloadLinkOkResponseRequest = z.lazy(() => {
50+
return z
51+
.object({
52+
data: z.string().optional(),
53+
detail: z.string().optional(),
54+
error: z.any().optional().nullable(),
55+
success: z.boolean().optional(),
56+
})
57+
.transform((data) => ({
58+
data: data['data'],
59+
detail: data['detail'],
60+
error: data['error'],
61+
success: data['success'],
62+
}));
63+
});

src/services/usenet/usenet-service.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
import { _8 } from './models/_8';
1616
import { GetUsenetCachedAvailabilityParams, GetUsenetListParams, RequestDownloadLink1Params } from './request-params';
1717
import { GetUsenetListOkResponse, getUsenetListOkResponseResponse } from './models/get-usenet-list-ok-response';
18+
import { RequestDownloadLinkOkResponse, requestDownloadLinkOkResponseResponse } from './models/request-download-link-response';
19+
import { GetUsenetCachedAvailabilityOkResponse, getUsenetCachedAvailabilityOkResponseResponse } from './models/get-usenet-cached-availability-response';
1820

1921
export class UsenetService extends BaseService {
2022
/**
@@ -68,7 +70,6 @@ Requires an API key using the Authorization Bearer Header.
6870
key: 'api_version',
6971
value: apiVersion,
7072
})
71-
.addHeaderParam({ key: 'Content-Type', value: 'multipart/form-data' })
7273
.addBody(body)
7374
.build();
7475
return this.client.call<CreateUsenetDownloadOkResponse>(request);
@@ -149,13 +150,13 @@ Requires an API key as a parameter for the `token` parameter.
149150
* @param {string} [params.userIp] - The user's IP to determine the closest CDN. Optional.
150151
* @param {string} [params.redirect] - If you want to redirect the user to the CDN link. This is useful for creating permalinks so that you can just make this request URL the link.
151152
* @param {RequestConfig} requestConfig - (Optional) The request configuration for retry and validation.
152-
* @returns {Promise<HttpResponse<any>>}
153+
* @returns {Promise<HttpResponse<RequestDownloadLinkOkResponse>>}
153154
*/
154-
async requestDownloadLink1(
155+
async requestDownloadLink(
155156
apiVersion: string,
156157
params?: RequestDownloadLink1Params,
157158
requestConfig?: RequestConfig,
158-
): Promise<HttpResponse<void>> {
159+
): Promise<HttpResponse<RequestDownloadLinkOkResponse>> {
159160
const request = new RequestBuilder()
160161
.setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT)
161162
.setConfig(this.config)
@@ -167,6 +168,11 @@ Requires an API key as a parameter for the `token` parameter.
167168
.addResponse({
168169
schema: z.undefined(),
169170
contentType: ContentType.NoContent,
171+
status: 307,
172+
})
173+
.addResponse({
174+
schema: requestDownloadLinkOkResponseResponse,
175+
contentType: ContentType.Json,
170176
status: 200,
171177
})
172178
.setRetryAttempts(this.config, requestConfig)
@@ -201,7 +207,7 @@ Requires an API key as a parameter for the `token` parameter.
201207
value: params?.redirect,
202208
})
203209
.build();
204-
return this.client.call<void>(request);
210+
return this.client.call<RequestDownloadLinkOkResponse>(request);
205211
}
206212

207213
/**
@@ -283,13 +289,13 @@ Requires an API key using the Authorization Bearer Header.
283289
* @param {string} [params.hash] - The list of usenet hashes you want to check. Comma seperated. To find the hash, md5 the link of the usenet link or file.
284290
* @param {string} [params.format] - Format you want the data in. Acceptable is either "object" or "list". List is the most performant option as it doesn't require modification of the list.
285291
* @param {RequestConfig} requestConfig - (Optional) The request configuration for retry and validation.
286-
* @returns {Promise<HttpResponse<any>>}
292+
* @returns {Promise<HttpResponse<GetUsenetCachedAvailabilityOkResponse>>}
287293
*/
288294
async getUsenetCachedAvailability(
289295
apiVersion: string,
290296
params?: GetUsenetCachedAvailabilityParams,
291297
requestConfig?: RequestConfig,
292-
): Promise<HttpResponse<void>> {
298+
): Promise<HttpResponse<GetUsenetCachedAvailabilityOkResponse>> {
293299
const request = new RequestBuilder()
294300
.setBaseUrl(requestConfig?.baseUrl || this.config.baseUrl || this.config.environment || Environment.DEFAULT)
295301
.setConfig(this.config)
@@ -299,8 +305,8 @@ Requires an API key using the Authorization Bearer Header.
299305
.addAccessTokenAuth(this.config.token, 'Bearer')
300306
.setRequestContentType(ContentType.Json)
301307
.addResponse({
302-
schema: z.undefined(),
303-
contentType: ContentType.NoContent,
308+
schema: getUsenetCachedAvailabilityOkResponseResponse,
309+
contentType: ContentType.Json,
304310
status: 200,
305311
})
306312
.setRetryAttempts(this.config, requestConfig)
@@ -319,6 +325,6 @@ Requires an API key using the Authorization Bearer Header.
319325
value: params?.format,
320326
})
321327
.build();
322-
return this.client.call<void>(request);
328+
return this.client.call<GetUsenetCachedAvailabilityOkResponse>(request);
323329
}
324330
}

0 commit comments

Comments
 (0)