2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-16 13:48:48 +02:00
|
|
|
import requests from '../utils/requests';
|
2015-05-21 17:59:38 +02:00
|
|
|
|
2015-08-04 15:06:02 +02:00
|
|
|
import { mergeOptions } from '../utils/general_utils';
|
2015-10-30 17:43:20 +01:00
|
|
|
import { generateOrderingQueryParams } from '../utils/url_utils';
|
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);
|
2015-08-04 15:06:02 +02:00
|
|
|
|
2016-01-18 10:53:01 +01:00
|
|
|
const queryParams = mergeOptions(
|
2015-08-04 15:06:02 +02:00
|
|
|
{
|
|
|
|
page,
|
|
|
|
pageSize,
|
|
|
|
ordering,
|
|
|
|
piece_id: pieceId
|
|
|
|
},
|
|
|
|
filterBy
|
|
|
|
);
|
|
|
|
|
|
|
|
return requests.get('editions_list', queryParams);
|
2015-05-21 17:59:38 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-01 17:43:38 +02:00
|
|
|
export default EditionListFetcher;
|