-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppStore_InfoApp.class.js
44 lines (39 loc) · 1.15 KB
/
AppStore_InfoApp.class.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
// Developer by : Azozz ALFiras
class AppStoreInfoApp {
async sentRequest(bundleid) {
const response = await fetch(`http://itunes.apple.com/lookup?bundleId=${bundleid}`);
const data = await response.json();
return data.results[0];
}
async getInfoApp(bundleid, Version) {
const data = await this.sentRequest(bundleid);
const V_AppStore = data.version;
const appLink = data.trackViewUrl;
if (V_AppStore === Version) {
return this.responseApi('Yes', appLink);
} else {
return this.responseApi('No', appLink);
}
}
responseApi(Status, url) {
if (Status === 'Yes') {
const json = {
status: 'success',
status_message: 'There is no application update',
};
return JSON.stringify(json);
} else {
const json = {
status: 'failed',
status_message: 'The version does not match. An update is required',
app_link: url,
};
return JSON.stringify(json);
}
}
}
// Example usage:
const app = new AppStoreInfoApp();
app.getInfoApp('your_bundle_id', 'your_version')
.then(response => console.log(response))
.catch(error => console.error(error));