Skip to content

Commit

Permalink
Merge pull request #97 from sygic-travel/release-changes
Browse files Browse the repository at this point in the history
Bump version numbers in package.json, readme, packages tweaks
  • Loading branch information
Radovan Fekeč authored Sep 19, 2017
2 parents 368c678 + 429f014 commit 4f43909
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 57 deletions.
75 changes: 37 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,47 @@ The Sygic Travel SDK for JavaScript provides a set of client-side functionality
- Enables you to get media (photos and videos) for a place
- Spreads places on a map according to your configuration

You can also check out our [Reference documentation](http://docs.sygictravelapi.com/js-sdk/v1.0.0/).
You can also check out our [Reference documentation](http://docs.sygictravelapi.com/js-sdk/v1.1.0/).

## Installation
You can get the UMD build from the CDN, which you can include to your document,
```html
<script src=“cdn.travel.sygic.com/js-sdk/v1.0.0/SygicTravelSDK.js”></script>
<script src=“cdn.travel.sygic.com/js-sdk/v1.1.0/SygicTravelSDK.js”></script>
```
or install it using Yarn or NPM (Typescript types included).
```
yarn add sygic-travel/js-sdk.git#v1.0.0
yarn add sygic-travel/js-sdk.git#v1.1.0
```
## Initialization
#### [`create`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/modules/_sdk_.html#create)
Creates an instance of [Sygic Travel SDK](http://docs.sygictravelapi.com/js-sdk/v1.0.0/classes/_stsdk_.stsdk.html)
#### [`create`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/modules/_sdk_.html#create)
Creates an instance of [Sygic Travel SDK](http://docs.sygictravelapi.com/js-sdk/v1.1.0/classes/_stsdk_.stsdk.html)
##### Arguments:
- `apiUrl: string`
- `clientKey: string`
##### Returns:
- [`StSDK`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/classes/_stsdk_.stsdk.html)
- [`StSDK`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/classes/_stsdk_.stsdk.html)
```
// const SygicTravelSDK = require('sygic-travel-js-sdk/index.node') for node
import * as SygicTravelSDK from sygic-travel-js-sdk;
const apiUrl: string = https://api.sygictravelapi.com/1.0/en/';
const clientKey: CLIENT_KEY; // Get your client key at https://travel.sygic.com/b2b/api-key
import * as SygicTravelSDK from 'sygic-travel-js-sdk';
const apiUrl: string = 'https://api.sygictravelapi.com/1.0/en/';
const clientKey: string = 'CLIENT_KEY'; // Get your client key at https://travel.sygic.com/b2b/api-key
const stSDK: SygicTravelSDK.StSDK = SygicTravelSDK.create(apiUrl, clientKey);
```

## Instance methods
### [`getPlaces`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/classes/_stsdk_.stsdk.html#getplaces)

### [`getPlaces`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/classes/_modules_placesmodule_.placesmodule.html#getplaces)
Fetches a list of places according to the applied filter.

##### Arguments:
- [`filter: Places.PlacesFilterJSON`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_places_filter_.placesfilterjson.html)

- [`filter: Places.PlacesListFilterJSON`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_places_listfilter_.placeslistfilterjson.html)
PlacesListFilterJSON
###### PlacesFilter:

```ts
```ts
// Filter full example
const placeFilter: SygicTravelSDK.Places.PlacesFilterJSON = {
query: 'Tower',
const placeFilter: SygicTravelSDK.Places.PlacesListFilterJSON = {
query: 'Tower',
mapTiles: ['0121011'], // Matches places within map tile coordinate. For details see [Bing Maps docs](https://msdn.microsoft.com/en-us/library/bb259689.aspx) or Maptiler.org
mapSpread: 1,
bounds: {
Expand All @@ -62,7 +63,7 @@ const placeFilter: SygicTravelSDK.Places.PlacesFilterJSON = {
},
categories: ['eating', 'sightseeing'], // filter out only certain categories
categoriesOperator: 'OR',
tags: ['indian_cousine', 'mexican_counsine'],
tags: ['indian_cousine', 'mexican_counsine'],
tagsOperator: 'OR',
parents: ['city:1', 'city:5'], // filter out only places that has certain parents
parentsOperator: 'OR',
Expand All @@ -89,11 +90,11 @@ const placeFilter: SygicTravelSDK.Places.PlacesFilterJSON = {
| zoom | Zoom level of map. This is required for mapSpread. |

##### Returns:
- [`Promise<Places.Place[]>`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_places_place_.place.html)
- [`Promise<Places.Place[]>`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_places_place_.place.html)

##### Usage example:
```ts
const placeFilter: SygicTravelSDK.Places.PlacesFilterJSON = {
const placeFilter: SygicTravelSDK.Places.PlacesListFilterJSON = {
query: null, // text query, for example from a search input field
mapTiles: null,
mapSpread: null,
Expand All @@ -110,44 +111,44 @@ const placeFilter: SygicTravelSDK.Places.PlacesFilterJSON = {
limit: 20
};

stSDK.getPlaces(placeFilter).then((places: SygicTravelSDK.Places.Place[]) => {
console.log(places);
});
const places: SygicTravelSDK.Places.Place[] = await stSDK.places.getPlaces(placeFilter);
console.log(places)
```

---

### [`getPlaceDetailed`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/classes/_stsdk_.stsdk.html#getplacedetailed)
Returns a single place with populated [`detail`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_places_place_.place.html#detail) property.
### [`getPlaceDetailed`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/classes/_modules_placesmodule_.placesmodule.html#getplacedetailed)
Returns a single place with populated [`detail`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_places_place_.place.html#detail) property.
##### Arguments:
- `id: string`
- `photoSize: string`
##### Returns:
- [`Promise<Places.Place>`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_places_place_.place.html)
- [`Promise<Places.Place>`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_places_place_.place.html)

---

### [`getPlaceMedia`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/classes/_stsdk_.stsdk.html#getplacemedia)
### [`getPlaceMedia`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/classes/_modules_placesmodule_.placesmodule.html#getplacemedia)
Fetches media for place.
#### Arguments:
- `id: string`
#### Returns:
- [`Promise<Media.Medium[]>`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_media_media_.medium.html)
- [`Promise<Media.Medium[]>`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_media_media_.medium.html)
---
### [`spreadPlacesOnMap`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/classes/_stsdk_.stsdk.html#spreadplacesonmap)

### [`spreadPlacesOnMap`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/classes/_modules_placesmodule_.placesmodule.html#spreadplacesonmap)
Will calculate positions of places (map markers) according to spread configuration.

#### Arguments:
- [`places: Places.Place[]`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_places_place_.place.html)
- [`bounds: Geo.Bounds`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_geo_bounds_.bounds.html)
- [`canvas: Spread.CanvasSize`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_spread_canvas_.canvassize.html)
- [`markerSizes (optional): Spread.SpreadSizeConfig[]`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_spread_config_.spreadsizeconfig.html)
- [`places: Places.Place[]`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_places_place_.place.html)
- [`bounds: Geo.Bounds`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_geo_bounds_.bounds.html)
- [`canvas: Spread.CanvasSize`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_spread_canvas_.canvassize.html)
- [`markerSizes (optional): Spread.SpreadSizeConfig[]`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_spread_config_.spreadsizeconfig.html)
#### Returns:
- [`Spread.SpreadResult`](http://docs.sygictravelapi.com/js-sdk/v1.0.0/interfaces/_spread_spreader_.spreadresult.html)
- [`Spread.SpreadResult`](http://docs.sygictravelapi.com/js-sdk/v1.1.0/interfaces/_spread_spreader_.spreadresult.html)

#### Usage example:
```ts
const placeFilter: SygicTravelSDK.Places.PlacesFilterJSON = {
const placeFilter: SygicTravelSDK.Places.PlacesListFilterJSON = {
query: null,
mapTiles: null,
mapSpread: null,
Expand All @@ -170,9 +171,7 @@ const canvasSize: SygicTravelSDK.Spread.CanvasSize = {
height: 768
}

stSDK.getPlaces(placeFilter).then((places: SygicTravelSDK.Places.Place[]) => {
return stSDK.spreadPlacesOnMap(places, bounds, canvasSize);
}).then((spreadPlaces: SygicTravelSDK.Spread.SpreadResult) => {
console.log(spreadPlaces);
});
const places: SygicTravelSDK.Places.Place[] = await stSDK.places.getPlaces(placeFilter);
const spreadPlaces: SygicTravelSDK.Spread.SpreadResult = await stSDK.places.spreadPlacesOnMap(places, bounds, canvasSize);
console.log(spreadPlaces);
```
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export namespace Hotels {
maxPrice?: number | null;
minPrice?: number | null;
minReviewScore?: number | null;
places?: string[] | null;
placeIds?: string[] | null;
bounds?: Geo.Bounds | null;
mapTileBounds?: string[] | null;
stars?: number[] | null;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sygic-travel-js-sdk",
"version": "0.2.1",
"version": "1.1.0",
"main": "index.js",
"repository": {},
"license": "MIT",
Expand Down Expand Up @@ -40,11 +40,11 @@
"webpack-dev-server": "^2.7.1"
},
"dependencies": {
"@mapbox/polyline": "^0.2.0",
"@types/geojson": "^1.0.2",
"axios": "*",
"humps": "^2.0.0",
"lodash.clonedeep": "^4.5.0",
"polyline": "^0.2.0",
"query-string": "^4.3.1"
}
}
4 changes: 2 additions & 2 deletions src/Hotels/DataAccess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ describe('HotelsDataAccess', () => {
adults: 2,
checkIn: '2017-11-11',
checkOut: '2017-11-12',
places: ['poi:1', 'poi:2']
placeIds: ['poi:1', 'poi:2']
});

chai.expect(await Dao.getHotels(hotelsFilter))
.to.deep.equal(HotelsResults.availableHotels);
chai.expect(apiStub.callCount).to.equal(1);
chai.expect(apiStub.getCall(0).args[0])
.to.equal('hotels/list/?adults=2&check_in=2017-11-11&check_out=2017-11-12&places=poi%3A1%7Cpoi%3A2');
.to.equal('hotels/list/?adults=2&check_in=2017-11-11&check_out=2017-11-12&place_ids=poi%3A1%7Cpoi%3A2');
});

it('should use map tiles if bounds and zoom are passed', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/Hotels/Filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('HotelsFilter', () => {
north: 3,
east: 4,
},
places: ['poi:1', 'poi:2']
placeIds: ['poi:1', 'poi:2']
});
};
chai.expect(createFilter).to.throw(
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('HotelsFilter', () => {
adults: 1,
checkIn: '2017-11-11',
checkOut: 'fdfdfd',
places: ['poi:1'],
placeIds: ['poi:1'],
});
};
chai.expect(createFilter).to.throw('Invalid checkOut date.');
Expand Down
14 changes: 7 additions & 7 deletions src/Hotels/Filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface HotelsFilterJSON {
maxPrice?: number | null;
minPrice?: number | null;
minReviewScore?: number | null;
places?: string[] | null;
placeIds?: string[] | null;
bounds?: Bounds | null;
mapTileBounds?: string[] | null;
stars?: number[] | null;
Expand All @@ -30,7 +30,7 @@ export interface HotelsFilterQuery {
max_price?: number;
min_price?: number;
min_review_score?: number;
places?: string;
place_ids?: string;
bounds?: string;
map_tile_bounds?: string;
stars?: string;
Expand All @@ -50,7 +50,7 @@ export class HotelsFilter {
protected _maxPrice?: number | null;
protected _minPrice?: number | null;
protected _minReviewScore?: number | null;
protected _places?: string[] | null;
protected _placeIds?: string[] | null;
protected _bounds?: Bounds | null;
protected _mapTileBounds?: string[] | null;
protected _stars?: number[] | null;
Expand All @@ -70,7 +70,7 @@ export class HotelsFilter {
this._minPrice = filter.minPrice;
this._minReviewScore = filter.minReviewScore;
this._bounds = filter.bounds;
this._places = filter.places;
this._placeIds = filter.placeIds;
this._mapTileBounds = filter.mapTileBounds;
this._stars = filter.stars;
this._currency = filter.currency;
Expand Down Expand Up @@ -108,8 +108,8 @@ export class HotelsFilter {
if (this._minReviewScore) {
query.min_review_score = this._minReviewScore;
}
if (this._places) {
query.places = this._places.join('|');
if (this._placeIds) {
query.place_ids = this._placeIds.join('|');
}
if (this._bounds) {
query.bounds = this._bounds.south + ',' + this._bounds.west + ',' + this._bounds.north + ',' + this._bounds.east;
Expand Down Expand Up @@ -156,7 +156,7 @@ export class HotelsFilter {
if (!this._adults) {
throw new Error('Adults count is mandatory.');
}
if ([this._bounds, this._mapTileBounds, this._places].filter((it) => it).length !== 1) {
if ([this._bounds, this._mapTileBounds, this._placeIds].filter((it) => it).length !== 1) {
throw new Error('Bounds, mapTileBounds and places have to be used exclusively and one of them has to be present.');
}
const chInDate = new Date(this._checkIn);
Expand Down
2 changes: 1 addition & 1 deletion src/Route/Estimator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encode } from 'polyline';
import { encode } from '@mapbox/polyline';
import { Direction } from '.';
import { EARTH_RADIUS, getDistance, Location } from '../Geo';

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# yarn lockfile v1


"@mapbox/polyline@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@mapbox/polyline/-/polyline-0.2.0.tgz#6e25980744aa22331f94b645a542c02d3fcfee97"

"@types/chai-as-promised@^0.0.30":
version "0.0.30"
resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-0.0.30.tgz#2341321cc796c6c3544a949a063e7609a222f303"
Expand Down Expand Up @@ -2561,10 +2565,6 @@ pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"

polyline@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/polyline/-/polyline-0.2.0.tgz#4f2b716ca81134a6cbaa488975d236ecb1cc2840"

portfinder@^1.0.9:
version "1.0.13"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9"
Expand Down

0 comments on commit 4f43909

Please sign in to comment.