1111 */
1212/* tslint:disable:no-unused-variable member-ordering */
1313
14- import { Observable } from " rxjs/Observable" ;
14+ import { Observable } from ' rxjs/Observable' ;
1515import 'rxjs/add/operator/map' ;
1616import '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' ;
2222
2323import { ApiResponse } from '../model/apiResponse' ;
2424import { Pet } from '../model/pet' ;
@@ -29,13 +29,10 @@ import { COLLECTION_FORMATS } from '../variables';
2929
3030@injectable ( )
3131export class PetService {
32- private basePath : string = 'http://petstore.swagger.io/v2' ;
32+ @inject ( 'IAPIConfiguration' ) private APIConfiguration : IAPIConfiguration ;
33+ @inject ( 'IApiHttpClient' ) private httpClient : IHttpClient ;
34+
3335
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- }
3936
4037 /**
4138 * Add a new pet to the store
@@ -60,9 +57,9 @@ export class PetService {
6057 headers [ 'Accept' ] = 'application/xml' ;
6158 headers [ 'Content-Type' ] = 'application/json' ;
6259
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 ) ;
6663 }
6764 return response ;
6865 }
@@ -95,9 +92,9 @@ export class PetService {
9592 }
9693 headers [ 'Accept' ] = 'application/xml' ;
9794
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 ) ;
10198 }
10299 return response ;
103100 }
@@ -118,7 +115,7 @@ export class PetService {
118115
119116 let queryParameters : string [ ] = [ ] ;
120117 if ( status ) {
121- queryParameters . push ( " status=" + encodeURIComponent ( status . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
118+ queryParameters . push ( ' status=' + encodeURIComponent ( status . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
122119 }
123120
124121 // authentication (petstore_auth) required
@@ -130,9 +127,9 @@ export class PetService {
130127 }
131128 headers [ 'Accept' ] = 'application/xml' ;
132129
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 ) ;
136133 }
137134 return response ;
138135 }
@@ -153,7 +150,7 @@ export class PetService {
153150
154151 let queryParameters : string [ ] = [ ] ;
155152 if ( tags ) {
156- queryParameters . push ( " tags=" + encodeURIComponent ( tags . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
153+ queryParameters . push ( ' tags=' + encodeURIComponent ( tags . join ( COLLECTION_FORMATS [ 'csv' ] ) ) ) ;
157154 }
158155
159156 // authentication (petstore_auth) required
@@ -165,9 +162,9 @@ export class PetService {
165162 }
166163 headers [ 'Accept' ] = 'application/xml' ;
167164
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 ) ;
171168 }
172169 return response ;
173170 }
@@ -187,14 +184,14 @@ export class PetService {
187184 }
188185
189186 // 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' ] ;
192189 }
193190 headers [ 'Accept' ] = 'application/xml' ;
194191
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 ) ;
198195 }
199196 return response ;
200197 }
@@ -223,9 +220,9 @@ export class PetService {
223220 headers [ 'Accept' ] = 'application/xml' ;
224221 headers [ 'Content-Type' ] = 'application/json' ;
225222
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 ) ;
229226 }
230227 return response ;
231228 }
@@ -264,9 +261,9 @@ export class PetService {
264261 formData . append ( 'status' , < any > status ) ;
265262 }
266263
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 ) ;
270267 }
271268 return response ;
272269 }
@@ -305,9 +302,9 @@ export class PetService {
305302 formData . append ( 'file' , < any > file ) ;
306303 }
307304
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 ) ;
311308 }
312309 return response ;
313310 }
0 commit comments