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