forked from rhapsodyn/vscode-evernote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
evernote-adapter.js
61 lines (44 loc) · 1.56 KB
/
evernote-adapter.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
'use strict'
const Evernote = require('evernote');
const vscode = require('vscode');
const config = vscode.workspace.getConfiguration("evernote");
const MAX_QUERY_COUNT = 20; //TODO only get 20 of a notebook
let client, noteStore;
//TODO should be hide by callback, BUT
function showStatusBarMsg(msg) {
vscode.window.setStatusBarMessage(msg, 2000);
}
function listNoteBooks() {
showStatusBarMsg("Requesting notebooks......");
client = new Evernote.Client({token: config.token});
noteStore = client.getNoteStore(config.noteStoreUrl);
return noteStore.listNotebooks();
}
function listAllNoteMetas(notebookGuid) {
showStatusBarMsg("Requesting all note metas......");
return noteStore.findNotesMetadata({notebookGuid}, 0, MAX_QUERY_COUNT, {includeTitle: true, includeTagGuids: true});
}
function getNoteContent(noteGuid) {
showStatusBarMsg("Requesting note content......");
return noteStore.getNoteContent(noteGuid);
}
function updateNoteContent(guid, title, content) {
showStatusBarMsg("Updating note content......");
return noteStore.updateNote({guid, title, content});
}
function createNotebook(title) {
showStatusBarMsg("Creating notebook: " + title + "......");
return noteStore.createNotebook({name: title});
}
function createNote(title, notebookGuid) {
showStatusBarMsg("Creating note: " + title + "......");
return noteStore.createNote({title, notebookGuid});
}
module.exports = {
listNoteBooks,
listAllNoteMetas,
getNoteContent,
updateNoteContent,
createNotebook,
createNote
};