Skip to content

Commit

Permalink
hotels: Places in filter renamed to placeIds
Browse files Browse the repository at this point in the history
  • Loading branch information
Rostislav Wolny committed Sep 19, 2017
1 parent 1b6c86f commit 429f014
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,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 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

0 comments on commit 429f014

Please sign in to comment.