1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00
onion/js/fetchers/piece_list_fetcher.js
2016-03-22 15:31:03 +01:00

37 lines
959 B
JavaScript

'use strict';
import requests from '../utils/requests';
import { mergeOptions } from '../utils/general_utils';
import { generateOrderingQueryParams } from '../utils/url_utils';
let PieceListFetcher = {
/**
* Fetches a list of pieces from the API.
* Can be called with all supplied queryparams the API.
*/
fetch({ page, pageSize, search, orderBy, orderAsc, filterBy }) {
const ordering = generateOrderingQueryParams(orderBy, orderAsc);
// filterBy is an object of acl key-value pairs.
// The values are booleans
const queryParams = mergeOptions(
{
page,
pageSize,
search,
ordering
},
filterBy
);
return requests.get('pieces_list', queryParams);
},
fetchRequestActions() {
return requests.get('pieces_list_request_actions');
}
};
export default PieceListFetcher;