This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
/
list-all-project-notes.js
63 lines (48 loc) · 2.03 KB
/
list-all-project-notes.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
//
// GitHub: https://github.com/SERPWoo/API
//
// This code requests a project's Notes and outputs the Note ID, Note Timestamp, Note Type, Note Message
//
// This output is text format
//
// Last updated - Mar 7th, 2019 @ 10:45 EST (@MercenaryCarter https://github.com/MercenaryCarter and https://twitter.com/MercenaryCarter)
//
// The following modules required to be installed to run this successfully (choose between locally or globally):
// (install locally)
// : npm install request
// : npm install sprintf-js
//
// (install globally)
// : npm install request -g
// : npm install sprintf-js -g
//
// Run Command: nodejs list-all-project-notes.js
//
var request = require("request");
var sprintf=require("sprintf-js").sprintf;
// Get your API Key here: https://www.serpwoo.com/q/api/ (should be logged in)
var API_key = "API_KEY_HERE"
var Project_ID = 0 //input your Project ID
var url = "https://api.serpwoo.com/v1/projects/" + Project_ID + "/notes/?key=" + API_key
request({
url: url,
json: true
}, function (error, response, JsonData) {
if (!error && response.statusCode === 200) {
//console.log(JsonData) // Print the json response
//console.log("Successful: ", JsonData.success);
if (JsonData.success === 1) {
console.log("\n--\n");
console.log(sprintf("%-25s %-15s %-10s %-80s", "Note ID", "Timestamp", "Type", "Note"));
console.log(sprintf("%-25s %-15s %-10s %-80s", "-------", "---------", "----", "----"));
for(var project_id in JsonData.projects) {
for(var id in JsonData.projects[project_id]['notes']) {
console.log(sprintf("%-25s %-15s %-10s %-80s", id, JsonData.projects[project_id]['notes'][id]['note'].timestamp, JsonData.projects[project_id]['notes'][id].type, JsonData.projects[project_id]['notes'][id]['note'].message));
}
}
console.log("\n--\n");
}else {
console.log("Something went wrong: ", JsonData.error);
}
}
})