File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -197,5 +197,19 @@ describe('Request', () => {
197197 expect ( request . headers [ 'Content-Type' ] ) . toBe ( 'application/vnd.amadeus+json' ) ;
198198 } ) ;
199199 } ) ;
200+
201+ describe ( '.addHTTPOverride' , ( ) => {
202+ it ( 'should add the X-HTTP-Method-Override header if the specific endpoints' , ( ) => {
203+ for ( let path of request . ListHTTPOverride ) {
204+ request . path = path ;
205+ request . verb = 'POST' ;
206+ request . headers = { } ;
207+ request . bearerToken = undefined ;
208+ request . addHTTPOverrideHeader ( ) ;
209+ expect ( request . headers [ 'X-HTTP-Method-Override' ] ) . toBe ( 'GET' ) ;
210+ }
211+ } ) ;
212+ } ) ;
213+
200214 } ) ;
201215} ) ;
Original file line number Diff line number Diff line change @@ -40,8 +40,17 @@ class Request {
4040 'User-Agent' : this . userAgent ( ) ,
4141 'Accept' : 'application/json, application/vnd.amadeus+json'
4242 } ;
43+ this . ListHTTPOverride = [
44+ '/v2/shopping/flight-offers' ,
45+ '/v1/shopping/seatmaps' ,
46+ '/v1/shopping/availability/flight-availabilities' ,
47+ '/v2/shopping/flight-offers/prediction' ,
48+ '/v1/shopping/flight-offers/pricing' ,
49+ '/v1/shopping/flight-offers/upselling'
50+ ] ;
4351 this . addAuthorizationHeader ( ) ;
4452 this . addContentTypeHeader ( ) ;
53+ this . addHTTPOverrideHeader ( ) ;
4554 }
4655
4756 // PROTECTED
@@ -132,6 +141,18 @@ class Request {
132141 }
133142 return ;
134143 }
144+
145+ /**
146+ * Adds HTTPOverride method if it is required
147+ *
148+ * @private
149+ */
150+ addHTTPOverrideHeader ( ) {
151+ if ( this . verb === 'POST' && this . ListHTTPOverride . includes ( this . path ) ) {
152+ this . headers [ 'X-HTTP-Method-Override' ] = 'GET' ;
153+ }
154+ return ;
155+ }
135156}
136157
137158export default Request ;
You can’t perform that action at this time.
0 commit comments