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 { Injectable } from '@angular/core';
4
5import type { Client, Options as Options2, TDataShape } from './client';
6import { client } from './client.gen';
7import type {
8 AddPetData,
9 AddPetErrors,
10 AddPetResponses,
11 CreateUserData,
12 CreateUserErrors,
13 CreateUserResponses,
14 CreateUsersWithListInputData,
15 CreateUsersWithListInputErrors,
16 CreateUsersWithListInputResponses,
17 DeleteOrderData,
18 DeleteOrderErrors,
19 DeleteOrderResponses,
20 DeletePetData,
21 DeletePetErrors,
22 DeletePetResponses,
23 DeleteUserData,
24 DeleteUserErrors,
25 DeleteUserResponses,
26 FindPetsByStatusData,
27 FindPetsByStatusErrors,
28 FindPetsByStatusResponses,
29 FindPetsByTagsData,
30 FindPetsByTagsErrors,
31 FindPetsByTagsResponses,
32 GetInventoryData,
33 GetInventoryErrors,
34 GetInventoryResponses,
35 GetOrderByIdData,
36 GetOrderByIdErrors,
37 GetOrderByIdResponses,
38 GetPetByIdData,
39 GetPetByIdErrors,
40 GetPetByIdResponses,
41 GetUserByNameData,
42 GetUserByNameErrors,
43 GetUserByNameResponses,
44 LoginUserData,
45 LoginUserErrors,
46 LoginUserResponses,
47 LogoutUserData,
48 LogoutUserErrors,
49 LogoutUserResponses,
50 PlaceOrderData,
51 PlaceOrderErrors,
52 PlaceOrderResponses,
53 UpdatePetData,
54 UpdatePetErrors,
55 UpdatePetResponses,
56 UpdatePetWithFormData,
57 UpdatePetWithFormErrors,
58 UpdatePetWithFormResponses,
59 UpdateUserData,
60 UpdateUserErrors,
61 UpdateUserResponses,
62 UploadFileData,
63 UploadFileErrors,
64 UploadFileResponses,
65} from './types.gen';
66
67export type Options<
68 TData extends TDataShape = TDataShape,
69 ThrowOnError extends boolean = boolean,
70> = Options2<TData, ThrowOnError> & {
71 /**
72 * You can provide a client instance returned by `createClient()` instead of
73 * individual options. This might be also useful if you want to implement a
74 * custom client.
75 */
76 client?: Client;
77 /**
78 * You can pass arbitrary values through the `meta` object. This can be
79 * used to access values that aren't defined as part of the SDK function.
80 */
81 meta?: Record<string, unknown>;
82};
83
84@Injectable({ providedIn: 'root' })
85export class PetService {
86 /**
87 * Add a new pet to the store.
88 *
89 * Add a new pet to the store.
90 */
91 public addPet<ThrowOnError extends boolean = false>(
92 options: Options<AddPetData, ThrowOnError>,
93 ) {
94 return (options.client ?? client).post<
95 AddPetResponses,
96 AddPetErrors,
97 ThrowOnError
98 >({
99 security: [{ scheme: 'bearer', type: 'http' }],
100 url: '/pet',
101 ...options,
102 headers: {
103 'Content-Type': 'application/json',
104 ...options.headers,
105 },
106 });
107 }
108
109 /**
110 * Update an existing pet.
111 *
112 * Update an existing pet by Id.
113 */
114 public updatePet<ThrowOnError extends boolean = false>(
115 options: Options<UpdatePetData, ThrowOnError>,
116 ) {
117 return (options.client ?? client).put<
118 UpdatePetResponses,
119 UpdatePetErrors,
120 ThrowOnError
121 >({
122 security: [{ scheme: 'bearer', type: 'http' }],
123 url: '/pet',
124 ...options,
125 headers: {
126 'Content-Type': 'application/json',
127 ...options.headers,
128 },
129 });
130 }
131
132 /**
133 * Finds Pets by status.
134 *
135 * Multiple status values can be provided with comma separated strings.
136 */
137 public findPetsByStatus<ThrowOnError extends boolean = false>(
138 options: Options<FindPetsByStatusData, ThrowOnError>,
139 ) {
140 return (options.client ?? client).get<
141 FindPetsByStatusResponses,
142 FindPetsByStatusErrors,
143 ThrowOnError
144 >({
145 security: [{ scheme: 'bearer', type: 'http' }],
146 url: '/pet/findByStatus',
147 ...options,
148 });
149 }
150
151 /**
152 * Finds Pets by tags.
153 *
154 * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
155 */
156 public findPetsByTags<ThrowOnError extends boolean = false>(
157 options: Options<FindPetsByTagsData, ThrowOnError>,
158 ) {
159 return (options.client ?? client).get<
160 FindPetsByTagsResponses,
161 FindPetsByTagsErrors,
162 ThrowOnError
163 >({
164 security: [{ scheme: 'bearer', type: 'http' }],
165 url: '/pet/findByTags',
166 ...options,
167 });
168 }
169
170 /**
171 * Deletes a pet.
172 *
173 * Delete a pet.
174 */
175 public deletePet<ThrowOnError extends boolean = false>(
176 options: Options<DeletePetData, ThrowOnError>,
177 ) {
178 return (options.client ?? client).delete<
179 DeletePetResponses,
180 DeletePetErrors,
181 ThrowOnError
182 >({
183 security: [{ scheme: 'bearer', type: 'http' }],
184 url: '/pet/{petId}',
185 ...options,
186 });
187 }
188
189 /**
190 * Find pet by ID.
191 *
192 * Returns a single pet.
193 */
194 public getPetById<ThrowOnError extends boolean = false>(
195 options: Options<GetPetByIdData, ThrowOnError>,
196 ) {
197 return (options.client ?? client).get<
198 GetPetByIdResponses,
199 GetPetByIdErrors,
200 ThrowOnError
201 >({
202 security: [
203 { name: 'api_key', type: 'apiKey' },
204 { scheme: 'bearer', type: 'http' },
205 ],
206 url: '/pet/{petId}',
207 ...options,
208 });
209 }
210
211 /**
212 * Updates a pet in the store with form data.
213 *
214 * Updates a pet resource based on the form data.
215 */
216 public updatePetWithForm<ThrowOnError extends boolean = false>(
217 options: Options<UpdatePetWithFormData, ThrowOnError>,
218 ) {
219 return (options.client ?? client).post<
220 UpdatePetWithFormResponses,
221 UpdatePetWithFormErrors,
222 ThrowOnError
223 >({
224 security: [{ scheme: 'bearer', type: 'http' }],
225 url: '/pet/{petId}',
226 ...options,
227 });
228 }
229
230 /**
231 * Uploads an image.
232 *
233 * Upload image of the pet.
234 */
235 public uploadFile<ThrowOnError extends boolean = false>(
236 options: Options<UploadFileData, ThrowOnError>,
237 ) {
238 return (options.client ?? client).post<
239 UploadFileResponses,
240 UploadFileErrors,
241 ThrowOnError
242 >({
243 bodySerializer: null,
244 security: [{ scheme: 'bearer', type: 'http' }],
245 url: '/pet/{petId}/uploadImage',
246 ...options,
247 headers: {
248 'Content-Type': 'application/octet-stream',
249 ...options.headers,
250 },
251 });
252 }
253}
254
255@Injectable({ providedIn: 'root' })
256export class StoreService {
257 /**
258 * Returns pet inventories by status.
259 *
260 * Returns a map of status codes to quantities.
261 */
262 public getInventory<ThrowOnError extends boolean = false>(
263 options?: Options<GetInventoryData, ThrowOnError>,
264 ) {
265 return (options?.client ?? client).get<
266 GetInventoryResponses,
267 GetInventoryErrors,
268 ThrowOnError
269 >({
270 security: [{ name: 'api_key', type: 'apiKey' }],
271 url: '/store/inventory',
272 ...options,
273 });
274 }
275
276 /**
277 * Place an order for a pet.
278 *
279 * Place a new order in the store.
280 */
281 public placeOrder<ThrowOnError extends boolean = false>(
282 options?: Options<PlaceOrderData, ThrowOnError>,
283 ) {
284 return (options?.client ?? client).post<
285 PlaceOrderResponses,
286 PlaceOrderErrors,
287 ThrowOnError
288 >({
289 url: '/store/order',
290 ...options,
291 headers: {
292 'Content-Type': 'application/json',
293 ...options?.headers,
294 },
295 });
296 }
297
298 /**
299 * Delete purchase order by identifier.
300 *
301 * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
302 */
303 public deleteOrder<ThrowOnError extends boolean = false>(
304 options: Options<DeleteOrderData, ThrowOnError>,
305 ) {
306 return (options.client ?? client).delete<
307 DeleteOrderResponses,
308 DeleteOrderErrors,
309 ThrowOnError
310 >({ url: '/store/order/{orderId}', ...options });
311 }
312
313 /**
314 * Find purchase order by ID.
315 *
316 * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
317 */
318 public getOrderById<ThrowOnError extends boolean = false>(
319 options: Options<GetOrderByIdData, ThrowOnError>,
320 ) {
321 return (options.client ?? client).get<
322 GetOrderByIdResponses,
323 GetOrderByIdErrors,
324 ThrowOnError
325 >({ url: '/store/order/{orderId}', ...options });
326 }
327}
328
329@Injectable({ providedIn: 'root' })
330export class UserService {
331 /**
332 * Create user.
333 *
334 * This can only be done by the logged in user.
335 */
336 public createUser<ThrowOnError extends boolean = false>(
337 options?: Options<CreateUserData, ThrowOnError>,
338 ) {
339 return (options?.client ?? client).post<
340 CreateUserResponses,
341 CreateUserErrors,
342 ThrowOnError
343 >({
344 url: '/user',
345 ...options,
346 headers: {
347 'Content-Type': 'application/json',
348 ...options?.headers,
349 },
350 });
351 }
352
353 /**
354 * Creates list of users with given input array.
355 *
356 * Creates list of users with given input array.
357 */
358 public createUsersWithListInput<ThrowOnError extends boolean = false>(
359 options?: Options<CreateUsersWithListInputData, ThrowOnError>,
360 ) {
361 return (options?.client ?? client).post<
362 CreateUsersWithListInputResponses,
363 CreateUsersWithListInputErrors,
364 ThrowOnError
365 >({
366 url: '/user/createWithList',
367 ...options,
368 headers: {
369 'Content-Type': 'application/json',
370 ...options?.headers,
371 },
372 });
373 }
374
375 /**
376 * Logs user into the system.
377 *
378 * Log into the system.
379 */
380 public loginUser<ThrowOnError extends boolean = false>(
381 options?: Options<LoginUserData, ThrowOnError>,
382 ) {
383 return (options?.client ?? client).get<
384 LoginUserResponses,
385 LoginUserErrors,
386 ThrowOnError
387 >({ url: '/user/login', ...options });
388 }
389
390 /**
391 * Logs out current logged in user session.
392 *
393 * Log user out of the system.
394 */
395 public logoutUser<ThrowOnError extends boolean = false>(
396 options?: Options<LogoutUserData, ThrowOnError>,
397 ) {
398 return (options?.client ?? client).get<
399 LogoutUserResponses,
400 LogoutUserErrors,
401 ThrowOnError
402 >({ url: '/user/logout', ...options });
403 }
404
405 /**
406 * Delete user resource.
407 *
408 * This can only be done by the logged in user.
409 */
410 public deleteUser<ThrowOnError extends boolean = false>(
411 options: Options<DeleteUserData, ThrowOnError>,
412 ) {
413 return (options.client ?? client).delete<
414 DeleteUserResponses,
415 DeleteUserErrors,
416 ThrowOnError
417 >({ url: '/user/{username}', ...options });
418 }
419
420 /**
421 * Get user by user name.
422 *
423 * Get user detail based on username.
424 */
425 public getUserByName<ThrowOnError extends boolean = false>(
426 options: Options<GetUserByNameData, ThrowOnError>,
427 ) {
428 return (options.client ?? client).get<
429 GetUserByNameResponses,
430 GetUserByNameErrors,
431 ThrowOnError
432 >({ url: '/user/{username}', ...options });
433 }
434
435 /**
436 * Update user resource.
437 *
438 * This can only be done by the logged in user.
439 */
440 public updateUser<ThrowOnError extends boolean = false>(
441 options: Options<UpdateUserData, ThrowOnError>,
442 ) {
443 return (options.client ?? client).put<
444 UpdateUserResponses,
445 UpdateUserErrors,
446 ThrowOnError
447 >({
448 url: '/user/{username}',
449 ...options,
450 headers: {
451 'Content-Type': 'application/json',
452 ...options.headers,
453 },
454 });
455 }
456}