src/models/consent/ConsentApprover.js
/**
* Model representing a consent approver.
*/
class ConsentApproverModel {
/**
* @param {Object} response - JSON formatted response of a consent version.
* @param {Number} response.id - The consent version ID value
* @param {String} response.first_name - First name of the consent approver
* @param {String} response.last_name - Last name of the consent approver
* @param {String} response.email - Email address of the consent approver
* @param {String} response.title - The title of the consent approver
* @param {String} response.password - The consent approver's password
*/
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.firstName = attributes.first_name;
/** @type {String} */
this.lastName = attributes.last_name;
/** @type {String} */
this.email = attributes.email;
/** @type {String} */
this.title = attributes.title;
/** @type {String} */
this.password = attributes.password;
}
}
export default ConsentApproverModel;