src/models/content/ContentType.js
/**
* Model representing an Content Type.
*/
class ContentTypeModel {
/**
* @param {Object} response - JSON formatted response of content type.
* @param {Number} response.id - The content type id value
* @param {String} response.name - Name of the content type
* @param {String} response.description - Description of the content type
* @param {String} response.permanent_link - Category of the content type
* @param {String} response.created_at - Date in which the content type was created
* @param {String} response.updated_at - Date in which the content type 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.name = attributes.name;
/** @type {String} */
this.description = attributes.description;
/** @type {String} */
this.permanentLink = attributes.permanent_link;
/** @type {String} */
this.createdAt = attributes.created_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default ContentTypeModel;