2016-06-17 20:25:44 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-19 19:16:40 +02:00
|
|
|
const api = require('../api.js');
|
2017-01-20 21:51:04 +01:00
|
|
|
const uri = require('../util/uri.js');
|
2016-06-19 19:16:40 +02:00
|
|
|
const AbstractList = require('./abstract_list.js');
|
2016-06-17 20:25:44 +02:00
|
|
|
const Post = require('./post.js');
|
|
|
|
|
2016-06-19 19:16:40 +02:00
|
|
|
class PostList extends AbstractList {
|
|
|
|
static getAround(id, searchQuery) {
|
2017-01-20 21:51:04 +01:00
|
|
|
return api.get(
|
|
|
|
uri.formatApiLink(
|
|
|
|
'post', id, 'around', {query: searchQuery, fields: 'id'}));
|
2016-06-17 20:25:44 +02:00
|
|
|
}
|
|
|
|
|
2017-02-09 00:48:06 +01:00
|
|
|
static search(text, offset, limit, fields) {
|
2017-01-20 21:51:04 +01:00
|
|
|
return api.get(
|
|
|
|
uri.formatApiLink(
|
|
|
|
'posts', {
|
|
|
|
query: text,
|
2017-02-09 00:48:06 +01:00
|
|
|
offset: offset,
|
|
|
|
limit: limit,
|
2017-01-20 21:51:04 +01:00
|
|
|
fields: fields.join(','),
|
|
|
|
}))
|
|
|
|
.then(response => {
|
|
|
|
return Promise.resolve(Object.assign(
|
|
|
|
{},
|
|
|
|
response,
|
|
|
|
{results: PostList.fromResponse(response.results)}));
|
|
|
|
});
|
2016-06-17 20:25:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-19 19:16:40 +02:00
|
|
|
PostList._itemClass = Post;
|
|
|
|
PostList._itemName = 'post';
|
|
|
|
|
2016-06-17 20:25:44 +02:00
|
|
|
module.exports = PostList;
|