Skip to content

Commit 00fb5b4

Browse files
committed
introduce function getBib
for retrieving formatted reference for each item if requested via `options.include=bib`.
1 parent 1ab0e5c commit 00fb5b4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/response.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,18 @@ class ApiResponse {
5656
}
5757

5858
/**
59-
* Value of "Last-Modified-Version" header in response if present. Specialised classes provide
59+
* Bib available in the response if requested via `options.include=bib`. Specialised classes provide extracted meta data depending on context.
60+
* @return {object}
61+
*/
62+
getBib() {
63+
if('bib' in this.raw) {
64+
return this.raw.bib;
65+
}
66+
return null;
67+
}
68+
69+
/**
70+
* Value of "Last-Modified-Version" header in response if present. Specialised classes provide
6071
version depending on context
6172
* @return {?number} Version of the content in response
6273
*/
@@ -143,8 +154,16 @@ module:zotero-api-client~MultiReadResponse#getData}
143154
}
144155

145156
/**
146-
* @return {string} Total number of results
147-
*/
157+
* @return {Array} a list of formatted references (if requested via `options.include=bib`), indexes of the array match indexes of entities in {@link
158+
module:zotero-api-client~MultiReadResponse#getData}
159+
*/
160+
getBib() {
161+
return this.raw.map(r => 'bib' in r && r.bib || null);
162+
}
163+
164+
/**
165+
* @return {string} Total number of results
166+
*/
148167
getTotalResults() {
149168
return parseIntHeaders(this.response.headers, 'Total-Results');
150169
}

0 commit comments

Comments
 (0)