-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (51 loc) · 1.54 KB
/
index.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
const request = require('request');
const marketplaceBaseURL = "https://marketplace.atlassian.com";
const getAddonSearchAPI = "/rest/2/addons/search/brief";
const getAddonInfoAPI = "/rest/2/addons/";
const pricingInfoPart = "/pricing/server/live"
let toString = Object.prototype.toString
// HTTP header
let headers = {
'Content-Type': 'application/json'
};
let addonSearchOption = {
url: marketplaceBaseURL + getAddonSearchAPI,
method: 'GET',
header: headers,
qs: {
"q": "*gantt*"
}
};
request(addonSearchOption, function(error, response, body) {
if (body) {
const bodyParse = JSON.parse(body);
const addons = bodyParse.addons;
addons.forEach(function(addon, i, addons) {
let addonKey = addon._links.alternate.href.split("/")[2];
request({
url: marketplaceBaseURL + getAddonInfoAPI + addonKey + pricingInfoPart,
method: 'GET',
header: headers,
},
function (err, res, infoBody) {
if (infoBody) {
const infoParse = JSON.parse(infoBody);
console.log(addon.name);
console.log("最終更新日:" + infoParse.lastModified);
infoParse.items.forEach(function (info, j, infos) {
console.log("ユーザ数:" + info.editionDescription);
console.log("新規:$ " + info.amount);
console.log("更新:$ " + info.renewalAmount);
});
}
if (err) {
console.log(err);
}
}
);
});
}
if (error) {
console.log(error);
}
});