src/models/consult/Consultation.js
/**
* Model representing a video consultation.
*/
class ConsultationModel {
/**
* @param {Object} response - JSON formatted response of a consultation.
* @param {Number} response.id - The user role ID value
* @param {String} response.confirmed_at - The date when the consultation was confirmed
* @param {String} response.deleted_at - The date when the consultation was deleted
* @param {String} response.end_at - The date when the consultation ends
* @param {String} response.name - Name of the consultation
* @param {String} response.session_identity - The video session id
* @param {String} response.start_at - The date when the consultation starts
* @param {String} response.status - The status of the consultation
* @param {Boolean} response.created_at - The date when the consultation was created
* @param {Boolean} response.updated_at - The date when the consultation 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.confirmedAt = attributes.confirmed_at;
/** @type {String} */
this.deletedAt = attributes.deleted_at;
/** @type {String} */
this.endAt = attributes.end_at;
/** @type {String} */
this.name = attributes.name;
/** @type {String} */
this.sessionIdentity = attributes.session_identity;
/** @type {String} */
this.startAt = attributes.start_at;
/** @type {String} */
this.status = attributes.status;
/** @type {String} */
this.createdAt = attributes.created_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default ConsultationModel;