UNPKG

2.49 kBJavaScriptView Raw
1const requestPromise = require('request-promise-native');
2const Global = require('./global');
3
4async function navigateWebsite(
5 idHotel,
6 checkin,
7 checkout,
8 adultos,
9 criancas,
10 cupom,
11 childAges,
12 otherParams,
13) {
14 try {
15 const options = {
16 uri: Global.CRAWLER_ENDPOINT + '/omnibees',
17 qs: {
18 idHotel: idHotel,
19 checkin: checkin,
20 checkout: checkout,
21 adultos: adultos,
22 criancas: criancas,
23 cupom: cupom,
24 childAges: childAges,
25 otherParams: otherParams,
26 },
27 json: true, // Automatically parses the JSON string in the response
28 };
29
30 const response = await requestPromise.get(options);
31
32 return Promise.resolve(response);
33 } catch (err) {
34 console.log('caiu aqui no erro');
35 console.error(err.error);
36 return Promise.reject(err.error);
37 }
38}
39
40async function getSuggestionDates(
41 idHotel,
42 checkin,
43 checkout,
44 adultos,
45 criancas,
46 cupom,
47 childAges,
48 otherParams,
49) {
50 try {
51 const options = {
52 uri: Global.CRAWLER_ENDPOINT + '/omnibees/suggestion',
53 qs: {
54 idHotel: idHotel,
55 checkin: checkin,
56 checkout: checkout,
57 adultos: adultos,
58 criancas: criancas,
59 cupom: cupom,
60 childAges: childAges,
61 otherParams: otherParams,
62 },
63 json: true, // Automatically parses the JSON string in the response
64 };
65
66 const response = await requestPromise.get(options);
67
68 return Promise.resolve(response);
69 } catch (err) {
70 console.log('caiu aqui no erro');
71 console.error(err.error);
72 return Promise.reject(err.error);
73 }
74}
75
76// //
77
78// https://myreservations.omnibees.com/default.aspx?q=5307&diff=false&CheckIn=25022018&CheckOut=26022018&Code=&group_code=&loyality_card=&NRooms=1&ad=2&ch=0&ag=-
79// https://myreservations.omnibees.com/default.aspx?q=5307&diff=false&CheckIn=25022018&CheckOut=26022018&Code=&group_code=&loyality_card=&NRooms=1&ad=2&ch=0&ag=-
80
81// //
82// navigateWebsite(3687, '14072018', '17072018', 2, 1, null, [1,2,3]).then(data => {
83// console.log("sucesso")
84// }).catch(error => {
85// console.log("caiu aqui");
86// console.log(error.message);
87// });
88
89// navigateWebsite(1798, '10052018', '11052018', 2, 0).then(data => {
90// console.log(data);
91// console.log("sucesso")
92//
93// }).catch(error => {
94// console.log("caiu aqui");
95// console.log(error.message);
96// });
97
98module.exports = { search: navigateWebsite, getSuggestionDates: getSuggestionDates };