// This file is auto-generated by @hey-api/openapi-ts import { type HttpRequest, httpResource } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { client } from '../client.gen'; import type { Options } from '../sdk.gen'; import type { AddPetData, AddPetResponse, CreateUserData, CreateUserResponse, CreateUsersWithListInputData, CreateUsersWithListInputResponse, DeleteOrderData, DeletePetData, DeleteUserData, FindPetsByStatusData, FindPetsByStatusResponse, FindPetsByTagsData, FindPetsByTagsResponse, GetInventoryData, GetInventoryResponse, GetOrderByIdData, GetOrderByIdResponse, GetPetByIdData, GetPetByIdResponse, GetUserByNameData, GetUserByNameResponse, LoginUserData, LoginUserResponse, LogoutUserData, PlaceOrderData, PlaceOrderResponse, UpdatePetData, UpdatePetResponse, UpdatePetWithFormData, UpdatePetWithFormResponse, UpdateUserData, UploadFileData, UploadFileResponse, } from '../types.gen'; /** * Add a new pet to the store. * * Add a new pet to the store. */ export const addPetRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'POST', responseStyle: 'data', url: '/pet', ...options, }); /** * Update an existing pet. * * Update an existing pet by Id. */ export const updatePetRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'PUT', responseStyle: 'data', url: '/pet', ...options, }); /** * Finds Pets by status. * * Multiple status values can be provided with comma separated strings. */ export const findPetsByStatusRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/pet/findByStatus', ...options, }); /** * Finds Pets by tags. * * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. */ export const findPetsByTagsRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/pet/findByTags', ...options, }); /** * Deletes a pet. * * Delete a pet. */ export const deletePetRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'DELETE', responseStyle: 'data', url: '/pet/{petId}', ...options, }); /** * Find pet by ID. * * Returns a single pet. */ export const getPetByIdRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/pet/{petId}', ...options, }); /** * Updates a pet in the store with form data. * * Updates a pet resource based on the form data. */ export const updatePetWithFormRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'POST', responseStyle: 'data', url: '/pet/{petId}', ...options, }); /** * Uploads an image. * * Upload image of the pet. */ export const uploadFileRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'POST', responseStyle: 'data', url: '/pet/{petId}/uploadImage', ...options, }); /** * Returns pet inventories by status. * * Returns a map of status codes to quantities. */ export const getInventoryRequest = ( options?: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/store/inventory', ...options, }); /** * Place an order for a pet. * * Place a new order in the store. */ export const placeOrderRequest = ( options?: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'POST', responseStyle: 'data', url: '/store/order', ...options, }); /** * Delete purchase order by identifier. * * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. */ export const deleteOrderRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'DELETE', responseStyle: 'data', url: '/store/order/{orderId}', ...options, }); /** * Find purchase order by ID. * * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. */ export const getOrderByIdRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/store/order/{orderId}', ...options, }); /** * Create user. * * This can only be done by the logged in user. */ export const createUserRequest = ( options?: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'POST', responseStyle: 'data', url: '/user', ...options, }); /** * Creates list of users with given input array. * * Creates list of users with given input array. */ export const createUsersWithListInputRequest = < ThrowOnError extends boolean = false, >( options?: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'POST', responseStyle: 'data', url: '/user/createWithList', ...options, }); /** * Logs user into the system. * * Log into the system. */ export const loginUserRequest = ( options?: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/user/login', ...options, }); /** * Logs out current logged in user session. * * Log user out of the system. */ export const logoutUserRequest = ( options?: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/user/logout', ...options, }); /** * Delete user resource. * * This can only be done by the logged in user. */ export const deleteUserRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'DELETE', responseStyle: 'data', url: '/user/{username}', ...options, }); /** * Get user by user name. * * Get user detail based on username. */ export const getUserByNameRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'GET', responseStyle: 'data', url: '/user/{username}', ...options, }); /** * Update user resource. * * This can only be done by the logged in user. */ export const updateUserRequest = ( options: Options, ): HttpRequest => (options?.client ?? client).requestOptions({ method: 'PUT', responseStyle: 'data', url: '/user/{username}', ...options, }); @Injectable({ providedIn: 'root' }) export class PetServiceResources { /** * Add a new pet to the store. * * Add a new pet to the store. */ public addPet( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? addPetRequest(opts) : undefined; }); } /** * Update an existing pet. * * Update an existing pet by Id. */ public updatePet( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? updatePetRequest(opts) : undefined; }); } /** * Finds Pets by status. * * Multiple status values can be provided with comma separated strings. */ public findPetsByStatus( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? findPetsByStatusRequest(opts) : undefined; }); } /** * Finds Pets by tags. * * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. */ public findPetsByTags( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? findPetsByTagsRequest(opts) : undefined; }); } /** * Deletes a pet. * * Delete a pet. */ public deletePet( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? deletePetRequest(opts) : undefined; }); } /** * Find pet by ID. * * Returns a single pet. */ public getPetById( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? getPetByIdRequest(opts) : undefined; }); } /** * Updates a pet in the store with form data. * * Updates a pet resource based on the form data. */ public updatePetWithForm( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? updatePetWithFormRequest(opts) : undefined; }); } /** * Uploads an image. * * Upload image of the pet. */ public uploadFile( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? uploadFileRequest(opts) : undefined; }); } } @Injectable({ providedIn: 'root' }) export class StoreServiceResources { /** * Returns pet inventories by status. * * Returns a map of status codes to quantities. */ public getInventory( options?: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? getInventoryRequest(opts) : undefined; }); } /** * Place an order for a pet. * * Place a new order in the store. */ public placeOrder( options?: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? placeOrderRequest(opts) : undefined; }); } /** * Delete purchase order by identifier. * * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. */ public deleteOrder( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? deleteOrderRequest(opts) : undefined; }); } /** * Find purchase order by ID. * * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. */ public getOrderById( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? getOrderByIdRequest(opts) : undefined; }); } } @Injectable({ providedIn: 'root' }) export class UserServiceResources { /** * Create user. * * This can only be done by the logged in user. */ public createUser( options?: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? createUserRequest(opts) : undefined; }); } /** * Creates list of users with given input array. * * Creates list of users with given input array. */ public createUsersWithListInput( options?: () => | Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? createUsersWithListInputRequest(opts) : undefined; }); } /** * Logs user into the system. * * Log into the system. */ public loginUser( options?: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? loginUserRequest(opts) : undefined; }); } /** * Logs out current logged in user session. * * Log user out of the system. */ public logoutUser( options?: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? logoutUserRequest(opts) : undefined; }); } /** * Delete user resource. * * This can only be done by the logged in user. */ public deleteUser( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? deleteUserRequest(opts) : undefined; }); } /** * Get user by user name. * * Get user detail based on username. */ public getUserByName( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? getUserByNameRequest(opts) : undefined; }); } /** * Update user resource. * * This can only be done by the logged in user. */ public updateUser( options: () => Options | undefined, ) { return httpResource(() => { const opts = options ? options() : undefined; return opts ? updateUserRequest(opts) : undefined; }); } }