Add getKeys() method to API Client

This commit is contained in:
Dan Stillman 2017-06-18 08:42:39 -04:00
parent 47741e75fa
commit 15a0f3bbe3

View file

@ -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.