src/models/import/CsvExampleFile.js
/**
* Model representing a csv example file.
*/
class CsvExampleFileModel {
/**
* @param {Object} response - JSON formatted response of a single csv example file
* @param {!Number} response.id - The id of the csv example file on the server
* @param {!String} response.type - The type of this object ('csv_example_files')
* @param {!String} response.human_readable_name - Human readable name of the file
* @param {!String} response.platform_model - Platform model used for example `Trials::Site`
* @param {!String} response.file_url - File URL for the csv example file
* @param {!Date} [response.created_at] - Time at which the csv example file was created
* @param {!Date} [response.updated_at] - Time at which the csv example file 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.humanReadableName = attributes.human_readable_name;
/** @type {String} */
this.platformModel = attributes.platform_model;
/** @type {String} */
this.fileUrl = attributes.file_url;
/** @type {Date} */
this.createdAt = attributes.created_at;
/** @type {Date} */
this.updatedAt = attributes.updated_at;
}
}
export default CsvExampleFileModel;