All files / app/assets/javascripts/api bulk_imports_api.js

100% Statements 11/11
0% Branches 0/1
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33      102x 102x   102x   102x 1x         1x     102x 25x   102x 3x       3x              
import { buildApiUrl } from '~/api/api_utils';
import axios from '~/lib/utils/axios_utils';
 
const BULK_IMPORT_ENTITIES_PATH = '/api/:version/bulk_imports/:id/entities';
const BULK_IMPORTS_ENTITIES_PATH = '/api/:version/bulk_imports/entities';
const BULK_IMPORT_ENTITIES_FAILURES_PATH =
  '/api/:version/bulk_imports/:id/entities/:entity_id/failures';
 
export const getBulkImportHistory = (id, params = {}) => {
  const bulkImportHistoryUrl = buildApiUrl(BULK_IMPORT_ENTITIES_PATH).replace(
    ':id',
    encodeURIComponent(id),
  );
 
  return axios.get(bulkImportHistoryUrl, { params });
};
 
export const getBulkImportsHistory = (params) =>
  axios.get(buildApiUrl(BULK_IMPORTS_ENTITIES_PATH), { params });
 
export const getBulkImportFailures = (id, entityId, { page, perPage }) => {
  const failuresPath = buildApiUrl(BULK_IMPORT_ENTITIES_FAILURES_PATH)
    .replace(':id', encodeURIComponent(id))
    .replace(':entity_id', encodeURIComponent(entityId));
 
  return axios.get(failuresPath, {
    params: {
      page,
      per_page: perPage,
    },
  });
};