commit 15a0f3bbe3f93074b2d5a046cec06b201c5a8543
parent 47741e75fa865cdd8f908a2aa32154e833f98520
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 18 Jun 2017 08:42:39 -0400
Add getKeys() method to API Client
Diffstat:
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/sync/syncAPIClient.js b/chrome/content/zotero/xpcom/sync/syncAPIClient.js
@@ -164,6 +164,35 @@ Zotero.Sync.APIClient.prototype = {
}),
+ getKeys: async function (libraryType, libraryTypeID, queryParams) {
+ var params = {
+ libraryType: libraryType,
+ libraryTypeID: libraryTypeID,
+ format: 'keys'
+ };
+ if (queryParams) {
+ for (let i in queryParams) {
+ params[i] = queryParams[i];
+ }
+ }
+
+ // TODO: Use pagination
+ var uri = this.buildRequestURI(params);
+
+ var options = {
+ successCodes: [200, 304]
+ };
+ var xmlhttp = await this.makeRequest("GET", uri, options);
+ if (xmlhttp.status == 304) {
+ return false;
+ }
+ return {
+ libraryVersion: this._getLastModifiedVersion(xmlhttp),
+ keys: xmlhttp.responseText.trim().split(/\n/).filter(key => key)
+ };
+ },
+
+
/**
* Return a promise for a JS object with object keys as keys and version
* numbers as values. By default, returns all objects in the library.