src/services/ImportService.js
import JsonApiService from './JsonApiService';
import {
hasToken,
validate,
} from '../utilities/ValidationUtility';
import CsvExampleFile from '../helpers/import/CsvExampleFile';
/**
* Service handling Import calls with specific endpoints.
*
*/
class ImportService extends JsonApiService {
/**
* Update type to be dynamic_content__contents
*/
constructor() {
super('import_wizard__bulk_imports',
{
title: 'ImportService',
obj: 'bulkImport',
tokenRequired: ['delete', 'get', 'getChildren', 'insert', 'update']
});
}
/**
* Gets example files for the bulk import
*
* @throws {Clinical6Error} - If missing token or missing required parameters
* @param {Object} [options] - Options to modify the network call and storage options
* @param {String} [options.cacheMode] - Override the caching method for this call
* @return {Promise<any[]>} - Promise object that returns a list of files
*
* @example
* import { importService } from 'clinical6';
*
* // You will be able to access the example files using the `getExampleFiles` method.
* importService.getExampleFiles().then(files => console.log(files));
*
*/
async getExampleFiles(options = {}) {
validate('ImportService.getExampleFiles', hasToken());
options.url = `/v3/import_wizard/example_files`;
return super.get(CsvExampleFile, options);
}
}
export default ImportService;