130 lines
5.7 KiB
TypeScript
130 lines
5.7 KiB
TypeScript
// This file is auto-generated by @hey-api/openapi-ts
|
|
|
|
import type { Client, Options as Options2, TDataShape } from './client';
|
|
import { client } from './client.gen';
|
|
import type { AddUserTitleData, AddUserTitleErrors, AddUserTitleResponses, DeleteUserTitleData, DeleteUserTitleErrors, DeleteUserTitleResponses, GetTitleData, GetTitleErrors, GetTitleResponses, GetTitlesData, GetTitlesErrors, GetTitlesResponses, GetUsersData, GetUsersErrors, GetUsersIdData, GetUsersIdErrors, GetUsersIdResponses, GetUsersResponses, GetUserTitleData, GetUserTitleErrors, GetUserTitleResponses, GetUserTitlesData, GetUserTitlesErrors, GetUserTitlesResponses, PostMediaUploadData, PostMediaUploadErrors, PostMediaUploadResponses, UpdateUserData, UpdateUserErrors, UpdateUserResponses, UpdateUserTitleData, UpdateUserTitleErrors, UpdateUserTitleResponses } from './types.gen';
|
|
|
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
|
/**
|
|
* You can provide a client instance returned by `createClient()` instead of
|
|
* individual options. This might be also useful if you want to implement a
|
|
* custom client.
|
|
*/
|
|
client?: Client;
|
|
/**
|
|
* You can pass arbitrary values through the `meta` object. This can be
|
|
* used to access values that aren't defined as part of the SDK function.
|
|
*/
|
|
meta?: Record<string, unknown>;
|
|
};
|
|
|
|
/**
|
|
* Get titles
|
|
*/
|
|
export const getTitles = <ThrowOnError extends boolean = false>(options?: Options<GetTitlesData, ThrowOnError>) => (options?.client ?? client).get<GetTitlesResponses, GetTitlesErrors, ThrowOnError>({
|
|
querySerializer: { parameters: { status: { array: { explode: false } } } },
|
|
url: '/titles',
|
|
...options
|
|
});
|
|
|
|
/**
|
|
* Get title description
|
|
*/
|
|
export const getTitle = <ThrowOnError extends boolean = false>(options: Options<GetTitleData, ThrowOnError>) => (options.client ?? client).get<GetTitleResponses, GetTitleErrors, ThrowOnError>({ url: '/titles/{title_id}', ...options });
|
|
|
|
/**
|
|
* Search user by nickname or dispname (both in one param), response is always sorted by id
|
|
*/
|
|
export const getUsers = <ThrowOnError extends boolean = false>(options?: Options<GetUsersData, ThrowOnError>) => (options?.client ?? client).get<GetUsersResponses, GetUsersErrors, ThrowOnError>({ url: '/users/', ...options });
|
|
|
|
/**
|
|
* Get user info
|
|
*/
|
|
export const getUsersId = <ThrowOnError extends boolean = false>(options: Options<GetUsersIdData, ThrowOnError>) => (options.client ?? client).get<GetUsersIdResponses, GetUsersIdErrors, ThrowOnError>({ url: '/users/{user_id}', ...options });
|
|
|
|
/**
|
|
* Partially update a user account
|
|
*
|
|
* Update selected user profile fields (excluding password).
|
|
* Password updates must be done via the dedicated auth-service (`/auth/`).
|
|
* Fields not provided in the request body remain unchanged.
|
|
*
|
|
*/
|
|
export const updateUser = <ThrowOnError extends boolean = false>(options: Options<UpdateUserData, ThrowOnError>) => (options.client ?? client).patch<UpdateUserResponses, UpdateUserErrors, ThrowOnError>({
|
|
security: [{ name: 'X-XSRF-TOKEN', type: 'apiKey' }],
|
|
url: '/users/{user_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Get user titles
|
|
*/
|
|
export const getUserTitles = <ThrowOnError extends boolean = false>(options: Options<GetUserTitlesData, ThrowOnError>) => (options.client ?? client).get<GetUserTitlesResponses, GetUserTitlesErrors, ThrowOnError>({
|
|
querySerializer: { parameters: { status: { array: { explode: false } }, watch_status: { array: { explode: false } } } },
|
|
url: '/users/{user_id}/titles',
|
|
...options
|
|
});
|
|
|
|
/**
|
|
* Add a title to a user
|
|
*
|
|
* User adding title to list af watched, status required
|
|
*/
|
|
export const addUserTitle = <ThrowOnError extends boolean = false>(options: Options<AddUserTitleData, ThrowOnError>) => (options.client ?? client).post<AddUserTitleResponses, AddUserTitleErrors, ThrowOnError>({
|
|
url: '/users/{user_id}/titles',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Delete a usertitle
|
|
*
|
|
* User deleting title from list of watched
|
|
*/
|
|
export const deleteUserTitle = <ThrowOnError extends boolean = false>(options: Options<DeleteUserTitleData, ThrowOnError>) => (options.client ?? client).delete<DeleteUserTitleResponses, DeleteUserTitleErrors, ThrowOnError>({
|
|
security: [{ name: 'X-XSRF-TOKEN', type: 'apiKey' }],
|
|
url: '/users/{user_id}/titles/{title_id}',
|
|
...options
|
|
});
|
|
|
|
/**
|
|
* Get user title
|
|
*/
|
|
export const getUserTitle = <ThrowOnError extends boolean = false>(options: Options<GetUserTitleData, ThrowOnError>) => (options.client ?? client).get<GetUserTitleResponses, GetUserTitleErrors, ThrowOnError>({ url: '/users/{user_id}/titles/{title_id}', ...options });
|
|
|
|
/**
|
|
* Update a usertitle
|
|
*
|
|
* User updating title list of watched
|
|
*/
|
|
export const updateUserTitle = <ThrowOnError extends boolean = false>(options: Options<UpdateUserTitleData, ThrowOnError>) => (options.client ?? client).patch<UpdateUserTitleResponses, UpdateUserTitleErrors, ThrowOnError>({
|
|
security: [{ name: 'X-XSRF-TOKEN', type: 'apiKey' }],
|
|
url: '/users/{user_id}/titles/{title_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Upload an image (PNG, JPEG, or WebP)
|
|
*
|
|
* Uploads a single image file. Supported formats: **PNG**, **JPEG/JPG**, **WebP**.
|
|
*
|
|
*/
|
|
export const postMediaUpload = <ThrowOnError extends boolean = false>(options: Options<PostMediaUploadData, ThrowOnError>) => (options.client ?? client).post<PostMediaUploadResponses, PostMediaUploadErrors, ThrowOnError>({
|
|
url: '/media/upload',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'encoding',
|
|
...options.headers
|
|
}
|
|
});
|