/**
* File Auto-Generated by the RICADO Gen 4 PHP API Project
*
* Do Not Edit this File Manually!
*/
import BaseModel from '../../../Models/BaseModel';
/**
* Model Class for a Shift Task
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class ShiftTaskModel extends BaseModel
{
/**
* ShiftTaskModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this Shift Task
*/
constructor(siteId)
{
super();
/**
* The Shift Task ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* The Packing Line ID this Task is associated with
*
* @type {string}
* @public
*/
this.packingLineId = "";
/**
* The Shift ID this Task is asssociated with
*
* @type {string}
* @public
*/
this.shiftId = "";
/**
* When this Task was Created
*
* @type {Date}
* @public
*/
this.createdTimestamp = new Date();
/**
* When this Task was Completed
*
* @type {?Date}
* @public
*/
this.completedTimestamp = null;
/**
* The User ID of the Author for this Task
*
* @type {?string}
* @public
*/
this.authorUserId = null;
/**
* The Name of the Author for this Task
*
* @type {string}
* @public
*/
this.authorName = "";
/**
* The Task Type
*
* @type {string}
* @public
*/
this.type = "";
/**
* An Array of Tag IDs for this Task
*
* @type {string[]}
* @public
*/
this.tags = [];
/**
* The Title of this Task
*
* @type {string}
* @public
*/
this.title = "";
/**
* The Content of this Task
*
* @type {string}
* @public
*/
this.content = "";
/**
* The Status of this Task
*
* @type {string}
* @public
*/
this.status = "";
/**
* Whether the Shift Task has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Shift Task was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this Shift Task
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **ShiftTaskModel** from a JSON Object or JSON String
*
* @static
* @public
* @param {Object<string, any>|string} json A JSON Object or JSON String
* @param {number} siteId The Site ID associated with this Shift Task
* @return {ShiftTaskModel}
*/
static fromJSON(json, siteId)
{
let model = new ShiftTaskModel(siteId);
/**
* The JSON Object
*
* @type {Object<string, any>}
*/
let jsonObject = {};
if(typeof json === 'string')
{
jsonObject = JSON.parse(json);
}
else if(typeof json === 'object')
{
jsonObject = json;
}
if('id' in jsonObject)
{
model.id = (function(){
if(typeof jsonObject['id'] !== 'string')
{
return String(jsonObject['id']);
}
return jsonObject['id'];
}());
}
if('packingLineId' in jsonObject)
{
model.packingLineId = (function(){
if(typeof jsonObject['packingLineId'] !== 'string')
{
return String(jsonObject['packingLineId']);
}
return jsonObject['packingLineId'];
}());
}
if('shiftId' in jsonObject)
{
model.shiftId = (function(){
if(typeof jsonObject['shiftId'] !== 'string')
{
return String(jsonObject['shiftId']);
}
return jsonObject['shiftId'];
}());
}
if('createdTimestamp' in jsonObject)
{
model.createdTimestamp = (function(){
if(typeof jsonObject['createdTimestamp'] !== 'string')
{
return new Date(String(jsonObject['createdTimestamp']));
}
return new Date(jsonObject['createdTimestamp']);
}());
}
if('completedTimestamp' in jsonObject)
{
model.completedTimestamp = (function(){
if(jsonObject['completedTimestamp'] === null)
{
return null;
}
if(typeof jsonObject['completedTimestamp'] !== 'string')
{
return new Date(String(jsonObject['completedTimestamp']));
}
return new Date(jsonObject['completedTimestamp']);
}());
}
if('authorUserId' in jsonObject)
{
model.authorUserId = (function(){
if(jsonObject['authorUserId'] === null)
{
return null;
}
if(typeof jsonObject['authorUserId'] !== 'string')
{
return String(jsonObject['authorUserId']);
}
return jsonObject['authorUserId'];
}());
}
if('authorName' in jsonObject)
{
model.authorName = (function(){
if(typeof jsonObject['authorName'] !== 'string')
{
return String(jsonObject['authorName']);
}
return jsonObject['authorName'];
}());
}
if('type' in jsonObject)
{
model.type = (function(){
if(typeof jsonObject['type'] !== 'string')
{
return String(jsonObject['type']);
}
return jsonObject['type'];
}());
}
if('tags' in jsonObject)
{
model.tags = (function(){
if(Array.isArray(jsonObject['tags']) !== true)
{
return [];
}
return jsonObject['tags'].map((tagsItem) => {
return (function(){
if(typeof tagsItem !== 'string')
{
return String(tagsItem);
}
return tagsItem;
}());
});
}());
}
if('title' in jsonObject)
{
model.title = (function(){
if(typeof jsonObject['title'] !== 'string')
{
return String(jsonObject['title']);
}
return jsonObject['title'];
}());
}
if('content' in jsonObject)
{
model.content = (function(){
if(typeof jsonObject['content'] !== 'string')
{
return String(jsonObject['content']);
}
return jsonObject['content'];
}());
}
if('status' in jsonObject)
{
model.status = (function(){
if(typeof jsonObject['status'] !== 'string')
{
return String(jsonObject['status']);
}
return jsonObject['status'];
}());
}
if('deleted' in jsonObject)
{
model.deleted = (function(){
if(typeof jsonObject['deleted'] !== 'boolean')
{
return Boolean(jsonObject['deleted']);
}
return jsonObject['deleted'];
}());
}
if('updateTimestamp' in jsonObject)
{
model.updateTimestamp = (function(){
if(typeof jsonObject['updateTimestamp'] !== 'string')
{
return new Date(String(jsonObject['updateTimestamp']));
}
return new Date(jsonObject['updateTimestamp']);
}());
}
return model;
}
}
export default ShiftTaskModel;
source