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