src/models/trial/Site.js
/**
* Model representing a site.
*/
class SiteModel {
/**
* @param {Object} response - JSON formatted response of a single site
* @param {!Number} response.id - The id of the site on the server
* @param {!String} response.type - The type of this object ('sites')
* @param {!String} response.site_id - Publicly listed id for site
* @param {!String} response.external_identifier - External id for site
* @param {!String} response.randomization_identifier - Randomization Identifier
* @param {!String} response.name - POC Name
* @param {!String} response.email - POC Email
* @param {!String} [response.phone_number] - POC Number
* @param {!String} [response.fax_number] - POC Fax Number
* @param {!Date} [response.created_at] - Time at which the site was created
* @param {!Date} [response.updated_at] - Time at which the site 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.siteId = attributes.site_id;
/** @type {String} */
this.externalIdentifier = attributes.external_identifier;
/** @type {String} */
this.randomizationIdentifier = attributes.randomization_identifier;
/** @type {String} */
this.name = attributes.name;
/** @type {String} */
this.contentType = attributes.content_type;
/** @type {String} */
this.email = attributes.email;
/** @type {String} */
this.phoneNumber = attributes.phone_number;
/** @type {String} */
this.faxNumber = attributes.fax_number;
/** @type {Date} */
this.createdAt = attributes.created_at;
/** @type {Date} */
this.updatedAt = attributes.updated_at;
}
}
export default SiteModel;