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