src/models/import/BulkImport.js
/**
* Model representing a bulk import.
*/
class BulkImportModel {
/**
* @param {Object} response - JSON formatted response of a single bulk import
* @param {!Number} response.id - The id of the bulk import on the server
* @param {!String} response.type - The type of this object ('import_wizard__bulk_imports')
* @param {!String} response.platform_model - Platform model, such as `Trials::Site`
* @param {!String} response.separator - Separator, such as `|`
* @param {!Date} [response.created_at] - Time at which the bulk import was created
* @param {!Date} [response.updated_at] - Time at which the bulk import was updated
*/
constructor(response = {}) {
const _response = response.data || response; // if json api is passed in directly
const attributes = _response.attributes || _response; // if json api is passed in directly
if (_response.id) {
/** @type {Number} */
this.id = parseInt(_response.id, 10);
}
/** @type {String} */
this.platformModel = attributes.platform_model;
/** @type {String} */
this.separator = attributes.separator;
/** @type {Date} */
this.createdAt = attributes.created_at;
/** @type {Date} */
this.updatedAt = attributes.updated_at;
}
}
export default BulkImportModel;