11
11
*/
12
12
/* tslint:disable:no-unused-variable member-ordering */
13
13
14
- import { Observable } from " rxjs/Observable" ;
14
+ import { Observable } from ' rxjs/Observable' ;
15
15
import 'rxjs/add/operator/map' ;
16
16
import 'rxjs/add/operator/toPromise' ;
17
- import IHttpClient from " ../IHttpClient" ;
18
- import { inject , injectable } from " inversify" ;
19
- import { IAPIConfiguration } from " ../IAPIConfiguration" ;
20
- import { Headers } from " ../Headers" ;
21
- import HttpResponse from " ../HttpResponse" ;
17
+ import IHttpClient from ' ../IHttpClient' ;
18
+ import { inject , injectable } from ' inversify' ;
19
+ import { IAPIConfiguration } from ' ../IAPIConfiguration' ;
20
+ import { Headers } from ' ../Headers' ;
21
+ import HttpResponse from ' ../HttpResponse' ;
22
22
23
23
import { ApiResponse } from '../model/apiResponse' ;
24
24
import { Pet } from '../model/pet' ;
@@ -29,13 +29,10 @@ import { COLLECTION_FORMATS } from '../variables';
29
29
30
30
@injectable ( )
31
31
export class PetService {
32
- private basePath : string = 'http://petstore.swagger.io/v2' ;
32
+ @inject ( 'IAPIConfiguration' ) private APIConfiguration : IAPIConfiguration ;
33
+ @inject ( 'IApiHttpClient' ) private httpClient : IHttpClient ;
34
+
33
35
34
- constructor ( @inject ( "IApiHttpClient" ) private httpClient : IHttpClient ,
35
- @inject ( "IAPIConfiguration" ) private APIConfiguration : IAPIConfiguration ) {
36
- if ( this . APIConfiguration . basePath )
37
- this . basePath = this . APIConfiguration . basePath ;
38
- }
39
36
40
37
/**
41
38
* Add a new pet to the store
@@ -60,9 +57,9 @@ export class PetService {
60
57
headers [ 'Accept' ] = 'application/xml' ;
61
58
headers [ 'Content-Type' ] = 'application/json' ;
62
59
63
- const response : Observable < HttpResponse < any > > = this . httpClient . post ( `${ this . basePath } /pet` , body , headers ) ;
64
- if ( observe == 'body' ) {
65
- return response . map ( httpResponse => < any > ( httpResponse . response ) ) ;
60
+ const response : Observable < HttpResponse < any > > = this . httpClient . post ( `${ this . APIConfiguration . basePath } /pet` , body as any , headers ) ;
61
+ if ( observe === 'body' ) {
62
+ return response . map ( httpResponse => httpResponse . response ) ;
66
63
}
67
64
return response ;
68
65
}
@@ -95,9 +92,9 @@ export class PetService {
95
92
}
96
93
headers [ 'Accept' ] = 'application/xml' ;
97
94
98
- const response : Observable < HttpResponse < any > > = this . httpClient . delete ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` , headers ) ;
99
- if ( observe == 'body' ) {
100
- return response . map ( httpResponse => < any > ( httpResponse . response ) ) ;
95
+ const response : Observable < HttpResponse < any > > = this . httpClient . delete ( `${ this . APIConfiguration . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` as any , headers ) ;
96
+ if ( observe === 'body' ) {
97
+ return response . map ( httpResponse => httpResponse . response ) ;
101
98
}
102
99
return response ;
103
100
}
@@ -118,7 +115,7 @@ export class PetService {
118
115
119
116
let queryParameters : string [ ] = [ ] ;
120
117
if ( status ) {
121
- queryParameters . push ( " status=" + encodeURIComponent ( status . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
118
+ queryParameters . push ( ' status=' + encodeURIComponent ( status . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
122
119
}
123
120
124
121
// authentication (petstore_auth) required
@@ -130,9 +127,9 @@ export class PetService {
130
127
}
131
128
headers [ 'Accept' ] = 'application/xml' ;
132
129
133
- const response : Observable < HttpResponse < Array < Pet > > > = this . httpClient . get ( `${ this . basePath } /pet/findByStatus?${ queryParameters . join ( '&' ) } ` , headers ) ;
134
- if ( observe == 'body' ) {
135
- return response . map ( httpResponse => < Array < Pet > > ( httpResponse . response ) ) ;
130
+ const response : Observable < HttpResponse < Array < Pet > > > = this . httpClient . get ( `${ this . APIConfiguration . basePath } /pet/findByStatus?${ queryParameters . join ( '&' ) } ` as any , headers ) ;
131
+ if ( observe === 'body' ) {
132
+ return response . map ( httpResponse => httpResponse . response ) ;
136
133
}
137
134
return response ;
138
135
}
@@ -153,7 +150,7 @@ export class PetService {
153
150
154
151
let queryParameters : string [ ] = [ ] ;
155
152
if ( tags ) {
156
- queryParameters . push ( " tags=" + encodeURIComponent ( tags . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
153
+ queryParameters . push ( ' tags=' + encodeURIComponent ( tags . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
157
154
}
158
155
159
156
// authentication (petstore_auth) required
@@ -165,9 +162,9 @@ export class PetService {
165
162
}
166
163
headers [ 'Accept' ] = 'application/xml' ;
167
164
168
- const response : Observable < HttpResponse < Array < Pet > > > = this . httpClient . get ( `${ this . basePath } /pet/findByTags?${ queryParameters . join ( '&' ) } ` , headers ) ;
169
- if ( observe == 'body' ) {
170
- return response . map ( httpResponse => < Array < Pet > > ( httpResponse . response ) ) ;
165
+ const response : Observable < HttpResponse < Array < Pet > > > = this . httpClient . get ( `${ this . APIConfiguration . basePath } /pet/findByTags?${ queryParameters . join ( '&' ) } ` as any , headers ) ;
166
+ if ( observe === 'body' ) {
167
+ return response . map ( httpResponse => httpResponse . response ) ;
171
168
}
172
169
return response ;
173
170
}
@@ -187,14 +184,14 @@ export class PetService {
187
184
}
188
185
189
186
// authentication (api_key) required
190
- if ( this . APIConfiguration . apiKeys [ " api_key" ] ) {
191
- headers [ 'api_key' ] = this . APIConfiguration . apiKeys [ " api_key" ] ;
187
+ if ( this . APIConfiguration . apiKeys [ ' api_key' ] ) {
188
+ headers [ 'api_key' ] = this . APIConfiguration . apiKeys [ ' api_key' ] ;
192
189
}
193
190
headers [ 'Accept' ] = 'application/xml' ;
194
191
195
- const response : Observable < HttpResponse < Pet > > = this . httpClient . get ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` , headers ) ;
196
- if ( observe == 'body' ) {
197
- return response . map ( httpResponse => < Pet > ( httpResponse . response ) ) ;
192
+ const response : Observable < HttpResponse < Pet > > = this . httpClient . get ( `${ this . APIConfiguration . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` as any , headers ) ;
193
+ if ( observe === 'body' ) {
194
+ return response . map ( httpResponse => httpResponse . response ) ;
198
195
}
199
196
return response ;
200
197
}
@@ -223,9 +220,9 @@ export class PetService {
223
220
headers [ 'Accept' ] = 'application/xml' ;
224
221
headers [ 'Content-Type' ] = 'application/json' ;
225
222
226
- const response : Observable < HttpResponse < any > > = this . httpClient . put ( `${ this . basePath } /pet` , body , headers ) ;
227
- if ( observe == 'body' ) {
228
- return response . map ( httpResponse => < any > ( httpResponse . response ) ) ;
223
+ const response : Observable < HttpResponse < any > > = this . httpClient . put ( `${ this . APIConfiguration . basePath } /pet` , body as any , headers ) ;
224
+ if ( observe === 'body' ) {
225
+ return response . map ( httpResponse => httpResponse . response ) ;
229
226
}
230
227
return response ;
231
228
}
@@ -264,9 +261,9 @@ export class PetService {
264
261
formData . append ( 'status' , < any > status ) ;
265
262
}
266
263
267
- const response : Observable < HttpResponse < any > > = this . httpClient . post ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` , body , headers ) ;
268
- if ( observe == 'body' ) {
269
- return response . map ( httpResponse => < any > ( httpResponse . response ) ) ;
264
+ const response : Observable < HttpResponse < any > > = this . httpClient . post ( `${ this . APIConfiguration . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } ` as any , body , headers ) ;
265
+ if ( observe === 'body' ) {
266
+ return response . map ( httpResponse => httpResponse . response ) ;
270
267
}
271
268
return response ;
272
269
}
@@ -305,9 +302,9 @@ export class PetService {
305
302
formData . append ( 'file' , < any > file ) ;
306
303
}
307
304
308
- const response : Observable < HttpResponse < ApiResponse > > = this . httpClient . post ( `${ this . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } /uploadImage` , body , headers ) ;
309
- if ( observe == 'body' ) {
310
- return response . map ( httpResponse => < ApiResponse > ( httpResponse . response ) ) ;
305
+ const response : Observable < HttpResponse < ApiResponse > > = this . httpClient . post ( `${ this . APIConfiguration . basePath } /pet/${ encodeURIComponent ( String ( petId ) ) } /uploadImage` as any , body , headers ) ;
306
+ if ( observe === 'body' ) {
307
+ return response . map ( httpResponse => httpResponse . response ) ;
311
308
}
312
309
return response ;
313
310
}
0 commit comments