src/models/ediary/EntryTemplate.js
/**
* Model representing an EDiary Entry Group Template.
*/
class EntryTemplateModel {
/**
* @param {Object} response - JSON formatted response of an entry group template.
* @param {Number} response.id - The template id value
* @param {String} response.category - Category of the template
* @param {String} response.created_at - Date in which the template was created
* @param {String} response.updated_at - Date in which the template 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.category = attributes.category;
/** @type {String} */
this.createdAt = attributes.created_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default EntryTemplateModel;