src/models/reminder/Event.js
/**
* Model representing an Event.
*/
class EventModel {
/**
* @param {Object} response - JSON formatted response of an event.
* @param {Number} response.id - The event id value
* @param {String} response.created_at - Date in which the event was created
* @param {String} response.date - Date
* @param {Any} response.extras - Extra information
* @param {Number} response.status - The status of this event [ACTIVE, COMPLETED_ON_TIME, COMPLETED_LATE, IGNORED, PAST, PENDING]
* @param {String} response.updated_at - Date in which the event was 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.createdAt = attributes.created_at;
/** @type {String} */
this.date = attributes.date;
/** @type {Any} */
this.extras = attributes.extras;
/** @type {Number} */
this.status = attributes.status;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default EventModel;