src/models/callback/Callback.js
import CallbackConditionModel from './CallbackCondition';
/**
* Model representing a callback. A callback returns information to the
* user when processing completes.
*
* @class Callback
*/
class CallbackModel {
/**
* @param {Object} response - JSON formatted response of a callback
* @param {String} response.action - The action to execute on callback return
* @param {Object} response.action_object - The object associated with the callback
* @param {String} response.action_owner_id - The action's owner
* @param {String} response.action_subject_id - The action's subject ID
* @param {String} response.action_subject_type - The action subject's type
* @param {String} response.callback_type - The type of callback
* @param {String} response.createdAt - When the callback was created
* @param {Number} response.id - The callback's id
* @param {Object} response.trigger - The callback trigger
* @param {String} response.updatedAt - When the callback was last updated
* @param {Number} response.contentId - The callback's associated content id
* @param {Object} response.conditionList - The conditions, if any, that are associated
* with the callback
*/
constructor(response = {}) {
/** @type {String} */
this.action = response.action;
/** @type {Object} */
this.actionObject = response.action_object;
/** @type {String} */
this.actionOwnerId = response.action_owner_id;
/** @type {String} */
this.actionSubject_id = response.action_subject_id;
/** @type {String} */
this.actionSubject_type = response.action_subject_type;
/** @type {String} */
this.callbackType = response.callback_type;
/** @type {String} */
this.createdAt = response.created_at;
/** @type {Number} */
this.id = response.id;
/** @type {Object} */
this.trigger = response.trigger;
/** @type {String} */
this.updatedAt = response.updated_at;
/** @type {Number} */
this.contentId = response.content_id;
if (response.conditionList) {
/** @type {CallbackCondition[]} */
this.conditionList = response.conditionList.map(obj => new CallbackConditionModel(obj));
}
}
}
export default CallbackModel;