src/models/Status.js
/**
* Model representing a status.
*/
class StatusModel {
/**
* @param {Object} response - JSON formatted response of a single status
* @param {!Number} response.id - The id of the status on the server
* @param {!String} response.type - The type of this object ('statuss')
* @param {!String} response.value - Status value
*/
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.value = attributes.value;
}
}
export default StatusModel;