forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.js
52 lines (44 loc) · 2.13 KB
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var Promise = require('bluebird');
var ReviewsOptions = [
'“Very stylish, great stay, great staff”',
'“good hotel awful meals”',
'“Need more attention to little things”',
'“Lovely small hotel ideally situated to explore the area.”',
'“Positive surprise”',
'“Beautiful suite and resort”'];
module.exports = {
searchHotels: function (destination) {
return new Promise(function (resolve) {
// Filling the hotels results manually just for demo purposes
var hotels = [];
for (var i = 1; i <= 5; i++) {
hotels.push({
name: destination + ' Hotel ' + i,
location: destination,
rating: Math.ceil(Math.random() * 5),
numberOfReviews: Math.floor(Math.random() * 5000) + 1,
priceStarting: Math.floor(Math.random() * 450) + 80,
image: 'https://placeholdit.imgix.net/~text?txtsize=35&txt=Hotel+' + i + '&w=500&h=260'
});
}
hotels.sort(function (a, b) { return a.priceStarting - b.priceStarting; });
// complete promise with a timer to simulate async response
setTimeout(function () { resolve(hotels); }, 1000);
});
},
searchHotelReviews: function (hotelName) {
return new Promise(function (resolve) {
// Filling the review results manually just for demo purposes
var reviews = [];
for (var i = 0; i < 5; i++) {
reviews.push({
title: ReviewsOptions[Math.floor(Math.random() * ReviewsOptions.length)],
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris odio magna, sodales vel ligula sit amet, vulputate vehicula velit. Nulla quis consectetur neque, sed commodo metus.',
image: 'https://upload.wikimedia.org/wikipedia/en/e/ee/Unknown-person.gif'
});
}
// complete promise with a timer to simulate async response
setTimeout(function () { resolve(reviews); }, 1000);
});
}
};