mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
385 lines
14 KiB
TypeScript
385 lines
14 KiB
TypeScript
// This file is auto-generated by @hey-api/openapi-ts
|
|
|
|
import { type Client, type Options as Options2, type TDataShape, urlSearchParamsBodySerializer } from './client';
|
|
import { client } from './client.gen';
|
|
import type { itemsCreateItemData, itemsCreateItemErrors, itemsCreateItemResponses, itemsDeleteItemData, itemsDeleteItemErrors, itemsDeleteItemResponses, itemsReadItemData, itemsReadItemErrors, itemsReadItemResponses, itemsReadItemsData, itemsReadItemsErrors, itemsReadItemsResponses, itemsUpdateItemData, itemsUpdateItemErrors, itemsUpdateItemResponses, loginLoginAccessTokenData, loginLoginAccessTokenErrors, loginLoginAccessTokenResponses, loginRecoverPasswordData, loginRecoverPasswordErrors, loginRecoverPasswordHtmlContentData, loginRecoverPasswordHtmlContentErrors, loginRecoverPasswordHtmlContentResponses, loginRecoverPasswordResponses, loginResetPasswordData, loginResetPasswordErrors, loginResetPasswordResponses, loginTestTokenData, loginTestTokenResponses, privateCreateUserData, privateCreateUserErrors, privateCreateUserResponses, usersCreateUserData, usersCreateUserErrors, usersCreateUserResponses, usersDeleteUserData, usersDeleteUserErrors, usersDeleteUserMeData, usersDeleteUserMeResponses, usersDeleteUserResponses, usersReadUserByIdData, usersReadUserByIdErrors, usersReadUserByIdResponses, usersReadUserMeData, usersReadUserMeResponses, usersReadUsersData, usersReadUsersErrors, usersReadUsersResponses, usersRegisterUserData, usersRegisterUserErrors, usersRegisterUserResponses, usersUpdatePasswordMeData, usersUpdatePasswordMeErrors, usersUpdatePasswordMeResponses, usersUpdateUserData, usersUpdateUserErrors, usersUpdateUserMeData, usersUpdateUserMeErrors, usersUpdateUserMeResponses, usersUpdateUserResponses, utilsHealthCheckData, utilsHealthCheckResponses, utilsTestEmailData, utilsTestEmailErrors, utilsTestEmailResponses } from './types.gen';
|
|
|
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
|
/**
|
|
* 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>;
|
|
};
|
|
|
|
export class LoginService {
|
|
/**
|
|
* Login Access Token
|
|
*
|
|
* OAuth2 compatible token login, get an access token for future requests
|
|
*/
|
|
public static loginAccessToken<ThrowOnError extends boolean = true>(options: Options<loginLoginAccessTokenData, ThrowOnError>) {
|
|
return (options.client ?? client).post<loginLoginAccessTokenResponses, loginLoginAccessTokenErrors, ThrowOnError>({
|
|
...urlSearchParamsBodySerializer,
|
|
responseType: 'json',
|
|
url: '/api/v1/login/access-token',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test Token
|
|
*
|
|
* Test access token
|
|
*/
|
|
public static testToken<ThrowOnError extends boolean = true>(options?: Options<loginTestTokenData, ThrowOnError>) {
|
|
return (options?.client ?? client).post<loginTestTokenResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/login/test-token',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Recover Password
|
|
*
|
|
* Password Recovery
|
|
*/
|
|
public static recoverPassword<ThrowOnError extends boolean = true>(options: Options<loginRecoverPasswordData, ThrowOnError>) {
|
|
return (options.client ?? client).post<loginRecoverPasswordResponses, loginRecoverPasswordErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/password-recovery/{email}',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reset Password
|
|
*
|
|
* Reset password
|
|
*/
|
|
public static resetPassword<ThrowOnError extends boolean = true>(options: Options<loginResetPasswordData, ThrowOnError>) {
|
|
return (options.client ?? client).post<loginResetPasswordResponses, loginResetPasswordErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/reset-password/',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Recover Password Html Content
|
|
*
|
|
* HTML Content for Password Recovery
|
|
*/
|
|
public static recoverPasswordHtmlContent<ThrowOnError extends boolean = true>(options: Options<loginRecoverPasswordHtmlContentData, ThrowOnError>) {
|
|
return (options.client ?? client).post<loginRecoverPasswordHtmlContentResponses, loginRecoverPasswordHtmlContentErrors, ThrowOnError>({
|
|
responseType: 'text',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/password-recovery-html-content/{email}',
|
|
...options
|
|
});
|
|
}
|
|
}
|
|
|
|
export class UsersService {
|
|
/**
|
|
* Read Users
|
|
*
|
|
* Retrieve users.
|
|
*/
|
|
public static readUsers<ThrowOnError extends boolean = true>(options?: Options<usersReadUsersData, ThrowOnError>) {
|
|
return (options?.client ?? client).get<usersReadUsersResponses, usersReadUsersErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Create User
|
|
*
|
|
* Create new user.
|
|
*/
|
|
public static createUser<ThrowOnError extends boolean = true>(options: Options<usersCreateUserData, ThrowOnError>) {
|
|
return (options.client ?? client).post<usersCreateUserResponses, usersCreateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Delete User Me
|
|
*
|
|
* Delete own user.
|
|
*/
|
|
public static deleteUserMe<ThrowOnError extends boolean = true>(options?: Options<usersDeleteUserMeData, ThrowOnError>) {
|
|
return (options?.client ?? client).delete<usersDeleteUserMeResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/me',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Read User Me
|
|
*
|
|
* Get current user.
|
|
*/
|
|
public static readUserMe<ThrowOnError extends boolean = true>(options?: Options<usersReadUserMeData, ThrowOnError>) {
|
|
return (options?.client ?? client).get<usersReadUserMeResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/me',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Update User Me
|
|
*
|
|
* Update own user.
|
|
*/
|
|
public static updateUserMe<ThrowOnError extends boolean = true>(options: Options<usersUpdateUserMeData, ThrowOnError>) {
|
|
return (options.client ?? client).patch<usersUpdateUserMeResponses, usersUpdateUserMeErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/me',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Update Password Me
|
|
*
|
|
* Update own password.
|
|
*/
|
|
public static updatePasswordMe<ThrowOnError extends boolean = true>(options: Options<usersUpdatePasswordMeData, ThrowOnError>) {
|
|
return (options.client ?? client).patch<usersUpdatePasswordMeResponses, usersUpdatePasswordMeErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/me/password',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Register User
|
|
*
|
|
* Create new user without the need to be logged in.
|
|
*/
|
|
public static registerUser<ThrowOnError extends boolean = true>(options: Options<usersRegisterUserData, ThrowOnError>) {
|
|
return (options.client ?? client).post<usersRegisterUserResponses, usersRegisterUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/users/signup',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Delete User
|
|
*
|
|
* Delete a user.
|
|
*/
|
|
public static deleteUser<ThrowOnError extends boolean = true>(options: Options<usersDeleteUserData, ThrowOnError>) {
|
|
return (options.client ?? client).delete<usersDeleteUserResponses, usersDeleteUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/{user_id}',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Read User By Id
|
|
*
|
|
* Get a specific user by id.
|
|
*/
|
|
public static readUserById<ThrowOnError extends boolean = true>(options: Options<usersReadUserByIdData, ThrowOnError>) {
|
|
return (options.client ?? client).get<usersReadUserByIdResponses, usersReadUserByIdErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/{user_id}',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Update User
|
|
*
|
|
* Update a user.
|
|
*/
|
|
public static updateUser<ThrowOnError extends boolean = true>(options: Options<usersUpdateUserData, ThrowOnError>) {
|
|
return (options.client ?? client).patch<usersUpdateUserResponses, usersUpdateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/users/{user_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
export class UtilsService {
|
|
/**
|
|
* Test Email
|
|
*
|
|
* Test emails.
|
|
*/
|
|
public static testEmail<ThrowOnError extends boolean = true>(options: Options<utilsTestEmailData, ThrowOnError>) {
|
|
return (options.client ?? client).post<utilsTestEmailResponses, utilsTestEmailErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/utils/test-email/',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Health Check
|
|
*/
|
|
public static healthCheck<ThrowOnError extends boolean = true>(options?: Options<utilsHealthCheckData, ThrowOnError>) {
|
|
return (options?.client ?? client).get<utilsHealthCheckResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/utils/health-check/',
|
|
...options
|
|
});
|
|
}
|
|
}
|
|
|
|
export class ItemsService {
|
|
/**
|
|
* Read Items
|
|
*
|
|
* Retrieve items.
|
|
*/
|
|
public static readItems<ThrowOnError extends boolean = true>(options?: Options<itemsReadItemsData, ThrowOnError>) {
|
|
return (options?.client ?? client).get<itemsReadItemsResponses, itemsReadItemsErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/items/',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Create Item
|
|
*
|
|
* Create new item.
|
|
*/
|
|
public static createItem<ThrowOnError extends boolean = true>(options: Options<itemsCreateItemData, ThrowOnError>) {
|
|
return (options.client ?? client).post<itemsCreateItemResponses, itemsCreateItemErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/items/',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Delete Item
|
|
*
|
|
* Delete an item.
|
|
*/
|
|
public static deleteItem<ThrowOnError extends boolean = true>(options: Options<itemsDeleteItemData, ThrowOnError>) {
|
|
return (options.client ?? client).delete<itemsDeleteItemResponses, itemsDeleteItemErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/items/{id}',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Read Item
|
|
*
|
|
* Get item by ID.
|
|
*/
|
|
public static readItem<ThrowOnError extends boolean = true>(options: Options<itemsReadItemData, ThrowOnError>) {
|
|
return (options.client ?? client).get<itemsReadItemResponses, itemsReadItemErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/items/{id}',
|
|
...options
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Update Item
|
|
*
|
|
* Update an item.
|
|
*/
|
|
public static updateItem<ThrowOnError extends boolean = true>(options: Options<itemsUpdateItemData, ThrowOnError>) {
|
|
return (options.client ?? client).put<itemsUpdateItemResponses, itemsUpdateItemErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [{ scheme: 'bearer', type: 'http' }],
|
|
url: '/api/v1/items/{id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
export class PrivateService {
|
|
/**
|
|
* Create User
|
|
*
|
|
* Create a new user.
|
|
*/
|
|
public static createUser<ThrowOnError extends boolean = true>(options: Options<privateCreateUserData, ThrowOnError>) {
|
|
return (options.client ?? client).post<privateCreateUserResponses, privateCreateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/private/users/',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
}
|
|
}
|