1 | 'use strict';
|
2 |
|
3 | var capiV2 = require('./utils/capi-v2');
|
4 |
|
5 | module.exports = function(opts) {
|
6 | var by = opts.by;
|
7 | if (!by && opts.uuid) {
|
8 | by = 'http://api.ft.com/things/' + opts.uuid;
|
9 | }
|
10 |
|
11 | var count = opts.count || 10;
|
12 | return capiV2({
|
13 | path: '/content?isAnnotatedBy=' + by
|
14 | + (opts.authority ? '&authority=' + opts.authority : '')
|
15 | + (opts.bindings ? '&bindings=' + opts.authority : ''),
|
16 | type: 'ContentAnnotatedBy'
|
17 | })
|
18 | .then(function(articles) {
|
19 |
|
20 | var items = Array.isArray(articles) ? articles : articles.content;
|
21 | return items.slice(0, count).map(function(article) {
|
22 | return article.apiUrl.replace('http://api.ft.com/content/', '');
|
23 | });
|
24 | })
|
25 | .then(function(articles) {
|
26 | articles.indexCount = articles.length;
|
27 | return articles;
|
28 | });
|
29 | };
|