fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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