diff --git a/lib/sabre-dev-studio-flight.js b/lib/sabre-dev-studio-flight.js index f8480ef..33a6c66 100644 --- a/lib/sabre-dev-studio-flight.js +++ b/lib/sabre-dev-studio-flight.js @@ -105,10 +105,12 @@ var SabreDevStudioFlight = (function() { * @param callback */ this.bargain_finder_max = function (request, callback) { - var endpoint = '/v1.8.5/shop/flights'; + var endpoint = '/v4/offers/shop/flights'; var options = { 'mode': 'live', - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'enabletagging':true, + 'limit':200 }; that.sabre_dev_studio.post(endpoint, request, options, callback); }; @@ -243,4 +245,4 @@ var SabreDevStudioFlight = (function() { return SabreDevStudioFlight; })(); -module.exports = SabreDevStudioFlight; +module.exports.SabreDevStudioFlight = SabreDevStudioFlight; diff --git a/lib/sabre-dev-studio.js b/lib/sabre-dev-studio.js index ebcc5ce..b5689f2 100644 --- a/lib/sabre-dev-studio.js +++ b/lib/sabre-dev-studio.js @@ -36,10 +36,10 @@ var SabreDevStudio = (function() { init(options); function init(options) { var clientID = function() { - return new Buffer(that.config.client_id).toString('base64'); + return Buffer.from(that.config.client_id).toString('base64'); }; var clientSecret = function() { - return new Buffer(that.config.client_secret).toString('base64'); + return Buffer.from(that.config.client_secret).toString('base64'); }; var keys = ['client_id', 'client_secret', 'uri', 'access_token']; @@ -95,15 +95,20 @@ var SabreDevStudio = (function() { method: method, body: post_body, headers: headers, + timeout: 60 * 10000, auth: { "bearer": this.config.access_token } }; request[method.toLowerCase()](requestUrl, reqestOptions, function(error, response, data) { if (error) { - if (error.data === '') { error.data = requestUrl; } - log.error('Error:', error); - cb(error, data, response); + if (error.code === 'ECONNRESET' && retryCount >= 0) { + fetchAccessToken(endpoint, options, cb, --retryCount); + } else { + if (error.data === '') { error.data = requestUrl; } + log.error('Error:', error); + cb(error, data, response); + } } else if (response.statusCode === 200) { cb(null, data, response); } else if (response.statusCode === 401 && retryCount >= 0) {