src/models/consent/ApproverGroup.js
import { fieldsToSnake } from '../../utilities/ClassUtility';
/**
* Model representing a consent approver group.
*/
class ApproverGroupModel {
/**
* @param {Object} response - JSON formatted response of a cohort assignment.
* @param {Number} response.id - The user role ID value
* @param {Boolean} response.name - The name of the consent approver group
* @param {Boolean} response.created_at - The date when the approver group was created
* @param {Boolean} response.updated_at - The date when the approver group was last updated
*/
constructor(response = {}) {
const _response = response.data || response; // if json api is passed in directly
const attributes = fieldsToSnake(_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.createdAt = attributes.created_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default ApproverGroupModel;