-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcinepolis.js
52 lines (43 loc) · 1.31 KB
/
cinepolis.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
const got = require("got");
exports.getCities = async () => {
const url =
"https://cinepolis.com/manejadores/CiudadesComplejos.ashx?EsVIP=false";
const { body } = await got.post(url, { json: true });
const cities = [];
body.map(value => {
let city = {};
city.message = value.Nombre;
city.name = value.Clave;
city.value = value.Clave;
cities.push(city);
});
return cities;
};
exports.getShowtimes = async city => {
const url = "https://cinepolis.com/Cartelera.aspx/GetNowPlayingByCity";
const body = { claveCiudad: city, esVIP: false };
const options = { body, json: true };
const response = await got.post(url, options);
const showtimes = response.body.d;
const locations = showtimes.Locations;
return { showtimes, locations };
};
exports.getDates = (cinemas, selectedCinema) => {
const [cinema] = cinemas.filter(value => value.Key === selectedCinema.cinema);
return cinema.Dates;
};
exports.getCinemas = async locations => {
const values = Object.keys(locations);
const cinemas = [];
values.forEach(value => {
let o = {};
o.value = value;
o.message = locations[value];
cinemas.push(o);
});
return cinemas;
};
exports.getMovies = (selectedDate, dates) => {
const [moviesArray] = dates.filter(v => v.ShowtimeDate === selectedDate);
return movies;
};