1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 05:31:58 +02:00
onion/js/fetchers/piece_list_fetcher.js

41 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

'use strict';
import requests from '../utils/requests';
2015-05-18 18:00:12 +02:00
import { mergeOptions } from '../utils/general_utils';
import { generateOrderingQueryParams } from '../utils/url_utils';
2015-05-20 16:44:45 +02:00
2015-05-19 17:16:01 +02:00
let PieceListFetcher = {
2015-05-19 17:01:28 +02:00
/**
* Fetches a list of pieces from the API.
* Can be called with all supplied queryparams the API.
*/
fetch(page, pageSize, search, orderBy, orderAsc, filterBy) {
let ordering = generateOrderingQueryParams(orderBy, orderAsc);
// filterBy is an object of acl key-value pairs.
// The values are booleans
let queryParams = mergeOptions(
{
page,
pageSize,
search,
ordering
},
filterBy
);
return requests.get('pieces_list', queryParams);
2015-07-01 19:05:47 +02:00
},
fetchRequestActions() {
return requests.get('pieces_list_request_actions');
2015-07-09 15:44:20 +02:00
},
fetchFirstEditionForPiece(pieceId) {
return requests.get('piece_first_edition_id', {'piece_id': pieceId});
2015-05-18 18:00:12 +02:00
}
};
2015-05-20 16:44:45 +02:00
export default PieceListFetcher;