2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-14 16:53:18 +02:00
|
|
|
import request from '../utils/request';
|
2015-05-21 17:59:38 +02:00
|
|
|
|
2016-06-13 16:25:56 +02:00
|
|
|
import { safeMerge } from '../utils/general';
|
2016-06-13 14:35:02 +02:00
|
|
|
import { generateOrderingQueryParams } from '../utils/url';
|
2015-05-21 17:59:38 +02:00
|
|
|
|
|
|
|
let EditionListFetcher = {
|
|
|
|
/**
|
|
|
|
* Fetches a list of editions from the API.
|
|
|
|
*/
|
2016-01-18 10:53:01 +01:00
|
|
|
fetch({ pieceId, page, pageSize, orderBy, orderAsc, filterBy }) {
|
|
|
|
const ordering = generateOrderingQueryParams(orderBy, orderAsc);
|
2016-06-14 16:53:18 +02:00
|
|
|
const query = safeMerge(
|
2015-08-04 15:06:02 +02:00
|
|
|
{
|
|
|
|
page,
|
|
|
|
pageSize,
|
2016-06-14 16:53:18 +02:00
|
|
|
ordering
|
2015-08-04 15:06:02 +02:00
|
|
|
},
|
|
|
|
filterBy
|
|
|
|
);
|
|
|
|
|
2016-06-14 16:53:18 +02:00
|
|
|
return request('editions_list', {
|
|
|
|
query,
|
|
|
|
urlTemplateSpec: { pieceId }
|
|
|
|
});
|
2015-05-21 17:59:38 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-01 17:43:38 +02:00
|
|
|
export default EditionListFetcher;
|