1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-05 11:25:09 +01:00
onion/js/fetchers/piece_list_fetcher.js
Brett Sun 56044488d7 Replace mergeOptions with js-utility-belt's safeMerge
And avoid using safeMerge when a normal Object.assign() would do.
2016-06-14 17:57:59 +02:00

37 lines
941 B
JavaScript

'use strict';
import requests from '../utils/requests';
import { safeMerge } from '../utils/general';
import { generateOrderingQueryParams } from '../utils/url';
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 = safeMerge(
{
page,
pageSize,
search,
ordering
},
filterBy
);
return requests.get('pieces_list', queryParams);
},
fetchRequestActions() {
return requests.get('pieces_list_request_actions');
}
};
export default PieceListFetcher;