/**
* 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 Summary Report
*
* @class
* @hideconstructor
* @extends BaseModel
*/
class ShiftSummaryReportModel extends BaseModel
{
/**
* ShiftSummaryReportModel Constructor
*
* @protected
* @param {number} siteId The Site ID associated with this Shift Summary Report
*/
constructor(siteId)
{
super();
/**
* The Shift Summary Report ID
*
* @type {string}
* @public
*/
this.id = "";
/**
* The Packing Line ID this Summary Report is associated with
*
* @type {string}
* @public
*/
this.packingLineId = "";
/**
* The Shift ID this Summary Report relates to
*
* @type {string}
* @public
*/
this.shiftId = "";
/**
* When this Summary Report was Created
*
* @type {Date}
* @public
*/
this.createdTimestamp = new Date();
/**
* The Base64 Encoded PDF Report
*
* @type {?string}
* @public
*/
this.pdfReportContent = null;
/**
* The Filename that should be used with the PDF Report
*
* @type {?string}
* @public
*/
this.pdfReportFileName = null;
/**
* The SendGrid API Status indicating progress when sending emails
*
* @type {?{requestCount: number, requestTimestamp: ?Date, responseCode: ?number, responseMessage: ?string, completed: boolean}}
* @public
*/
this.sendGridApi = null;
/**
* Whether the Report is in the process of being Emailed
*
* @type {string}
* @public
*/
this.status = "";
/**
* An Array of Email Contacts that were sent this Summary Report
*
* @type {Array<{email: string, firstName: string, lastName: string}>}
* @public
*/
this.emailContacts = [];
/**
* Whether the Shift Summary Report has been deleted
*
* @type {boolean}
* @public
*/
this.deleted = false;
/**
* When the Shift Summary Report was last updated
*
* @type {Date}
* @public
*/
this.updateTimestamp = new Date();
/**
* The Site ID associated with this Shift Summary Report
*
* @type {number}
* @public
*/
this.siteId = siteId;
}
/**
* Create a new **ShiftSummaryReportModel** 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 Summary Report
* @return {ShiftSummaryReportModel}
*/
static fromJSON(json, siteId)
{
let model = new ShiftSummaryReportModel(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('pdfReportContent' in jsonObject)
{
model.pdfReportContent = (function(){
if(jsonObject['pdfReportContent'] === null)
{
return null;
}
if(typeof jsonObject['pdfReportContent'] !== 'string')
{
return String(jsonObject['pdfReportContent']);
}
return jsonObject['pdfReportContent'];
}());
}
if('pdfReportFileName' in jsonObject)
{
model.pdfReportFileName = (function(){
if(jsonObject['pdfReportFileName'] === null)
{
return null;
}
if(typeof jsonObject['pdfReportFileName'] !== 'string')
{
return String(jsonObject['pdfReportFileName']);
}
return jsonObject['pdfReportFileName'];
}());
}
if('sendGridApi' in jsonObject)
{
model.sendGridApi = (function(){
if(jsonObject['sendGridApi'] === null)
{
return null;
}
let sendGridApiObject = {};
if(typeof jsonObject['sendGridApi'] === 'object' && 'requestCount' in jsonObject['sendGridApi'])
{
sendGridApiObject.requestCount = (function(){
if(typeof jsonObject['sendGridApi'].requestCount !== 'number')
{
return Number.isInteger(Number(jsonObject['sendGridApi'].requestCount)) ? Number(jsonObject['sendGridApi'].requestCount) : Math.floor(Number(jsonObject['sendGridApi'].requestCount));
}
return Number.isInteger(jsonObject['sendGridApi'].requestCount) ? jsonObject['sendGridApi'].requestCount : Math.floor(jsonObject['sendGridApi'].requestCount);
}());
}
else
{
sendGridApiObject.requestCount = 0;
}
if(typeof jsonObject['sendGridApi'] === 'object' && 'requestTimestamp' in jsonObject['sendGridApi'])
{
sendGridApiObject.requestTimestamp = (function(){
if(jsonObject['sendGridApi'].requestTimestamp === null)
{
return null;
}
if(typeof jsonObject['sendGridApi'].requestTimestamp !== 'string')
{
return new Date(String(jsonObject['sendGridApi'].requestTimestamp));
}
return new Date(jsonObject['sendGridApi'].requestTimestamp);
}());
}
else
{
sendGridApiObject.requestTimestamp = null;
}
if(typeof jsonObject['sendGridApi'] === 'object' && 'responseCode' in jsonObject['sendGridApi'])
{
sendGridApiObject.responseCode = (function(){
if(jsonObject['sendGridApi'].responseCode === null)
{
return null;
}
if(typeof jsonObject['sendGridApi'].responseCode !== 'number')
{
return Number.isInteger(Number(jsonObject['sendGridApi'].responseCode)) ? Number(jsonObject['sendGridApi'].responseCode) : Math.floor(Number(jsonObject['sendGridApi'].responseCode));
}
return Number.isInteger(jsonObject['sendGridApi'].responseCode) ? jsonObject['sendGridApi'].responseCode : Math.floor(jsonObject['sendGridApi'].responseCode);
}());
}
else
{
sendGridApiObject.responseCode = null;
}
if(typeof jsonObject['sendGridApi'] === 'object' && 'responseMessage' in jsonObject['sendGridApi'])
{
sendGridApiObject.responseMessage = (function(){
if(jsonObject['sendGridApi'].responseMessage === null)
{
return null;
}
if(typeof jsonObject['sendGridApi'].responseMessage !== 'string')
{
return String(jsonObject['sendGridApi'].responseMessage);
}
return jsonObject['sendGridApi'].responseMessage;
}());
}
else
{
sendGridApiObject.responseMessage = null;
}
if(typeof jsonObject['sendGridApi'] === 'object' && 'completed' in jsonObject['sendGridApi'])
{
sendGridApiObject.completed = (function(){
if(typeof jsonObject['sendGridApi'].completed !== 'boolean')
{
return Boolean(jsonObject['sendGridApi'].completed);
}
return jsonObject['sendGridApi'].completed;
}());
}
else
{
sendGridApiObject.completed = false;
}
return sendGridApiObject;
}());
}
if('status' in jsonObject)
{
model.status = (function(){
if(typeof jsonObject['status'] !== 'string')
{
return String(jsonObject['status']);
}
return jsonObject['status'];
}());
}
if('emailContacts' in jsonObject)
{
model.emailContacts = (function(){
if(Array.isArray(jsonObject['emailContacts']) !== true)
{
return [];
}
return jsonObject['emailContacts'].map((emailContactsItem) => {
return (function(){
let emailContactsItemObject = {};
if(typeof emailContactsItem === 'object' && 'email' in emailContactsItem)
{
emailContactsItemObject.email = (function(){
if(typeof emailContactsItem.email !== 'string')
{
return String(emailContactsItem.email);
}
return emailContactsItem.email;
}());
}
else
{
emailContactsItemObject.email = "";
}
if(typeof emailContactsItem === 'object' && 'firstName' in emailContactsItem)
{
emailContactsItemObject.firstName = (function(){
if(typeof emailContactsItem.firstName !== 'string')
{
return String(emailContactsItem.firstName);
}
return emailContactsItem.firstName;
}());
}
else
{
emailContactsItemObject.firstName = "";
}
if(typeof emailContactsItem === 'object' && 'lastName' in emailContactsItem)
{
emailContactsItemObject.lastName = (function(){
if(typeof emailContactsItem.lastName !== 'string')
{
return String(emailContactsItem.lastName);
}
return emailContactsItem.lastName;
}());
}
else
{
emailContactsItemObject.lastName = "";
}
return emailContactsItemObject;
}());
});
}());
}
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 ShiftSummaryReportModel;
source