skyscannerjs
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -30,9 +30,9 @@ "use strict"; | ||
livePrices: { | ||
session: function session(data) { | ||
session: function session(params) { | ||
var asJSON = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; | ||
var url = API.flightPricingURL; | ||
data.apiKey = apiKey; | ||
data = _querystring2.default.stringify(data); | ||
return _axios2.default.post(url, data, { | ||
params.apiKey = apiKey; | ||
params = _querystring2.default.stringify(params); | ||
return _axios2.default.post(url, params, { | ||
headers: { | ||
@@ -47,12 +47,12 @@ "Content-Type": "application/x-www-form-urlencoded", | ||
var url = API.flightPricingURL + "/" + session; | ||
params.apiKey = apiKey; | ||
return _axios2.default.get(url, { params: params }); | ||
return _axios2.default.get(session, { params: params }); | ||
}, | ||
bookingDetails: { | ||
session: function session(_session, data) { | ||
var url = API.flightPricingURL + "/" + _session + "/booking"; | ||
data.apiKey = apiKey; | ||
data = _querystring2.default.stringify(data); | ||
return _axios2.default.put(url, data); | ||
session: function session(_session, params) { | ||
var url = _session + "/booking"; | ||
url = url.replace("/uk2", ""); | ||
params.apiKey = apiKey; | ||
params = _querystring2.default.stringify(params); | ||
return _axios2.default.put(url, params); | ||
}, | ||
@@ -62,3 +62,3 @@ poll: function poll(session, itinerary) { | ||
var url = API.flightPricingURL + "/" + session + "/booking/" + itinerary; | ||
var url = session + "/booking/" + itinerary; | ||
params.apiKey = apiKey; | ||
@@ -200,4 +200,2 @@ return _axios2.default.get(url, { params: params }); | ||
poll: function poll(session, deltaExcludedWebsites) { | ||
var url = API.carHirePricingURL + "/" + session; | ||
var params = {}; | ||
@@ -208,3 +206,3 @@ if (deltaExcludedWebsites) { | ||
return _axios2.default.get(url, { params: params }); | ||
return _axios2.default.get(session, { params: params }); | ||
} | ||
@@ -241,4 +239,3 @@ } | ||
var url = API.hotelPricingURL + "/" + session; | ||
return _axios2.default.get(url, { params: params }); | ||
return _axios2.default.get(session, { params: params }); | ||
}, | ||
@@ -245,0 +242,0 @@ details: { |
{ | ||
"name": "skyscannerjs", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Promise based wrapper for the Skyscanner travel APIs.", | ||
@@ -5,0 +5,0 @@ "main": "lib/skyscanner.js", |
307
README.md
@@ -20,11 +20,308 @@ # SkyscannerJS | ||
```javascript | ||
// ES6 | ||
import skyscanner from "skyscanner"; | ||
const apiKey = "s3r3t4PIk3y"; | ||
const api = new skyscanner.API(apiKey); | ||
``` | ||
// ES5 | ||
var skyscanner = require("skyscanner"); | ||
var apiKey = "s3r3t4PIk3y"; | ||
var api = new skyscanner.API(apiKey); | ||
### Create a flight live pricing session | ||
```javascript | ||
api.flights.livePricing.session({ | ||
country: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
locationSchema: "Iata", | ||
originplace: "EDI", | ||
destinationplace: "LHR", | ||
outbounddate: "2016-06-13", | ||
adults: 1 | ||
}) | ||
.then((response) => { | ||
// URL to poll the session. | ||
const location = response.headers.location; | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList#createsession) | ||
### Poll a flight living pricing session | ||
```javascript | ||
api.flights.livePricing.poll(session).then((response) => { | ||
const itineraries = response.data.Itineraries; | ||
const legs = response.data.legs; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList#pollsession) | ||
### Create a flight booking details session | ||
```javascript | ||
api.flights.livePricing.bookingDetails.session(session, { | ||
outboundlegid: "", | ||
inboundlegid: "" | ||
}) | ||
.then((response) => { | ||
// URL to poll the session. | ||
const location = response.headers.location; | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList#createbookingdetails) | ||
### Poll a flight booking details session | ||
```javascript | ||
api.flights.livePricing.bookingDetails.poll(session, itinerary).then((response) => { | ||
const options = response.data.BookingOptions; | ||
const places = response.data.Places; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList#pollbookingdetails) | ||
### Browse the quotes service | ||
```javascript | ||
api.flights.browse.quotes({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
originPlace: "EDI", | ||
destinationPlace: "LHR", | ||
outboundPartialDate: "2016-06-13", | ||
ip: "98.139.180.149" | ||
}) | ||
.then((response) => { | ||
const quotes = response.data.Quotes; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheQuotes) | ||
## Browse the routes service | ||
```javascript | ||
api.flights.browse.routes({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
originPlace: "EDI", | ||
destinationPlace: "LHR", | ||
outboundPartialDate: "2016-06-13", | ||
ip: "98.139.180.149" | ||
}) | ||
.then((response) => { | ||
const quotes = response.data.Quotes; | ||
const dates = response.data.Routes; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheRoutes) | ||
### Browse the dates service | ||
```javascript | ||
api.flights.browse.dates({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
originPlace: "EDI", | ||
destinationPlace: "LHR", | ||
outboundPartialDate: "2016-06-13", | ||
ip: "98.139.180.149" | ||
}) | ||
.then((response) => { | ||
const quotes = response.data.Quotes; | ||
const dates = response.data.Dates; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheDates) | ||
### Browse the grid service | ||
```javascript | ||
api.flights.browse.grid({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
originPlace: "EDI", | ||
destinationPlace: "LHR", | ||
outboundPartialDate: "2016-06-13", | ||
ip: "98.139.180.149" | ||
}) | ||
.then((response) => { | ||
const quotes = response.data.Quotes; | ||
const dates = response.data.Dates; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheGrid) | ||
## Create a car hire live pricing session | ||
```javascript | ||
api.carHire.livePricing.session({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
pickupplace: "EDI", | ||
dropoffplace: "GLA", | ||
pickupdatetime: "2016-06-13T19:00", | ||
dropoffdatetime: "2016-06-14T19:00", | ||
driverage: 40, | ||
ip: "98.139.180.149" | ||
}) | ||
.then((response) => { | ||
// URL to poll the session. | ||
const location = response.headers.location; | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/CarHireLivePricing#createsession) | ||
## Poll a car hire live pricing session | ||
```javascript | ||
api.carHire.livePricing.poll(session).then((response) => { | ||
const cars = reponse.data.cars; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/CarHireLivePricing#pollsession) | ||
## Create a hotels live pricing session | ||
```javascript | ||
api.hotels.livePrices.session({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
entityId: "41.37,2.14-latlong", | ||
checkindate: "2016-06-13", | ||
checkoutdate: "2016-06-14", | ||
guests: 1, | ||
rooms: 1 | ||
}) | ||
.then((response) => { | ||
// URL to poll the session. | ||
const location = response.headers.location; | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/HotelsLivePricingList#createsession) | ||
## Poll the hotels live pricing session | ||
```javascript | ||
api.hotels.livePricing.poll(session).then((response) => { | ||
const hotels = response.data.hotels; | ||
const status = response.data.status; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/HotelsLivePricingList#pollsession) | ||
## Create a hotel details session | ||
```javascript | ||
api.hotels.livePrices.details.session(session, { | ||
HotelIds: "1,2,3" | ||
}) | ||
.then((response) => { | ||
// URL to poll the session. | ||
const location = response.headers.location; | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/HotelsLivePricingList#createdetails) | ||
## Poll a hotel details session | ||
```javascript | ||
api.hotels.livePrices.details.poll(session, { | ||
HotelIds: "1,2,3" | ||
}) | ||
.then((response) => { | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/HotelsLivePricingList#polldetails) | ||
## Use the hotel autosuggest service | ||
```javascript | ||
api.hotels.autosuggest({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
query: "pari" | ||
}) | ||
.then((reponse) => { | ||
const results = response.data.results; | ||
const places = response.data.places; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/HotelsAutoSuggest) | ||
## Get all supported currencies | ||
```javascript | ||
api.reference.currencies().then((response) => { | ||
const currencies = response.data.Currencies; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/Currencies) | ||
## Get all supported locales | ||
```javascript | ||
api.reference.locales().then((response) => { | ||
const locales = response.data.Locales; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/Locales) | ||
## Get all supported countries | ||
```javascript | ||
api.reference.countries().then((response) => { | ||
const countries = response.data.Countries; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/Markets) | ||
## Use the location autosuggest service | ||
```javascript | ||
api.locationAutosuggest({ | ||
market: "UK", | ||
currency: "GBP", | ||
locale: "en-GB", | ||
query: "ed" | ||
}) | ||
.then((response) => { | ||
const places = response.data.Places; | ||
... | ||
}); | ||
``` | ||
[Documentation](http://business.skyscanner.net/portal/en-GB/Documentation/Autosuggest) |
27676
326
365