-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequests.js
84 lines (71 loc) · 1.61 KB
/
requests.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const fetch = require("node-fetch");
const { BASE_URL, ROUTES } = require("./constants");
const getAllSports = async () => {
let sportPaths = [];
const res = await fetch(
"https://api-gateway.staging.jeet11.com/gaming-service/external/v1.0.0/getSports",
{
body: null,
method: "GET",
mode: "cors"
}
);
if (!res.ok) {
return sportPaths;
}
const response = await res.json();
const { data, status } = response;
if (status === "success") {
sportPaths = data.map(sport => {
const { name, id, priority } = sport;
return {
sportName: name,
sportId: id,
priority: priority
};
});
}
return sportPaths;
};
const getAllMatches = async sportId => {
let matchData = [];
const res = await fetch(
`https://api-gateway.staging.jeet11.com/gaming-service/external/v1.0.0/getMatches?s=${sportId}`,
{
body: null,
method: "GET",
mode: "cors"
}
);
if (!res.ok) {
return sportPaths;
}
const response = await res.json();
const { matchInfo } = response;
matchData = matchInfo.map(match => {
return {
loc: `${BASE_URL}${ROUTES.MATCH_ROUTE}/${match.matchId}/1`,
changefreq: "daily",
priority: 0.8
};
});
return matchData;
};
const letGoogleKnow = async sitemapUrl => {
let encoded_file_url = encodeURIComponent(file_url);
let ping_url = `http://www.google.com/ping?sitemap=${encoded_file_url}`;
const res = await fetch(ping_url, {
body: null,
method: "GET",
mode: "cors"
});
if (!res.ok) {
console.log("Letting Google Know Failed");
}
console.log("Letting Google Know Succeeded");
};
module.exports = {
getAllSports,
getAllMatches,
letGoogleKnow
};