src/models/trial/SiteMember.js
/**
* Model representing a site member.
*/
class SiteMemberModel {
/**
* @param {Object} response - JSON formatted response of a single site member
* @param {!Number} response.id - The id of the site member on the server
* @param {!String} response.type - The type of this object ('site members')
* @param {!String} response.member_type - Either 'pi' or 'patient'
* @param {String} response.created_at - Created at
* @param {String} response.updated_at - Updated at
* @param {String} response.first_consented_at - First consented at date
* @param {String} response.last_consented_at - Last consented at date
* @param {String} response.consent_status - The consent status
* @param {String} response.account_status - The account status
*/
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.consentStatus = attributes.consent_status;
/** @type {String} */
this.accountStatus = attributes.account_status;
/** @type {String} */
this.firstConsentedAt = attributes.first_consented_at;
/** @type {String} */
this.lastConsentedAt = attributes.last_consented_at;
/** @type {String} */
this.createdAt = attributes.created_at;
/** @type {String} */
this.memberType = attributes.member_type;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default SiteMemberModel;