fork of hey-api/openapi-ts because I need some additional things
1// This file is auto-generated by @hey-api/openapi-ts
2
3import { type HttpRequest, httpResource } from '@angular/common/http';
4import { Injectable } from '@angular/core';
5
6import { client } from '../client.gen';
7import type { Options } from '../sdk.gen';
8import type {
9 AddPetData,
10 AddPetResponse,
11 CreateUserData,
12 CreateUserResponse,
13 CreateUsersWithListInputData,
14 CreateUsersWithListInputResponse,
15 DeleteOrderData,
16 DeletePetData,
17 DeleteUserData,
18 FindPetsByStatusData,
19 FindPetsByStatusResponse,
20 FindPetsByTagsData,
21 FindPetsByTagsResponse,
22 GetInventoryData,
23 GetInventoryResponse,
24 GetOrderByIdData,
25 GetOrderByIdResponse,
26 GetPetByIdData,
27 GetPetByIdResponse,
28 GetUserByNameData,
29 GetUserByNameResponse,
30 LoginUserData,
31 LoginUserResponse,
32 LogoutUserData,
33 PlaceOrderData,
34 PlaceOrderResponse,
35 UpdatePetData,
36 UpdatePetResponse,
37 UpdatePetWithFormData,
38 UpdatePetWithFormResponse,
39 UpdateUserData,
40 UploadFileData,
41 UploadFileResponse,
42} from '../types.gen';
43
44/**
45 * Add a new pet to the store.
46 *
47 * Add a new pet to the store.
48 */
49export const addPetRequest = <ThrowOnError extends boolean = false>(
50 options: Options<AddPetData, ThrowOnError>,
51): HttpRequest<unknown> =>
52 (options?.client ?? client).requestOptions({
53 method: 'POST',
54 responseStyle: 'data',
55 url: '/pet',
56 ...options,
57 });
58
59/**
60 * Update an existing pet.
61 *
62 * Update an existing pet by Id.
63 */
64export const updatePetRequest = <ThrowOnError extends boolean = false>(
65 options: Options<UpdatePetData, ThrowOnError>,
66): HttpRequest<unknown> =>
67 (options?.client ?? client).requestOptions({
68 method: 'PUT',
69 responseStyle: 'data',
70 url: '/pet',
71 ...options,
72 });
73
74/**
75 * Finds Pets by status.
76 *
77 * Multiple status values can be provided with comma separated strings.
78 */
79export const findPetsByStatusRequest = <ThrowOnError extends boolean = false>(
80 options: Options<FindPetsByStatusData, ThrowOnError>,
81): HttpRequest<unknown> =>
82 (options?.client ?? client).requestOptions({
83 method: 'GET',
84 responseStyle: 'data',
85 url: '/pet/findByStatus',
86 ...options,
87 });
88
89/**
90 * Finds Pets by tags.
91 *
92 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
93 */
94export const findPetsByTagsRequest = <ThrowOnError extends boolean = false>(
95 options: Options<FindPetsByTagsData, ThrowOnError>,
96): HttpRequest<unknown> =>
97 (options?.client ?? client).requestOptions({
98 method: 'GET',
99 responseStyle: 'data',
100 url: '/pet/findByTags',
101 ...options,
102 });
103
104/**
105 * Deletes a pet.
106 *
107 * Delete a pet.
108 */
109export const deletePetRequest = <ThrowOnError extends boolean = false>(
110 options: Options<DeletePetData, ThrowOnError>,
111): HttpRequest<unknown> =>
112 (options?.client ?? client).requestOptions({
113 method: 'DELETE',
114 responseStyle: 'data',
115 url: '/pet/{petId}',
116 ...options,
117 });
118
119/**
120 * Find pet by ID.
121 *
122 * Returns a single pet.
123 */
124export const getPetByIdRequest = <ThrowOnError extends boolean = false>(
125 options: Options<GetPetByIdData, ThrowOnError>,
126): HttpRequest<unknown> =>
127 (options?.client ?? client).requestOptions({
128 method: 'GET',
129 responseStyle: 'data',
130 url: '/pet/{petId}',
131 ...options,
132 });
133
134/**
135 * Updates a pet in the store with form data.
136 *
137 * Updates a pet resource based on the form data.
138 */
139export const updatePetWithFormRequest = <ThrowOnError extends boolean = false>(
140 options: Options<UpdatePetWithFormData, ThrowOnError>,
141): HttpRequest<unknown> =>
142 (options?.client ?? client).requestOptions({
143 method: 'POST',
144 responseStyle: 'data',
145 url: '/pet/{petId}',
146 ...options,
147 });
148
149/**
150 * Uploads an image.
151 *
152 * Upload image of the pet.
153 */
154export const uploadFileRequest = <ThrowOnError extends boolean = false>(
155 options: Options<UploadFileData, ThrowOnError>,
156): HttpRequest<unknown> =>
157 (options?.client ?? client).requestOptions({
158 method: 'POST',
159 responseStyle: 'data',
160 url: '/pet/{petId}/uploadImage',
161 ...options,
162 });
163
164/**
165 * Returns pet inventories by status.
166 *
167 * Returns a map of status codes to quantities.
168 */
169export const getInventoryRequest = <ThrowOnError extends boolean = false>(
170 options?: Options<GetInventoryData, ThrowOnError>,
171): HttpRequest<unknown> =>
172 (options?.client ?? client).requestOptions({
173 method: 'GET',
174 responseStyle: 'data',
175 url: '/store/inventory',
176 ...options,
177 });
178
179/**
180 * Place an order for a pet.
181 *
182 * Place a new order in the store.
183 */
184export const placeOrderRequest = <ThrowOnError extends boolean = false>(
185 options?: Options<PlaceOrderData, ThrowOnError>,
186): HttpRequest<unknown> =>
187 (options?.client ?? client).requestOptions({
188 method: 'POST',
189 responseStyle: 'data',
190 url: '/store/order',
191 ...options,
192 });
193
194/**
195 * Delete purchase order by identifier.
196 *
197 * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
198 */
199export const deleteOrderRequest = <ThrowOnError extends boolean = false>(
200 options: Options<DeleteOrderData, ThrowOnError>,
201): HttpRequest<unknown> =>
202 (options?.client ?? client).requestOptions({
203 method: 'DELETE',
204 responseStyle: 'data',
205 url: '/store/order/{orderId}',
206 ...options,
207 });
208
209/**
210 * Find purchase order by ID.
211 *
212 * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
213 */
214export const getOrderByIdRequest = <ThrowOnError extends boolean = false>(
215 options: Options<GetOrderByIdData, ThrowOnError>,
216): HttpRequest<unknown> =>
217 (options?.client ?? client).requestOptions({
218 method: 'GET',
219 responseStyle: 'data',
220 url: '/store/order/{orderId}',
221 ...options,
222 });
223
224/**
225 * Create user.
226 *
227 * This can only be done by the logged in user.
228 */
229export const createUserRequest = <ThrowOnError extends boolean = false>(
230 options?: Options<CreateUserData, ThrowOnError>,
231): HttpRequest<unknown> =>
232 (options?.client ?? client).requestOptions({
233 method: 'POST',
234 responseStyle: 'data',
235 url: '/user',
236 ...options,
237 });
238
239/**
240 * Creates list of users with given input array.
241 *
242 * Creates list of users with given input array.
243 */
244export const createUsersWithListInputRequest = <
245 ThrowOnError extends boolean = false,
246>(
247 options?: Options<CreateUsersWithListInputData, ThrowOnError>,
248): HttpRequest<unknown> =>
249 (options?.client ?? client).requestOptions({
250 method: 'POST',
251 responseStyle: 'data',
252 url: '/user/createWithList',
253 ...options,
254 });
255
256/**
257 * Logs user into the system.
258 *
259 * Log into the system.
260 */
261export const loginUserRequest = <ThrowOnError extends boolean = false>(
262 options?: Options<LoginUserData, ThrowOnError>,
263): HttpRequest<unknown> =>
264 (options?.client ?? client).requestOptions({
265 method: 'GET',
266 responseStyle: 'data',
267 url: '/user/login',
268 ...options,
269 });
270
271/**
272 * Logs out current logged in user session.
273 *
274 * Log user out of the system.
275 */
276export const logoutUserRequest = <ThrowOnError extends boolean = false>(
277 options?: Options<LogoutUserData, ThrowOnError>,
278): HttpRequest<unknown> =>
279 (options?.client ?? client).requestOptions({
280 method: 'GET',
281 responseStyle: 'data',
282 url: '/user/logout',
283 ...options,
284 });
285
286/**
287 * Delete user resource.
288 *
289 * This can only be done by the logged in user.
290 */
291export const deleteUserRequest = <ThrowOnError extends boolean = false>(
292 options: Options<DeleteUserData, ThrowOnError>,
293): HttpRequest<unknown> =>
294 (options?.client ?? client).requestOptions({
295 method: 'DELETE',
296 responseStyle: 'data',
297 url: '/user/{username}',
298 ...options,
299 });
300
301/**
302 * Get user by user name.
303 *
304 * Get user detail based on username.
305 */
306export const getUserByNameRequest = <ThrowOnError extends boolean = false>(
307 options: Options<GetUserByNameData, ThrowOnError>,
308): HttpRequest<unknown> =>
309 (options?.client ?? client).requestOptions({
310 method: 'GET',
311 responseStyle: 'data',
312 url: '/user/{username}',
313 ...options,
314 });
315
316/**
317 * Update user resource.
318 *
319 * This can only be done by the logged in user.
320 */
321export const updateUserRequest = <ThrowOnError extends boolean = false>(
322 options: Options<UpdateUserData, ThrowOnError>,
323): HttpRequest<unknown> =>
324 (options?.client ?? client).requestOptions({
325 method: 'PUT',
326 responseStyle: 'data',
327 url: '/user/{username}',
328 ...options,
329 });
330
331@Injectable({ providedIn: 'root' })
332export class PetServiceResources {
333 /**
334 * Add a new pet to the store.
335 *
336 * Add a new pet to the store.
337 */
338 public addPet<ThrowOnError extends boolean = false>(
339 options: () => Options<AddPetData, ThrowOnError> | undefined,
340 ) {
341 return httpResource<AddPetResponse>(() => {
342 const opts = options ? options() : undefined;
343 return opts ? addPetRequest(opts) : undefined;
344 });
345 }
346
347 /**
348 * Update an existing pet.
349 *
350 * Update an existing pet by Id.
351 */
352 public updatePet<ThrowOnError extends boolean = false>(
353 options: () => Options<UpdatePetData, ThrowOnError> | undefined,
354 ) {
355 return httpResource<UpdatePetResponse>(() => {
356 const opts = options ? options() : undefined;
357 return opts ? updatePetRequest(opts) : undefined;
358 });
359 }
360
361 /**
362 * Finds Pets by status.
363 *
364 * Multiple status values can be provided with comma separated strings.
365 */
366 public findPetsByStatus<ThrowOnError extends boolean = false>(
367 options: () => Options<FindPetsByStatusData, ThrowOnError> | undefined,
368 ) {
369 return httpResource<FindPetsByStatusResponse>(() => {
370 const opts = options ? options() : undefined;
371 return opts ? findPetsByStatusRequest(opts) : undefined;
372 });
373 }
374
375 /**
376 * Finds Pets by tags.
377 *
378 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
379 */
380 public findPetsByTags<ThrowOnError extends boolean = false>(
381 options: () => Options<FindPetsByTagsData, ThrowOnError> | undefined,
382 ) {
383 return httpResource<FindPetsByTagsResponse>(() => {
384 const opts = options ? options() : undefined;
385 return opts ? findPetsByTagsRequest(opts) : undefined;
386 });
387 }
388
389 /**
390 * Deletes a pet.
391 *
392 * Delete a pet.
393 */
394 public deletePet<ThrowOnError extends boolean = false>(
395 options: () => Options<DeletePetData, ThrowOnError> | undefined,
396 ) {
397 return httpResource<unknown>(() => {
398 const opts = options ? options() : undefined;
399 return opts ? deletePetRequest(opts) : undefined;
400 });
401 }
402
403 /**
404 * Find pet by ID.
405 *
406 * Returns a single pet.
407 */
408 public getPetById<ThrowOnError extends boolean = false>(
409 options: () => Options<GetPetByIdData, ThrowOnError> | undefined,
410 ) {
411 return httpResource<GetPetByIdResponse>(() => {
412 const opts = options ? options() : undefined;
413 return opts ? getPetByIdRequest(opts) : undefined;
414 });
415 }
416
417 /**
418 * Updates a pet in the store with form data.
419 *
420 * Updates a pet resource based on the form data.
421 */
422 public updatePetWithForm<ThrowOnError extends boolean = false>(
423 options: () => Options<UpdatePetWithFormData, ThrowOnError> | undefined,
424 ) {
425 return httpResource<UpdatePetWithFormResponse>(() => {
426 const opts = options ? options() : undefined;
427 return opts ? updatePetWithFormRequest(opts) : undefined;
428 });
429 }
430
431 /**
432 * Uploads an image.
433 *
434 * Upload image of the pet.
435 */
436 public uploadFile<ThrowOnError extends boolean = false>(
437 options: () => Options<UploadFileData, ThrowOnError> | undefined,
438 ) {
439 return httpResource<UploadFileResponse>(() => {
440 const opts = options ? options() : undefined;
441 return opts ? uploadFileRequest(opts) : undefined;
442 });
443 }
444}
445
446@Injectable({ providedIn: 'root' })
447export class StoreServiceResources {
448 /**
449 * Returns pet inventories by status.
450 *
451 * Returns a map of status codes to quantities.
452 */
453 public getInventory<ThrowOnError extends boolean = false>(
454 options?: () => Options<GetInventoryData, ThrowOnError> | undefined,
455 ) {
456 return httpResource<GetInventoryResponse>(() => {
457 const opts = options ? options() : undefined;
458 return opts ? getInventoryRequest(opts) : undefined;
459 });
460 }
461
462 /**
463 * Place an order for a pet.
464 *
465 * Place a new order in the store.
466 */
467 public placeOrder<ThrowOnError extends boolean = false>(
468 options?: () => Options<PlaceOrderData, ThrowOnError> | undefined,
469 ) {
470 return httpResource<PlaceOrderResponse>(() => {
471 const opts = options ? options() : undefined;
472 return opts ? placeOrderRequest(opts) : undefined;
473 });
474 }
475
476 /**
477 * Delete purchase order by identifier.
478 *
479 * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
480 */
481 public deleteOrder<ThrowOnError extends boolean = false>(
482 options: () => Options<DeleteOrderData, ThrowOnError> | undefined,
483 ) {
484 return httpResource<unknown>(() => {
485 const opts = options ? options() : undefined;
486 return opts ? deleteOrderRequest(opts) : undefined;
487 });
488 }
489
490 /**
491 * Find purchase order by ID.
492 *
493 * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
494 */
495 public getOrderById<ThrowOnError extends boolean = false>(
496 options: () => Options<GetOrderByIdData, ThrowOnError> | undefined,
497 ) {
498 return httpResource<GetOrderByIdResponse>(() => {
499 const opts = options ? options() : undefined;
500 return opts ? getOrderByIdRequest(opts) : undefined;
501 });
502 }
503}
504
505@Injectable({ providedIn: 'root' })
506export class UserServiceResources {
507 /**
508 * Create user.
509 *
510 * This can only be done by the logged in user.
511 */
512 public createUser<ThrowOnError extends boolean = false>(
513 options?: () => Options<CreateUserData, ThrowOnError> | undefined,
514 ) {
515 return httpResource<CreateUserResponse>(() => {
516 const opts = options ? options() : undefined;
517 return opts ? createUserRequest(opts) : undefined;
518 });
519 }
520
521 /**
522 * Creates list of users with given input array.
523 *
524 * Creates list of users with given input array.
525 */
526 public createUsersWithListInput<ThrowOnError extends boolean = false>(
527 options?: () =>
528 | Options<CreateUsersWithListInputData, ThrowOnError>
529 | undefined,
530 ) {
531 return httpResource<CreateUsersWithListInputResponse>(() => {
532 const opts = options ? options() : undefined;
533 return opts ? createUsersWithListInputRequest(opts) : undefined;
534 });
535 }
536
537 /**
538 * Logs user into the system.
539 *
540 * Log into the system.
541 */
542 public loginUser<ThrowOnError extends boolean = false>(
543 options?: () => Options<LoginUserData, ThrowOnError> | undefined,
544 ) {
545 return httpResource<LoginUserResponse>(() => {
546 const opts = options ? options() : undefined;
547 return opts ? loginUserRequest(opts) : undefined;
548 });
549 }
550
551 /**
552 * Logs out current logged in user session.
553 *
554 * Log user out of the system.
555 */
556 public logoutUser<ThrowOnError extends boolean = false>(
557 options?: () => Options<LogoutUserData, ThrowOnError> | undefined,
558 ) {
559 return httpResource<unknown>(() => {
560 const opts = options ? options() : undefined;
561 return opts ? logoutUserRequest(opts) : undefined;
562 });
563 }
564
565 /**
566 * Delete user resource.
567 *
568 * This can only be done by the logged in user.
569 */
570 public deleteUser<ThrowOnError extends boolean = false>(
571 options: () => Options<DeleteUserData, ThrowOnError> | undefined,
572 ) {
573 return httpResource<unknown>(() => {
574 const opts = options ? options() : undefined;
575 return opts ? deleteUserRequest(opts) : undefined;
576 });
577 }
578
579 /**
580 * Get user by user name.
581 *
582 * Get user detail based on username.
583 */
584 public getUserByName<ThrowOnError extends boolean = false>(
585 options: () => Options<GetUserByNameData, ThrowOnError> | undefined,
586 ) {
587 return httpResource<GetUserByNameResponse>(() => {
588 const opts = options ? options() : undefined;
589 return opts ? getUserByNameRequest(opts) : undefined;
590 });
591 }
592
593 /**
594 * Update user resource.
595 *
596 * This can only be done by the logged in user.
597 */
598 public updateUser<ThrowOnError extends boolean = false>(
599 options: () => Options<UpdateUserData, ThrowOnError> | undefined,
600 ) {
601 return httpResource<unknown>(() => {
602 const opts = options ? options() : undefined;
603 return opts ? updateUserRequest(opts) : undefined;
604 });
605 }
606}