src/models/flow/FlowDataGroup.js
/**
* Model representing an Flow Data Group (data_collection__captured_value_groups).
*/
class FlowDataGroup {
/**
* @param {Object} response - JSON formatted response of an entry.
* @param {Number} response.id - The entry id value
* @param {String} response.created_at - Date in which the user was created
* @param {String} response.owner_type - Type of owner, probably 'mobile_user'
* @param {String} response.submitted_at - Date in which the user was updated
* @param {String} response.updated_at - Date in which the user 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.ownerType = attributes.owner_type;
/** @type {String} */
this.submittedAt = attributes.submitted_at;
/** @type {String} */
this.updatedAt = attributes.updated_at;
}
}
export default FlowDataGroup;