src/models/consent/ConsentStrategy.js
/**
* Model representing a consent strategy.
*/
class ConsentStrategyModel {
/**
* @param {Object} response - JSON formatted response of a consent method.
* @param {Number} response.id - The consent strategy ID value
* @param {Boolean} response.name - The name of the consent strategy
* @param {String} response.strategy_type - The type of consent strategy: electronic, paper, waived
* @param {String} response.created_at - Date when the consent strategy was created
* @param {String} response.updated_at - Date when the consent strategy 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 {String} */
this.name = attributes.name;
/** @type {String} */
this.strategyType = attributes.strategy_type;
/** @type {String} */
this.createdAt = attributes.created_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default ConsentStrategyModel;