src/models/consent/ConsentForm.js
/**
* Model representing a consent form.
*/
class ConsentFormModel {
/**
* @param {Object} response - JSON formatted response of a consent form.
* @param {Number} response.id - The consent form ID value
* @param {Boolean} response.enabled - Is consent form enabled
* @param {String} response.name - Name of the consent form
* @param {String} response.created_at - Date when the consent form was created
* @param {String} response.updated_at - Date when the consent form was last 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 {Boolean} */
this.enabled = attributes.enabled;
/** @type {String} */
this.name = attributes.name;
/** @type {String} */
this.createdAt = attributes.created_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default ConsentFormModel;