11
11
*/
12
12
/* tslint:disable:no-unused-variable member-ordering */
13
13
14
- import { HttpService , Inject , Injectable , Optional } from '@nestjs/common' ;
15
- import { AxiosResponse } from 'axios' ;
14
+ import { Inject , Injectable , Optional } from '@nestjs/common' ;
15
+ import { HttpService } from '@nestjs/axios' ;
16
+ import { AxiosResponse , AxiosRequestHeaders } from 'axios' ;
16
17
import { Observable } from 'rxjs' ;
17
18
import { ApiResponse } from '../model/apiResponse' ;
18
19
import { Pet } from '../model/pet' ;
19
20
import { Configuration } from '../configuration' ;
20
21
21
-
22
+ type addPetParams = {
23
+ pet : Pet ,
24
+ }
25
+ type deletePetParams = {
26
+ petId : number ,
27
+ apiKey ?: string ,
28
+ }
29
+ type findPetsByStatusParams = {
30
+ status : Array < 'available' | 'pending' | 'sold' > ,
31
+ }
32
+ type findPetsByTagsParams = {
33
+ tags : Array < string > ,
34
+ }
35
+ type getPetByIdParams = {
36
+ petId : number ,
37
+ }
38
+ type updatePetParams = {
39
+ pet : Pet ,
40
+ }
41
+ type updatePetWithFormParams = {
42
+ petId : number ,
43
+ name ?: string ,
44
+ status ?: string ,
45
+ }
46
+ type uploadFileParams = {
47
+ petId : number ,
48
+ additionalMetadata ?: string ,
49
+ file ?: Blob ,
50
+ }
22
51
@Injectable ( )
23
52
export class PetService {
24
53
25
54
protected basePath = 'http://petstore.swagger.io/v2' ;
26
- public defaultHeaders = new Map ( )
55
+ public defaultHeaders : Record < string , string > = { } ;
27
56
public configuration = new Configuration ( ) ;
28
57
29
58
constructor ( protected httpClient : HttpService , @Optional ( ) configuration : Configuration ) {
@@ -43,15 +72,15 @@ export class PetService {
43
72
/**
44
73
* Add a new pet to the store
45
74
*
46
- * @param pet Pet object that needs to be added to the store
75
+ * @param addPetParams
47
76
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
48
77
* @param reportProgress flag to report request and response progress.
49
78
*/
50
- public addPet ( pet : Pet , ) : Observable < AxiosResponse < Pet > > ;
51
- public addPet ( pet : Pet , ) : Observable < any > {
79
+ public addPet ( params : addPetParams ) : Observable < AxiosResponse < Pet > > ;
80
+ public addPet ( params : addPetParams ) : Observable < any > {
52
81
53
- if ( pet === null || pet === undefined ) {
54
- throw new Error ( 'Required parameter pet was null or undefined when calling addPet.' ) ;
82
+ if ( params . pet === null || params . pet === undefined ) {
83
+ throw new Error ( 'Required parameter params. pet was null or undefined when calling addPet.' ) ;
55
84
}
56
85
57
86
let headers = this . defaultHeaders ;
@@ -84,7 +113,7 @@ export class PetService {
84
113
headers [ 'Content-Type' ] = httpContentTypeSelected ;
85
114
}
86
115
return this . httpClient . post < Pet > ( `${ this . basePath } /pet` ,
87
- pet ,
116
+ params . pet ,
88
117
{
89
118
withCredentials : this . configuration . withCredentials ,
90
119
headers : headers
@@ -94,22 +123,21 @@ export class PetService {
94
123
/**
95
124
* Deletes a pet
96
125
*
97
- * @param petId Pet id to delete
98
- * @param apiKey
126
+ * @param deletePetParams
99
127
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
100
128
* @param reportProgress flag to report request and response progress.
101
129
*/
102
- public deletePet ( petId : number , apiKey ?: string , ) : Observable < AxiosResponse < any > > ;
103
- public deletePet ( petId : number , apiKey ?: string , ) : Observable < any > {
130
+ public deletePet ( params : deletePetParams ) : Observable < AxiosResponse < any > > ;
131
+ public deletePet ( params : deletePetParams ) : Observable < any > {
104
132
105
- if ( petId === null || petId === undefined ) {
106
- throw new Error ( 'Required parameter petId was null or undefined when calling deletePet.' ) ;
133
+ if ( params . petId === null || params . petId === undefined ) {
134
+ throw new Error ( 'Required parameter params. petId was null or undefined when calling deletePet.' ) ;
107
135
}
108
136
109
137
110
138
let headers = this . defaultHeaders ;
111
- if ( apiKey !== undefined && apiKey !== null ) {
112
- headers [ 'api_key' ] = String ( apiKey ) ;
139
+ if ( params . apiKey !== undefined && params . apiKey !== null ) {
140
+ headers [ 'api_key' ] = String ( params . apiKey ) ;
113
141
}
114
142
115
143
// authentication (petstore_auth) required
@@ -131,7 +159,7 @@ export class PetService {
131
159
// to determine the Content-Type header
132
160
const consumes : string [ ] = [
133
161
] ;
134
- return this . httpClient . delete < any > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` ,
162
+ return this . httpClient . delete < any > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( params . petId ) ) } ` ,
135
163
{
136
164
withCredentials : this . configuration . withCredentials ,
137
165
headers : headers
@@ -141,20 +169,20 @@ export class PetService {
141
169
/**
142
170
* Finds Pets by status
143
171
* Multiple status values can be provided with comma separated strings
144
- * @param status Status values that need to be considered for filter
172
+ * @param findPetsByStatusParams
145
173
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
146
174
* @param reportProgress flag to report request and response progress.
147
175
*/
148
- public findPetsByStatus ( status : Array < 'available' | 'pending' | 'sold' > , ) : Observable < AxiosResponse < Array < Pet > > > ;
149
- public findPetsByStatus ( status : Array < 'available' | 'pending' | 'sold' > , ) : Observable < any > {
176
+ public findPetsByStatus ( params : findPetsByStatusParams ) : Observable < AxiosResponse < Array < Pet > > > ;
177
+ public findPetsByStatus ( params : findPetsByStatusParams ) : Observable < any > {
150
178
151
- if ( status === null || status === undefined ) {
152
- throw new Error ( 'Required parameter status was null or undefined when calling findPetsByStatus.' ) ;
179
+ if ( params . status === null || params . status === undefined ) {
180
+ throw new Error ( 'Required parameter params. status was null or undefined when calling findPetsByStatus.' ) ;
153
181
}
154
182
155
183
let queryParameters = { } ;
156
- if ( status !== undefined && status !== null ) {
157
- queryParameters [ 'status' ] = < any > status ;
184
+ if ( params . status !== undefined && params . status !== null ) {
185
+ queryParameters [ 'status' ] = < any > params . status ;
158
186
}
159
187
160
188
let headers = this . defaultHeaders ;
@@ -191,20 +219,20 @@ export class PetService {
191
219
/**
192
220
* Finds Pets by tags
193
221
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
194
- * @param tags Tags to filter by
222
+ * @param findPetsByTagsParams
195
223
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
196
224
* @param reportProgress flag to report request and response progress.
197
225
*/
198
- public findPetsByTags ( tags : Array < string > , ) : Observable < AxiosResponse < Array < Pet > > > ;
199
- public findPetsByTags ( tags : Array < string > , ) : Observable < any > {
226
+ public findPetsByTags ( params : findPetsByTagsParams ) : Observable < AxiosResponse < Array < Pet > > > ;
227
+ public findPetsByTags ( params : findPetsByTagsParams ) : Observable < any > {
200
228
201
- if ( tags === null || tags === undefined ) {
202
- throw new Error ( 'Required parameter tags was null or undefined when calling findPetsByTags.' ) ;
229
+ if ( params . tags === null || params . tags === undefined ) {
230
+ throw new Error ( 'Required parameter params. tags was null or undefined when calling findPetsByTags.' ) ;
203
231
}
204
232
205
233
let queryParameters = { } ;
206
- if ( tags !== undefined && tags !== null ) {
207
- queryParameters [ 'tags' ] = < any > tags ;
234
+ if ( params . tags !== undefined && params . tags !== null ) {
235
+ queryParameters [ 'tags' ] = < any > params . tags ;
208
236
}
209
237
210
238
let headers = this . defaultHeaders ;
@@ -241,15 +269,15 @@ export class PetService {
241
269
/**
242
270
* Find pet by ID
243
271
* Returns a single pet
244
- * @param petId ID of pet to return
272
+ * @param getPetByIdParams
245
273
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
246
274
* @param reportProgress flag to report request and response progress.
247
275
*/
248
- public getPetById ( petId : number , ) : Observable < AxiosResponse < Pet > > ;
249
- public getPetById ( petId : number , ) : Observable < any > {
276
+ public getPetById ( params : getPetByIdParams ) : Observable < AxiosResponse < Pet > > ;
277
+ public getPetById ( params : getPetByIdParams ) : Observable < any > {
250
278
251
- if ( petId === null || petId === undefined ) {
252
- throw new Error ( 'Required parameter petId was null or undefined when calling getPetById.' ) ;
279
+ if ( params . petId === null || params . petId === undefined ) {
280
+ throw new Error ( 'Required parameter params. petId was null or undefined when calling getPetById.' ) ;
253
281
}
254
282
255
283
let headers = this . defaultHeaders ;
@@ -272,7 +300,7 @@ export class PetService {
272
300
// to determine the Content-Type header
273
301
const consumes : string [ ] = [
274
302
] ;
275
- return this . httpClient . get < Pet > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` ,
303
+ return this . httpClient . get < Pet > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( params . petId ) ) } ` ,
276
304
{
277
305
withCredentials : this . configuration . withCredentials ,
278
306
headers : headers
@@ -282,15 +310,15 @@ export class PetService {
282
310
/**
283
311
* Update an existing pet
284
312
*
285
- * @param pet Pet object that needs to be added to the store
313
+ * @param updatePetParams
286
314
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
287
315
* @param reportProgress flag to report request and response progress.
288
316
*/
289
- public updatePet ( pet : Pet , ) : Observable < AxiosResponse < Pet > > ;
290
- public updatePet ( pet : Pet , ) : Observable < any > {
317
+ public updatePet ( params : updatePetParams ) : Observable < AxiosResponse < Pet > > ;
318
+ public updatePet ( params : updatePetParams ) : Observable < any > {
291
319
292
- if ( pet === null || pet === undefined ) {
293
- throw new Error ( 'Required parameter pet was null or undefined when calling updatePet.' ) ;
320
+ if ( params . pet === null || params . pet === undefined ) {
321
+ throw new Error ( 'Required parameter params. pet was null or undefined when calling updatePet.' ) ;
294
322
}
295
323
296
324
let headers = this . defaultHeaders ;
@@ -323,7 +351,7 @@ export class PetService {
323
351
headers [ 'Content-Type' ] = httpContentTypeSelected ;
324
352
}
325
353
return this . httpClient . put < Pet > ( `${ this . basePath } /pet` ,
326
- pet ,
354
+ params . pet ,
327
355
{
328
356
withCredentials : this . configuration . withCredentials ,
329
357
headers : headers
@@ -333,17 +361,15 @@ export class PetService {
333
361
/**
334
362
* Updates a pet in the store with form data
335
363
*
336
- * @param petId ID of pet that needs to be updated
337
- * @param name Updated name of the pet
338
- * @param status Updated status of the pet
364
+ * @param updatePetWithFormParams
339
365
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
340
366
* @param reportProgress flag to report request and response progress.
341
367
*/
342
- public updatePetWithForm ( petId : number , name ?: string , status ?: string , ) : Observable < AxiosResponse < any > > ;
343
- public updatePetWithForm ( petId : number , name ?: string , status ?: string , ) : Observable < any > {
368
+ public updatePetWithForm ( params : updatePetWithFormParams ) : Observable < AxiosResponse < any > > ;
369
+ public updatePetWithForm ( params : updatePetWithFormParams ) : Observable < any > {
344
370
345
- if ( petId === null || petId === undefined ) {
346
- throw new Error ( 'Required parameter petId was null or undefined when calling updatePetWithForm.' ) ;
371
+ if ( params . petId === null || params . petId === undefined ) {
372
+ throw new Error ( 'Required parameter params. petId was null or undefined when calling updatePetWithForm.' ) ;
347
373
}
348
374
349
375
@@ -382,15 +408,15 @@ export class PetService {
382
408
// formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
383
409
}
384
410
385
- if ( name !== undefined ) {
386
- formParams . append ( 'name' , < any > name ) ;
411
+ if ( params . name !== undefined ) {
412
+ formParams . append ( 'name' , < any > params . name ) ;
387
413
}
388
414
389
- if ( status !== undefined ) {
390
- formParams . append ( 'status' , < any > status ) ;
415
+ if ( params . status !== undefined ) {
416
+ formParams . append ( 'status' , < any > params . status ) ;
391
417
}
392
418
393
- return this . httpClient . post < any > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` ,
419
+ return this . httpClient . post < any > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( params . petId ) ) } ` ,
394
420
convertFormParamsToString ? formParams . toString ( ) : formParams ,
395
421
{
396
422
withCredentials : this . configuration . withCredentials ,
@@ -401,17 +427,15 @@ export class PetService {
401
427
/**
402
428
* uploads an image
403
429
*
404
- * @param petId ID of pet to update
405
- * @param additionalMetadata Additional data to pass to server
406
- * @param file file to upload
430
+ * @param uploadFileParams
407
431
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
408
432
* @param reportProgress flag to report request and response progress.
409
433
*/
410
- public uploadFile ( petId : number , additionalMetadata ?: string , file ?: Blob , ) : Observable < AxiosResponse < ApiResponse > > ;
411
- public uploadFile ( petId : number , additionalMetadata ?: string , file ?: Blob , ) : Observable < any > {
434
+ public uploadFile ( params : uploadFileParams ) : Observable < AxiosResponse < ApiResponse > > ;
435
+ public uploadFile ( params : uploadFileParams ) : Observable < any > {
412
436
413
- if ( petId === null || petId === undefined ) {
414
- throw new Error ( 'Required parameter petId was null or undefined when calling uploadFile.' ) ;
437
+ if ( params . petId === null || params . petId === undefined ) {
438
+ throw new Error ( 'Required parameter params. petId was null or undefined when calling uploadFile.' ) ;
415
439
}
416
440
417
441
@@ -455,15 +479,15 @@ export class PetService {
455
479
// formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
456
480
}
457
481
458
- if ( additionalMetadata !== undefined ) {
459
- formParams . append ( 'additionalMetadata' , < any > additionalMetadata ) ;
482
+ if ( params . additionalMetadata !== undefined ) {
483
+ formParams . append ( 'additionalMetadata' , < any > params . additionalMetadata ) ;
460
484
}
461
485
462
- if ( file !== undefined ) {
463
- formParams . append ( 'file' , < any > file ) ;
486
+ if ( params . file !== undefined ) {
487
+ formParams . append ( 'file' , < any > params . file ) ;
464
488
}
465
489
466
- return this . httpClient . post < ApiResponse > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } /uploadImage` ,
490
+ return this . httpClient . post < ApiResponse > ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( params . petId ) ) } /uploadImage` ,
467
491
convertFormParamsToString ? formParams . toString ( ) : formParams ,
468
492
{
469
493
withCredentials : this . configuration . withCredentials ,
0 commit comments