2020-05-04 04:53:28 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const api = require('../api.js');
|
|
|
|
const uri = require('../util/uri.js');
|
|
|
|
const AbstractList = require('./abstract_list.js');
|
|
|
|
const Pool = require('./pool.js');
|
|
|
|
|
|
|
|
class PoolList extends AbstractList {
|
|
|
|
static search(text, offset, limit, fields) {
|
|
|
|
return api.get(
|
2020-06-05 03:01:28 +02:00
|
|
|
uri.formatApiLink(
|
|
|
|
'pools', {
|
|
|
|
query: text,
|
|
|
|
offset: offset,
|
|
|
|
limit: limit,
|
|
|
|
fields: fields.join(','),
|
|
|
|
}))
|
2020-05-04 04:53:28 +02:00
|
|
|
.then(response => {
|
|
|
|
return Promise.resolve(Object.assign(
|
|
|
|
{},
|
|
|
|
response,
|
|
|
|
{results: PoolList.fromResponse(response.results)}));
|
|
|
|
});
|
|
|
|
}
|
2020-05-04 11:20:23 +02:00
|
|
|
|
|
|
|
hasPoolId(poolId) {
|
|
|
|
for (let pool of this._list) {
|
|
|
|
if (pool.id === poolId) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeById(poolId) {
|
|
|
|
for (let pool of this._list) {
|
|
|
|
if (pool.id === poolId) {
|
|
|
|
this.remove(pool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-04 04:53:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PoolList._itemClass = Pool;
|
|
|
|
PoolList._itemName = 'pool';
|
|
|
|
|
|
|
|
module.exports = PoolList;
|