RICADO Gen 4 API JS Client

RICADO Gen 4 API JS Client

source

Controllers/Packhouse/Site/PackrunController.js

/**
 * File Auto-Generated by the RICADO Gen 4 PHP API Project
 * 
 * Do Not Edit this File Manually!
 */

import RequestHelper from '../../../RequestHelper';
import PackrunModel from '../../../Models/Packhouse/Site/PackrunModel';

/**
 * Controller Class for Packruns
 * 
 * @class
 */
class PackrunController
{
    /**
     * Retrieve a Packrun [GET /packhouse/sites/{siteId}/packruns/{id}]
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @return {Promise<PackrunModel>}
     */
    static getOne(siteId, id)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}`)
            .then((result) => {
                let resolveValue = (function(){
                    return PackrunModel.fromJSON(result, siteId);
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Update a Packrun [PATCH /packhouse/sites/{siteId}/packruns/{id}]
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @param {PackrunController.UpdateData} updateData The Packrun Update Data
     * @return {Promise<PackrunModel>}
     */
    static update(siteId, id, updateData)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.patchRequest(`/packhouse/sites/${siteId}/packruns/${id}`, updateData)
            .then((result) => {
                let resolveValue = (function(){
                    return PackrunModel.fromJSON(result, siteId);
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Delete a Packrun [DELETE /packhouse/sites/{siteId}/packruns/{id}]
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @return {Promise<boolean>}
     */
    static delete(siteId, id)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.deleteRequest(`/packhouse/sites/${siteId}/packruns/${id}`)
            .then((result) => {
                resolve(result ?? true);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Retrieve Comments [GET /packhouse/sites/{siteId}/packruns/{id}/comments]
     * 
     * Retrieves Comments for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @return {Promise<Array<PackrunController.CommentItem>>}
     */
    static getComments(siteId, id)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}/comments`)
            .then((result) => {
                let resolveValue = (function(){
                    if(Array.isArray(result) !== true)
                    {
                        return [];
                    }
                
                    return result.map((resultItem) => {
                        return (function(){
                            let resultItemObject = {};
                            
                            if(typeof resultItem === 'object' && 'id' in resultItem)
                            {
                                resultItemObject.id = (function(){
                                    if(typeof resultItem.id !== 'string')
                                    {
                                        return String(resultItem.id);
                                    }
                
                                    return resultItem.id;
                                }());
                            }
                            else
                            {
                                resultItemObject.id = "";
                            }
                            
                            if(typeof resultItem === 'object' && 'userAccount' in resultItem)
                            {
                                resultItemObject.userAccount = (function(){
                                    let userAccountObject = {};
                                    
                                    if(typeof resultItem.userAccount === 'object' && 'id' in resultItem.userAccount)
                                    {
                                        userAccountObject.id = (function(){
                                            if(resultItem.userAccount.id === null)
                                            {
                                                return null;
                                            }
                
                                            if(typeof resultItem.userAccount.id !== 'string')
                                            {
                                                return String(resultItem.userAccount.id);
                                            }
                
                                            return resultItem.userAccount.id;
                                        }());
                                    }
                                    else
                                    {
                                        userAccountObject.id = null;
                                    }
                                    
                                    if(typeof resultItem.userAccount === 'object' && 'firstName' in resultItem.userAccount)
                                    {
                                        userAccountObject.firstName = (function(){
                                            if(resultItem.userAccount.firstName === null)
                                            {
                                                return null;
                                            }
                
                                            if(typeof resultItem.userAccount.firstName !== 'string')
                                            {
                                                return String(resultItem.userAccount.firstName);
                                            }
                
                                            return resultItem.userAccount.firstName;
                                        }());
                                    }
                                    else
                                    {
                                        userAccountObject.firstName = null;
                                    }
                                    
                                    if(typeof resultItem.userAccount === 'object' && 'lastName' in resultItem.userAccount)
                                    {
                                        userAccountObject.lastName = (function(){
                                            if(resultItem.userAccount.lastName === null)
                                            {
                                                return null;
                                            }
                
                                            if(typeof resultItem.userAccount.lastName !== 'string')
                                            {
                                                return String(resultItem.userAccount.lastName);
                                            }
                
                                            return resultItem.userAccount.lastName;
                                        }());
                                    }
                                    else
                                    {
                                        userAccountObject.lastName = null;
                                    }
                
                                    return userAccountObject;
                                }());
                            }
                            else
                            {
                                resultItemObject.userAccount = (function(){
                                    let userAccountDefaultValue = {};
                                    
                                    userAccountDefaultValue.id = null;
                                    
                                    userAccountDefaultValue.firstName = null;
                                    
                                    userAccountDefaultValue.lastName = null;
                                    
                                    return userAccountDefaultValue;
                                }());
                            }
                            
                            if(typeof resultItem === 'object' && 'content' in resultItem)
                            {
                                resultItemObject.content = (function(){
                                    if(resultItem.content === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof resultItem.content !== 'string')
                                    {
                                        return String(resultItem.content);
                                    }
                
                                    return resultItem.content;
                                }());
                            }
                            else
                            {
                                resultItemObject.content = null;
                            }
                            
                            if(typeof resultItem === 'object' && 'createdTimestamp' in resultItem)
                            {
                                resultItemObject.createdTimestamp = (function(){
                                    if(resultItem.createdTimestamp === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof resultItem.createdTimestamp !== 'string')
                                    {
                                        return new Date(String(resultItem.createdTimestamp));
                                    }
                
                                    return new Date(resultItem.createdTimestamp);
                                }());
                            }
                            else
                            {
                                resultItemObject.createdTimestamp = null;
                            }
                            
                            if(typeof resultItem === 'object' && 'updatedTimestamp' in resultItem)
                            {
                                resultItemObject.updatedTimestamp = (function(){
                                    if(resultItem.updatedTimestamp === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof resultItem.updatedTimestamp !== 'string')
                                    {
                                        return new Date(String(resultItem.updatedTimestamp));
                                    }
                
                                    return new Date(resultItem.updatedTimestamp);
                                }());
                            }
                            else
                            {
                                resultItemObject.updatedTimestamp = null;
                            }
                
                            return resultItemObject;
                        }());
                    });
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Create a Comment [POST /packhouse/sites/{siteId}/packruns/{id}/comments]
     * 
     * Create a Comment for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @param {string} content The Content of the New Comment
     * @return {Promise<PackrunController.CommentItem>}
     */
    static createComment(siteId, id, content)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.postRequest(`/packhouse/sites/${siteId}/packruns/${id}/comments`, {content})
            .then((result) => {
                let resolveValue = (function(){
                    let resultObject = {};
                    
                    if(typeof result === 'object' && 'id' in result)
                    {
                        resultObject.id = (function(){
                            if(typeof result.id !== 'string')
                            {
                                return String(result.id);
                            }
                
                            return result.id;
                        }());
                    }
                    else
                    {
                        resultObject.id = "";
                    }
                    
                    if(typeof result === 'object' && 'userAccount' in result)
                    {
                        resultObject.userAccount = (function(){
                            let userAccountObject = {};
                            
                            if(typeof result.userAccount === 'object' && 'id' in result.userAccount)
                            {
                                userAccountObject.id = (function(){
                                    if(result.userAccount.id === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.id !== 'string')
                                    {
                                        return String(result.userAccount.id);
                                    }
                
                                    return result.userAccount.id;
                                }());
                            }
                            else
                            {
                                userAccountObject.id = null;
                            }
                            
                            if(typeof result.userAccount === 'object' && 'firstName' in result.userAccount)
                            {
                                userAccountObject.firstName = (function(){
                                    if(result.userAccount.firstName === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.firstName !== 'string')
                                    {
                                        return String(result.userAccount.firstName);
                                    }
                
                                    return result.userAccount.firstName;
                                }());
                            }
                            else
                            {
                                userAccountObject.firstName = null;
                            }
                            
                            if(typeof result.userAccount === 'object' && 'lastName' in result.userAccount)
                            {
                                userAccountObject.lastName = (function(){
                                    if(result.userAccount.lastName === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.lastName !== 'string')
                                    {
                                        return String(result.userAccount.lastName);
                                    }
                
                                    return result.userAccount.lastName;
                                }());
                            }
                            else
                            {
                                userAccountObject.lastName = null;
                            }
                
                            return userAccountObject;
                        }());
                    }
                    else
                    {
                        resultObject.userAccount = (function(){
                            let userAccountDefaultValue = {};
                            
                            userAccountDefaultValue.id = null;
                            
                            userAccountDefaultValue.firstName = null;
                            
                            userAccountDefaultValue.lastName = null;
                            
                            return userAccountDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'content' in result)
                    {
                        resultObject.content = (function(){
                            if(result.content === null)
                            {
                                return null;
                            }
                
                            if(typeof result.content !== 'string')
                            {
                                return String(result.content);
                            }
                
                            return result.content;
                        }());
                    }
                    else
                    {
                        resultObject.content = null;
                    }
                    
                    if(typeof result === 'object' && 'createdTimestamp' in result)
                    {
                        resultObject.createdTimestamp = (function(){
                            if(result.createdTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.createdTimestamp !== 'string')
                            {
                                return new Date(String(result.createdTimestamp));
                            }
                
                            return new Date(result.createdTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.createdTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'updatedTimestamp' in result)
                    {
                        resultObject.updatedTimestamp = (function(){
                            if(result.updatedTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.updatedTimestamp !== 'string')
                            {
                                return new Date(String(result.updatedTimestamp));
                            }
                
                            return new Date(result.updatedTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.updatedTimestamp = null;
                    }
                
                    return resultObject;
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Retrieve a Comment [GET /packhouse/sites/{siteId}/packruns/{id}/comments/{commentId}]
     * 
     * Retrieves Comments for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @param {string} commentId The Comment ID
     * @return {Promise<PackrunController.CommentItem>}
     */
    static getOneComment(siteId, id, commentId)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}/comments/${commentId}`)
            .then((result) => {
                let resolveValue = (function(){
                    let resultObject = {};
                    
                    if(typeof result === 'object' && 'id' in result)
                    {
                        resultObject.id = (function(){
                            if(typeof result.id !== 'string')
                            {
                                return String(result.id);
                            }
                
                            return result.id;
                        }());
                    }
                    else
                    {
                        resultObject.id = "";
                    }
                    
                    if(typeof result === 'object' && 'userAccount' in result)
                    {
                        resultObject.userAccount = (function(){
                            let userAccountObject = {};
                            
                            if(typeof result.userAccount === 'object' && 'id' in result.userAccount)
                            {
                                userAccountObject.id = (function(){
                                    if(result.userAccount.id === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.id !== 'string')
                                    {
                                        return String(result.userAccount.id);
                                    }
                
                                    return result.userAccount.id;
                                }());
                            }
                            else
                            {
                                userAccountObject.id = null;
                            }
                            
                            if(typeof result.userAccount === 'object' && 'firstName' in result.userAccount)
                            {
                                userAccountObject.firstName = (function(){
                                    if(result.userAccount.firstName === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.firstName !== 'string')
                                    {
                                        return String(result.userAccount.firstName);
                                    }
                
                                    return result.userAccount.firstName;
                                }());
                            }
                            else
                            {
                                userAccountObject.firstName = null;
                            }
                            
                            if(typeof result.userAccount === 'object' && 'lastName' in result.userAccount)
                            {
                                userAccountObject.lastName = (function(){
                                    if(result.userAccount.lastName === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.lastName !== 'string')
                                    {
                                        return String(result.userAccount.lastName);
                                    }
                
                                    return result.userAccount.lastName;
                                }());
                            }
                            else
                            {
                                userAccountObject.lastName = null;
                            }
                
                            return userAccountObject;
                        }());
                    }
                    else
                    {
                        resultObject.userAccount = (function(){
                            let userAccountDefaultValue = {};
                            
                            userAccountDefaultValue.id = null;
                            
                            userAccountDefaultValue.firstName = null;
                            
                            userAccountDefaultValue.lastName = null;
                            
                            return userAccountDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'content' in result)
                    {
                        resultObject.content = (function(){
                            if(result.content === null)
                            {
                                return null;
                            }
                
                            if(typeof result.content !== 'string')
                            {
                                return String(result.content);
                            }
                
                            return result.content;
                        }());
                    }
                    else
                    {
                        resultObject.content = null;
                    }
                    
                    if(typeof result === 'object' && 'createdTimestamp' in result)
                    {
                        resultObject.createdTimestamp = (function(){
                            if(result.createdTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.createdTimestamp !== 'string')
                            {
                                return new Date(String(result.createdTimestamp));
                            }
                
                            return new Date(result.createdTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.createdTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'updatedTimestamp' in result)
                    {
                        resultObject.updatedTimestamp = (function(){
                            if(result.updatedTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.updatedTimestamp !== 'string')
                            {
                                return new Date(String(result.updatedTimestamp));
                            }
                
                            return new Date(result.updatedTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.updatedTimestamp = null;
                    }
                
                    return resultObject;
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Update a Comment [PATCH /packhouse/sites/{siteId}/packruns/{id}/comments/{commentId}]
     * 
     * Update a Comment for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @param {string} commentId The Comment ID
     * @param {string} content The Updated Content for the Comment
     * @return {Promise<PackrunController.CommentItem>}
     */
    static updateOneComment(siteId, id, commentId, content)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.patchRequest(`/packhouse/sites/${siteId}/packruns/${id}/comments/${commentId}`, {content})
            .then((result) => {
                let resolveValue = (function(){
                    let resultObject = {};
                    
                    if(typeof result === 'object' && 'id' in result)
                    {
                        resultObject.id = (function(){
                            if(typeof result.id !== 'string')
                            {
                                return String(result.id);
                            }
                
                            return result.id;
                        }());
                    }
                    else
                    {
                        resultObject.id = "";
                    }
                    
                    if(typeof result === 'object' && 'userAccount' in result)
                    {
                        resultObject.userAccount = (function(){
                            let userAccountObject = {};
                            
                            if(typeof result.userAccount === 'object' && 'id' in result.userAccount)
                            {
                                userAccountObject.id = (function(){
                                    if(result.userAccount.id === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.id !== 'string')
                                    {
                                        return String(result.userAccount.id);
                                    }
                
                                    return result.userAccount.id;
                                }());
                            }
                            else
                            {
                                userAccountObject.id = null;
                            }
                            
                            if(typeof result.userAccount === 'object' && 'firstName' in result.userAccount)
                            {
                                userAccountObject.firstName = (function(){
                                    if(result.userAccount.firstName === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.firstName !== 'string')
                                    {
                                        return String(result.userAccount.firstName);
                                    }
                
                                    return result.userAccount.firstName;
                                }());
                            }
                            else
                            {
                                userAccountObject.firstName = null;
                            }
                            
                            if(typeof result.userAccount === 'object' && 'lastName' in result.userAccount)
                            {
                                userAccountObject.lastName = (function(){
                                    if(result.userAccount.lastName === null)
                                    {
                                        return null;
                                    }
                
                                    if(typeof result.userAccount.lastName !== 'string')
                                    {
                                        return String(result.userAccount.lastName);
                                    }
                
                                    return result.userAccount.lastName;
                                }());
                            }
                            else
                            {
                                userAccountObject.lastName = null;
                            }
                
                            return userAccountObject;
                        }());
                    }
                    else
                    {
                        resultObject.userAccount = (function(){
                            let userAccountDefaultValue = {};
                            
                            userAccountDefaultValue.id = null;
                            
                            userAccountDefaultValue.firstName = null;
                            
                            userAccountDefaultValue.lastName = null;
                            
                            return userAccountDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'content' in result)
                    {
                        resultObject.content = (function(){
                            if(result.content === null)
                            {
                                return null;
                            }
                
                            if(typeof result.content !== 'string')
                            {
                                return String(result.content);
                            }
                
                            return result.content;
                        }());
                    }
                    else
                    {
                        resultObject.content = null;
                    }
                    
                    if(typeof result === 'object' && 'createdTimestamp' in result)
                    {
                        resultObject.createdTimestamp = (function(){
                            if(result.createdTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.createdTimestamp !== 'string')
                            {
                                return new Date(String(result.createdTimestamp));
                            }
                
                            return new Date(result.createdTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.createdTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'updatedTimestamp' in result)
                    {
                        resultObject.updatedTimestamp = (function(){
                            if(result.updatedTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.updatedTimestamp !== 'string')
                            {
                                return new Date(String(result.updatedTimestamp));
                            }
                
                            return new Date(result.updatedTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.updatedTimestamp = null;
                    }
                
                    return resultObject;
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Delete a Comment [DELETE /packhouse/sites/{siteId}/packruns/{id}/comments/{commentId}]
     * 
     * Delete a Comment for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @param {string} commentId The Comment ID
     * @return {Promise<boolean>}
     */
    static deleteOneComment(siteId, id, commentId)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.deleteRequest(`/packhouse/sites/${siteId}/packruns/${id}/comments/${commentId}`)
            .then((result) => {
                resolve(result ?? true);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Retrieve a Packrun Summary Report [GET /packhouse/sites/{siteId}/packruns/{id}/summaryReport]
     * 
     * Retrieves a Summary Report for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @return {Promise<PackrunController.PackrunSummaryReport>}
     */
    static getSummaryReport(siteId, id)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}/summaryReport`)
            .then((result) => {
                let resolveValue = (function(){
                    let resultObject = {};
                    
                    if(typeof result === 'object' && 'id' in result)
                    {
                        resultObject.id = (function(){
                            if(typeof result.id !== 'string')
                            {
                                return String(result.id);
                            }
                
                            return result.id;
                        }());
                    }
                    else
                    {
                        resultObject.id = "";
                    }
                    
                    if(typeof result === 'object' && 'name' in result)
                    {
                        resultObject.name = (function(){
                            if(typeof result.name !== 'string')
                            {
                                return String(result.name);
                            }
                
                            return result.name;
                        }());
                    }
                    else
                    {
                        resultObject.name = "";
                    }
                    
                    if(typeof result === 'object' && 'createdTimestamp' in result)
                    {
                        resultObject.createdTimestamp = (function(){
                            if(typeof result.createdTimestamp !== 'string')
                            {
                                return new Date(String(result.createdTimestamp));
                            }
                
                            return new Date(result.createdTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.createdTimestamp = new Date();
                    }
                    
                    if(typeof result === 'object' && 'growerName' in result)
                    {
                        resultObject.growerName = (function(){
                            if(typeof result.growerName !== 'string')
                            {
                                return String(result.growerName);
                            }
                
                            return result.growerName;
                        }());
                    }
                    else
                    {
                        resultObject.growerName = "";
                    }
                    
                    if(typeof result === 'object' && 'growerCode' in result)
                    {
                        resultObject.growerCode = (function(){
                            if(typeof result.growerCode !== 'string')
                            {
                                return String(result.growerCode);
                            }
                
                            return result.growerCode;
                        }());
                    }
                    else
                    {
                        resultObject.growerCode = "";
                    }
                    
                    if(typeof result === 'object' && 'maturityArea' in result)
                    {
                        resultObject.maturityArea = (function(){
                            if(result.maturityArea === null)
                            {
                                return null;
                            }
                
                            if(typeof result.maturityArea !== 'string')
                            {
                                return String(result.maturityArea);
                            }
                
                            return result.maturityArea;
                        }());
                    }
                    else
                    {
                        resultObject.maturityArea = null;
                    }
                    
                    if(typeof result === 'object' && 'startTimestamp' in result)
                    {
                        resultObject.startTimestamp = (function(){
                            if(result.startTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.startTimestamp !== 'string')
                            {
                                return new Date(String(result.startTimestamp));
                            }
                
                            return new Date(result.startTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.startTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'finishTimestamp' in result)
                    {
                        resultObject.finishTimestamp = (function(){
                            if(result.finishTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.finishTimestamp !== 'string')
                            {
                                return new Date(String(result.finishTimestamp));
                            }
                
                            return new Date(result.finishTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.finishTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'allocatedBins' in result)
                    {
                        resultObject.allocatedBins = (function(){
                            if(typeof result.allocatedBins !== 'number')
                            {
                                return Number.isInteger(Number(result.allocatedBins)) ? Number(result.allocatedBins) : Math.floor(Number(result.allocatedBins));
                            }
                
                            return Number.isInteger(result.allocatedBins) ? result.allocatedBins : Math.floor(result.allocatedBins);
                        }());
                    }
                    else
                    {
                        resultObject.allocatedBins = 0;
                    }
                    
                    if(typeof result === 'object' && 'timeBatches' in result)
                    {
                        resultObject.timeBatches = (function(){
                            if(Array.isArray(result.timeBatches) !== true)
                            {
                                return [];
                            }
                
                            return result.timeBatches.map((timeBatchesItem) => {
                                return (function(){
                                    let timeBatchesItemObject = {};
                                    
                                    if(typeof timeBatchesItem === 'object' && 'id' in timeBatchesItem)
                                    {
                                        timeBatchesItemObject.id = (function(){
                                            if(typeof timeBatchesItem.id !== 'string')
                                            {
                                                return String(timeBatchesItem.id);
                                            }
                
                                            return timeBatchesItem.id;
                                        }());
                                    }
                                    else
                                    {
                                        timeBatchesItemObject.id = "";
                                    }
                                    
                                    if(typeof timeBatchesItem === 'object' && 'timestamp' in timeBatchesItem)
                                    {
                                        timeBatchesItemObject.timestamp = (function(){
                                            if(typeof timeBatchesItem.timestamp !== 'string')
                                            {
                                                return new Date(String(timeBatchesItem.timestamp));
                                            }
                
                                            return new Date(timeBatchesItem.timestamp);
                                        }());
                                    }
                                    else
                                    {
                                        timeBatchesItemObject.timestamp = new Date();
                                    }
                
                                    return timeBatchesItemObject;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.timeBatches = [];
                    }
                    
                    if(typeof result === 'object' && 'variety' in result)
                    {
                        resultObject.variety = (function(){
                            let varietyObject = {};
                            
                            if(typeof result.variety === 'object' && 'id' in result.variety)
                            {
                                varietyObject.id = (function(){
                                    if(typeof result.variety.id !== 'string')
                                    {
                                        return String(result.variety.id);
                                    }
                
                                    return result.variety.id;
                                }());
                            }
                            else
                            {
                                varietyObject.id = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'code' in result.variety)
                            {
                                varietyObject.code = (function(){
                                    if(typeof result.variety.code !== 'string')
                                    {
                                        return String(result.variety.code);
                                    }
                
                                    return result.variety.code;
                                }());
                            }
                            else
                            {
                                varietyObject.code = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'name' in result.variety)
                            {
                                varietyObject.name = (function(){
                                    if(typeof result.variety.name !== 'string')
                                    {
                                        return String(result.variety.name);
                                    }
                
                                    return result.variety.name;
                                }());
                            }
                            else
                            {
                                varietyObject.name = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'description' in result.variety)
                            {
                                varietyObject.description = (function(){
                                    if(typeof result.variety.description !== 'string')
                                    {
                                        return String(result.variety.description);
                                    }
                
                                    return result.variety.description;
                                }());
                            }
                            else
                            {
                                varietyObject.description = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'image' in result.variety)
                            {
                                varietyObject.image = (function(){
                                    if(typeof result.variety.image !== 'string')
                                    {
                                        return String(result.variety.image);
                                    }
                
                                    return result.variety.image;
                                }());
                            }
                            else
                            {
                                varietyObject.image = "";
                            }
                
                            return varietyObject;
                        }());
                    }
                    else
                    {
                        resultObject.variety = (function(){
                            let varietyDefaultValue = {};
                            
                            varietyDefaultValue.id = "";
                            
                            varietyDefaultValue.code = "";
                            
                            varietyDefaultValue.name = "";
                            
                            varietyDefaultValue.description = "";
                            
                            varietyDefaultValue.image = "";
                            
                            return varietyDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'growingMethod' in result)
                    {
                        resultObject.growingMethod = (function(){
                            let growingMethodObject = {};
                            
                            if(typeof result.growingMethod === 'object' && 'id' in result.growingMethod)
                            {
                                growingMethodObject.id = (function(){
                                    if(typeof result.growingMethod.id !== 'string')
                                    {
                                        return String(result.growingMethod.id);
                                    }
                
                                    return result.growingMethod.id;
                                }());
                            }
                            else
                            {
                                growingMethodObject.id = "";
                            }
                            
                            if(typeof result.growingMethod === 'object' && 'code' in result.growingMethod)
                            {
                                growingMethodObject.code = (function(){
                                    if(typeof result.growingMethod.code !== 'string')
                                    {
                                        return String(result.growingMethod.code);
                                    }
                
                                    return result.growingMethod.code;
                                }());
                            }
                            else
                            {
                                growingMethodObject.code = "";
                            }
                            
                            if(typeof result.growingMethod === 'object' && 'name' in result.growingMethod)
                            {
                                growingMethodObject.name = (function(){
                                    if(typeof result.growingMethod.name !== 'string')
                                    {
                                        return String(result.growingMethod.name);
                                    }
                
                                    return result.growingMethod.name;
                                }());
                            }
                            else
                            {
                                growingMethodObject.name = "";
                            }
                            
                            if(typeof result.growingMethod === 'object' && 'description' in result.growingMethod)
                            {
                                growingMethodObject.description = (function(){
                                    if(typeof result.growingMethod.description !== 'string')
                                    {
                                        return String(result.growingMethod.description);
                                    }
                
                                    return result.growingMethod.description;
                                }());
                            }
                            else
                            {
                                growingMethodObject.description = "";
                            }
                
                            return growingMethodObject;
                        }());
                    }
                    else
                    {
                        resultObject.growingMethod = (function(){
                            let growingMethodDefaultValue = {};
                            
                            growingMethodDefaultValue.id = "";
                            
                            growingMethodDefaultValue.code = "";
                            
                            growingMethodDefaultValue.name = "";
                            
                            growingMethodDefaultValue.description = "";
                            
                            return growingMethodDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'packingLineId' in result)
                    {
                        resultObject.packingLineId = (function(){
                            if(typeof result.packingLineId !== 'string')
                            {
                                return String(result.packingLineId);
                            }
                
                            return result.packingLineId;
                        }());
                    }
                    else
                    {
                        resultObject.packingLineId = "";
                    }
                    
                    if(typeof result === 'object' && 'packingLineName' in result)
                    {
                        resultObject.packingLineName = (function(){
                            if(result.packingLineName === null)
                            {
                                return null;
                            }
                
                            if(typeof result.packingLineName !== 'string')
                            {
                                return String(result.packingLineName);
                            }
                
                            return result.packingLineName;
                        }());
                    }
                    else
                    {
                        resultObject.packingLineName = null;
                    }
                    
                    if(typeof result === 'object' && 'classTypes' in result)
                    {
                        resultObject.classTypes = (function(){
                            if(Array.isArray(result.classTypes) !== true)
                            {
                                return [];
                            }
                
                            return result.classTypes.map((classTypesItem) => {
                                return (function(){
                                    let classTypesItemObject = {};
                                    
                                    if(typeof classTypesItem === 'object' && 'classType' in classTypesItem)
                                    {
                                        classTypesItemObject.classType = (function(){
                                            if(typeof classTypesItem.classType !== 'string')
                                            {
                                                return String(classTypesItem.classType);
                                            }
                
                                            return classTypesItem.classType;
                                        }());
                                    }
                                    else
                                    {
                                        classTypesItemObject.classType = "";
                                    }
                                    
                                    if(typeof classTypesItem === 'object' && 'name' in classTypesItem)
                                    {
                                        classTypesItemObject.name = (function(){
                                            if(typeof classTypesItem.name !== 'string')
                                            {
                                                return String(classTypesItem.name);
                                            }
                
                                            return classTypesItem.name;
                                        }());
                                    }
                                    else
                                    {
                                        classTypesItemObject.name = "";
                                    }
                
                                    return classTypesItemObject;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.classTypes = [];
                    }
                    
                    if(typeof result === 'object' && 'compacSizers' in result)
                    {
                        resultObject.compacSizers = (function(){
                            if(Array.isArray(result.compacSizers) !== true)
                            {
                                return [];
                            }
                
                            return result.compacSizers.map((compacSizersItem) => {
                                return (function(){
                                    if(typeof compacSizersItem !== 'object')
                                    {
                                        return Object(compacSizersItem);
                                    }
                
                                    return compacSizersItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.compacSizers = [];
                    }
                    
                    if(typeof result === 'object' && 'sizers' in result)
                    {
                        resultObject.sizers = (function(){
                            if(Array.isArray(result.sizers) !== true)
                            {
                                return [];
                            }
                
                            return result.sizers.map((sizersItem) => {
                                return (function(){
                                    let sizersItemObject = {};
                                    
                                    if(typeof sizersItem === 'object' && 'id' in sizersItem)
                                    {
                                        sizersItemObject.id = (function(){
                                            if(typeof sizersItem.id !== 'string')
                                            {
                                                return String(sizersItem.id);
                                            }
                
                                            return sizersItem.id;
                                        }());
                                    }
                                    else
                                    {
                                        sizersItemObject.id = "";
                                    }
                                    
                                    if(typeof sizersItem === 'object' && 'name' in sizersItem)
                                    {
                                        sizersItemObject.name = (function(){
                                            if(typeof sizersItem.name !== 'string')
                                            {
                                                return String(sizersItem.name);
                                            }
                
                                            return sizersItem.name;
                                        }());
                                    }
                                    else
                                    {
                                        sizersItemObject.name = "";
                                    }
                                    
                                    if(typeof sizersItem === 'object' && 'batchSummaries' in sizersItem)
                                    {
                                        sizersItemObject.batchSummaries = (function(){
                                            if(Array.isArray(sizersItem.batchSummaries) !== true)
                                            {
                                                return [];
                                            }
                
                                            return sizersItem.batchSummaries.map((batchSummariesItem) => {
                                                return (function(){
                                                    let batchSummariesItemObject = {};
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'id' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.id = (function(){
                                                            if(typeof batchSummariesItem.id !== 'string')
                                                            {
                                                                return String(batchSummariesItem.id);
                                                            }
                
                                                            return batchSummariesItem.id;
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.id = "";
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'number' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.number = (function(){
                                                            if(typeof batchSummariesItem.number !== 'number')
                                                            {
                                                                return Number.isInteger(Number(batchSummariesItem.number)) ? Number(batchSummariesItem.number) : Math.floor(Number(batchSummariesItem.number));
                                                            }
                
                                                            return Number.isInteger(batchSummariesItem.number) ? batchSummariesItem.number : Math.floor(batchSummariesItem.number);
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.number = 0;
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'name' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.name = (function(){
                                                            if(typeof batchSummariesItem.name !== 'string')
                                                            {
                                                                return String(batchSummariesItem.name);
                                                            }
                
                                                            return batchSummariesItem.name;
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.name = "";
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'varietyName' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.varietyName = (function(){
                                                            if(typeof batchSummariesItem.varietyName !== 'string')
                                                            {
                                                                return String(batchSummariesItem.varietyName);
                                                            }
                
                                                            return batchSummariesItem.varietyName;
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.varietyName = "";
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'timestamp' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.timestamp = (function(){
                                                            if(typeof batchSummariesItem.timestamp !== 'string')
                                                            {
                                                                return new Date(String(batchSummariesItem.timestamp));
                                                            }
                
                                                            return new Date(batchSummariesItem.timestamp);
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.timestamp = new Date();
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'totalFruitCount' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.totalFruitCount = (function(){
                                                            if(typeof batchSummariesItem.totalFruitCount !== 'number')
                                                            {
                                                                return Number.isInteger(Number(batchSummariesItem.totalFruitCount)) ? Number(batchSummariesItem.totalFruitCount) : Math.floor(Number(batchSummariesItem.totalFruitCount));
                                                            }
                
                                                            return Number.isInteger(batchSummariesItem.totalFruitCount) ? batchSummariesItem.totalFruitCount : Math.floor(batchSummariesItem.totalFruitCount);
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.totalFruitCount = 0;
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'totalFruitWeight' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.totalFruitWeight = (function(){
                                                            if(typeof batchSummariesItem.totalFruitWeight !== 'number')
                                                            {
                                                                return Number(batchSummariesItem.totalFruitWeight);
                                                            }
                
                                                            return batchSummariesItem.totalFruitWeight;
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.totalFruitWeight = 0;
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'recycleFruitCount' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.recycleFruitCount = (function(){
                                                            if(typeof batchSummariesItem.recycleFruitCount !== 'number')
                                                            {
                                                                return Number.isInteger(Number(batchSummariesItem.recycleFruitCount)) ? Number(batchSummariesItem.recycleFruitCount) : Math.floor(Number(batchSummariesItem.recycleFruitCount));
                                                            }
                
                                                            return Number.isInteger(batchSummariesItem.recycleFruitCount) ? batchSummariesItem.recycleFruitCount : Math.floor(batchSummariesItem.recycleFruitCount);
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.recycleFruitCount = 0;
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'recycleFruitWeight' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.recycleFruitWeight = (function(){
                                                            if(typeof batchSummariesItem.recycleFruitWeight !== 'number')
                                                            {
                                                                return Number(batchSummariesItem.recycleFruitWeight);
                                                            }
                
                                                            return batchSummariesItem.recycleFruitWeight;
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.recycleFruitWeight = 0;
                                                    }
                                                    
                                                    if(typeof batchSummariesItem === 'object' && 'recyclePercentage' in batchSummariesItem)
                                                    {
                                                        batchSummariesItemObject.recyclePercentage = (function(){
                                                            if(typeof batchSummariesItem.recyclePercentage !== 'number')
                                                            {
                                                                return Number(batchSummariesItem.recyclePercentage);
                                                            }
                
                                                            return batchSummariesItem.recyclePercentage;
                                                        }());
                                                    }
                                                    else
                                                    {
                                                        batchSummariesItemObject.recyclePercentage = 0;
                                                    }
                
                                                    return batchSummariesItemObject;
                                                }());
                                            });
                                        }());
                                    }
                                    else
                                    {
                                        sizersItemObject.batchSummaries = [];
                                    }
                
                                    return sizersItemObject;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.sizers = [];
                    }
                    
                    if(typeof result === 'object' && 'rejectBinSummary' in result)
                    {
                        resultObject.rejectBinSummary = (function(){
                            if(typeof result.rejectBinSummary !== 'object')
                            {
                                return Object(result.rejectBinSummary);
                            }
                
                            return result.rejectBinSummary;
                        }());
                    }
                    else
                    {
                        resultObject.rejectBinSummary = {}
                    }
                    
                    if(typeof result === 'object' && 'binTipSummary' in result)
                    {
                        resultObject.binTipSummary = (function(){
                            if(typeof result.binTipSummary !== 'object')
                            {
                                return Object(result.binTipSummary);
                            }
                
                            return result.binTipSummary;
                        }());
                    }
                    else
                    {
                        resultObject.binTipSummary = {}
                    }
                    
                    if(typeof result === 'object' && 'classTypeTotals' in result)
                    {
                        resultObject.classTypeTotals = (function(){
                            if(Array.isArray(result.classTypeTotals) !== true)
                            {
                                return [];
                            }
                
                            return result.classTypeTotals.map((classTypeTotalsItem) => {
                                return (function(){
                                    if(typeof classTypeTotalsItem !== 'object')
                                    {
                                        return Object(classTypeTotalsItem);
                                    }
                
                                    return classTypeTotalsItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.classTypeTotals = [];
                    }
                    
                    if(typeof result === 'object' && 'class1SizerSummary' in result)
                    {
                        resultObject.class1SizerSummary = (function(){
                            if(Array.isArray(result.class1SizerSummary) !== true)
                            {
                                return [];
                            }
                
                            return result.class1SizerSummary.map((class1SizerSummaryItem) => {
                                return (function(){
                                    if(typeof class1SizerSummaryItem !== 'object')
                                    {
                                        return Object(class1SizerSummaryItem);
                                    }
                
                                    return class1SizerSummaryItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.class1SizerSummary = [];
                    }
                    
                    if(typeof result === 'object' && 'class1TotalTrays' in result)
                    {
                        resultObject.class1TotalTrays = (function(){
                            if(typeof result.class1TotalTrays !== 'number')
                            {
                                return Number(result.class1TotalTrays);
                            }
                
                            return result.class1TotalTrays;
                        }());
                    }
                    else
                    {
                        resultObject.class1TotalTrays = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1AverageTrayWeight' in result)
                    {
                        resultObject.class1AverageTrayWeight = (function(){
                            if(typeof result.class1AverageTrayWeight !== 'number')
                            {
                                return Number(result.class1AverageTrayWeight);
                            }
                
                            return result.class1AverageTrayWeight;
                        }());
                    }
                    else
                    {
                        resultObject.class1AverageTrayWeight = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1FruitSizeProfile' in result)
                    {
                        resultObject.class1FruitSizeProfile = (function(){
                            if(Array.isArray(result.class1FruitSizeProfile) !== true)
                            {
                                return [];
                            }
                
                            return result.class1FruitSizeProfile.map((class1FruitSizeProfileItem) => {
                                return (function(){
                                    if(typeof class1FruitSizeProfileItem !== 'object')
                                    {
                                        return Object(class1FruitSizeProfileItem);
                                    }
                
                                    return class1FruitSizeProfileItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.class1FruitSizeProfile = [];
                    }
                    
                    if(typeof result === 'object' && 'class1AverageFruitSize' in result)
                    {
                        resultObject.class1AverageFruitSize = (function(){
                            if(typeof result.class1AverageFruitSize !== 'number')
                            {
                                return Number(result.class1AverageFruitSize);
                            }
                
                            return result.class1AverageFruitSize;
                        }());
                    }
                    else
                    {
                        resultObject.class1AverageFruitSize = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1TraysPerBin' in result)
                    {
                        resultObject.class1TraysPerBin = (function(){
                            if(typeof result.class1TraysPerBin !== 'number')
                            {
                                return Number(result.class1TraysPerBin);
                            }
                
                            return result.class1TraysPerBin;
                        }());
                    }
                    else
                    {
                        resultObject.class1TraysPerBin = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1FreshPackSummary' in result)
                    {
                        resultObject.class1FreshPackSummary = (function(){
                            if(Array.isArray(result.class1FreshPackSummary) !== true)
                            {
                                return [];
                            }
                
                            return result.class1FreshPackSummary.map((class1FreshPackSummaryItem) => {
                                return (function(){
                                    if(typeof class1FreshPackSummaryItem !== 'object')
                                    {
                                        return Object(class1FreshPackSummaryItem);
                                    }
                
                                    return class1FreshPackSummaryItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.class1FreshPackSummary = [];
                    }
                    
                    if(typeof result === 'object' && 'class2SizerSummary' in result)
                    {
                        resultObject.class2SizerSummary = (function(){
                            if(Array.isArray(result.class2SizerSummary) !== true)
                            {
                                return [];
                            }
                
                            return result.class2SizerSummary.map((class2SizerSummaryItem) => {
                                return (function(){
                                    if(typeof class2SizerSummaryItem !== 'object')
                                    {
                                        return Object(class2SizerSummaryItem);
                                    }
                
                                    return class2SizerSummaryItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.class2SizerSummary = [];
                    }
                    
                    if(typeof result === 'object' && 'class2TotalTrays' in result)
                    {
                        resultObject.class2TotalTrays = (function(){
                            if(typeof result.class2TotalTrays !== 'number')
                            {
                                return Number(result.class2TotalTrays);
                            }
                
                            return result.class2TotalTrays;
                        }());
                    }
                    else
                    {
                        resultObject.class2TotalTrays = 0;
                    }
                    
                    if(typeof result === 'object' && 'class2AverageTrayWeight' in result)
                    {
                        resultObject.class2AverageTrayWeight = (function(){
                            if(typeof result.class2AverageTrayWeight !== 'number')
                            {
                                return Number(result.class2AverageTrayWeight);
                            }
                
                            return result.class2AverageTrayWeight;
                        }());
                    }
                    else
                    {
                        resultObject.class2AverageTrayWeight = 0;
                    }
                    
                    if(typeof result === 'object' && 'class2FreshPackSummary' in result)
                    {
                        resultObject.class2FreshPackSummary = (function(){
                            if(Array.isArray(result.class2FreshPackSummary) !== true)
                            {
                                return [];
                            }
                
                            return result.class2FreshPackSummary.map((class2FreshPackSummaryItem) => {
                                return (function(){
                                    if(typeof class2FreshPackSummaryItem !== 'object')
                                    {
                                        return Object(class2FreshPackSummaryItem);
                                    }
                
                                    return class2FreshPackSummaryItem;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.class2FreshPackSummary = [];
                    }
                
                    return resultObject;
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Retrieve a Packrun Infeed Report [GET /packhouse/sites/{siteId}/packruns/{id}/infeedReport]
     * 
     * Retrieves an Infeed Report for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @return {Promise<PackrunController.PackrunInfeedReport>}
     */
    static getInfeedReport(siteId, id)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}/infeedReport`)
            .then((result) => {
                let resolveValue = (function(){
                    let resultObject = {};
                    
                    if(typeof result === 'object' && 'id' in result)
                    {
                        resultObject.id = (function(){
                            if(typeof result.id !== 'string')
                            {
                                return String(result.id);
                            }
                
                            return result.id;
                        }());
                    }
                    else
                    {
                        resultObject.id = "";
                    }
                    
                    if(typeof result === 'object' && 'name' in result)
                    {
                        resultObject.name = (function(){
                            if(typeof result.name !== 'string')
                            {
                                return String(result.name);
                            }
                
                            return result.name;
                        }());
                    }
                    else
                    {
                        resultObject.name = "";
                    }
                    
                    if(typeof result === 'object' && 'createdTimestamp' in result)
                    {
                        resultObject.createdTimestamp = (function(){
                            if(typeof result.createdTimestamp !== 'string')
                            {
                                return new Date(String(result.createdTimestamp));
                            }
                
                            return new Date(result.createdTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.createdTimestamp = new Date();
                    }
                    
                    if(typeof result === 'object' && 'startTimestamp' in result)
                    {
                        resultObject.startTimestamp = (function(){
                            if(result.startTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.startTimestamp !== 'string')
                            {
                                return new Date(String(result.startTimestamp));
                            }
                
                            return new Date(result.startTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.startTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'finishTimestamp' in result)
                    {
                        resultObject.finishTimestamp = (function(){
                            if(result.finishTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.finishTimestamp !== 'string')
                            {
                                return new Date(String(result.finishTimestamp));
                            }
                
                            return new Date(result.finishTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.finishTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'packingLineId' in result)
                    {
                        resultObject.packingLineId = (function(){
                            if(typeof result.packingLineId !== 'string')
                            {
                                return String(result.packingLineId);
                            }
                
                            return result.packingLineId;
                        }());
                    }
                    else
                    {
                        resultObject.packingLineId = "";
                    }
                    
                    if(typeof result === 'object' && 'packingLineName' in result)
                    {
                        resultObject.packingLineName = (function(){
                            if(result.packingLineName === null)
                            {
                                return null;
                            }
                
                            if(typeof result.packingLineName !== 'string')
                            {
                                return String(result.packingLineName);
                            }
                
                            return result.packingLineName;
                        }());
                    }
                    else
                    {
                        resultObject.packingLineName = null;
                    }
                    
                    if(typeof result === 'object' && 'growerName' in result)
                    {
                        resultObject.growerName = (function(){
                            if(typeof result.growerName !== 'string')
                            {
                                return String(result.growerName);
                            }
                
                            return result.growerName;
                        }());
                    }
                    else
                    {
                        resultObject.growerName = "";
                    }
                    
                    if(typeof result === 'object' && 'growerCode' in result)
                    {
                        resultObject.growerCode = (function(){
                            if(typeof result.growerCode !== 'string')
                            {
                                return String(result.growerCode);
                            }
                
                            return result.growerCode;
                        }());
                    }
                    else
                    {
                        resultObject.growerCode = "";
                    }
                    
                    if(typeof result === 'object' && 'maturityArea' in result)
                    {
                        resultObject.maturityArea = (function(){
                            if(result.maturityArea === null)
                            {
                                return null;
                            }
                
                            if(typeof result.maturityArea !== 'string')
                            {
                                return String(result.maturityArea);
                            }
                
                            return result.maturityArea;
                        }());
                    }
                    else
                    {
                        resultObject.maturityArea = null;
                    }
                    
                    if(typeof result === 'object' && 'allocatedBins' in result)
                    {
                        resultObject.allocatedBins = (function(){
                            if(typeof result.allocatedBins !== 'number')
                            {
                                return Number.isInteger(Number(result.allocatedBins)) ? Number(result.allocatedBins) : Math.floor(Number(result.allocatedBins));
                            }
                
                            return Number.isInteger(result.allocatedBins) ? result.allocatedBins : Math.floor(result.allocatedBins);
                        }());
                    }
                    else
                    {
                        resultObject.allocatedBins = 0;
                    }
                    
                    if(typeof result === 'object' && 'tippedBins' in result)
                    {
                        resultObject.tippedBins = (function(){
                            if(typeof result.tippedBins !== 'number')
                            {
                                return Number.isInteger(Number(result.tippedBins)) ? Number(result.tippedBins) : Math.floor(Number(result.tippedBins));
                            }
                
                            return Number.isInteger(result.tippedBins) ? result.tippedBins : Math.floor(result.tippedBins);
                        }());
                    }
                    else
                    {
                        resultObject.tippedBins = 0;
                    }
                    
                    if(typeof result === 'object' && 'softSortRejectWeight' in result)
                    {
                        resultObject.softSortRejectWeight = (function(){
                            if(typeof result.softSortRejectWeight !== 'number')
                            {
                                return Number(result.softSortRejectWeight);
                            }
                
                            return result.softSortRejectWeight;
                        }());
                    }
                    else
                    {
                        resultObject.softSortRejectWeight = 0;
                    }
                    
                    if(typeof result === 'object' && 'softSortRejectPercentage' in result)
                    {
                        resultObject.softSortRejectPercentage = (function(){
                            if(typeof result.softSortRejectPercentage !== 'number')
                            {
                                return Number(result.softSortRejectPercentage);
                            }
                
                            return result.softSortRejectPercentage;
                        }());
                    }
                    else
                    {
                        resultObject.softSortRejectPercentage = 0;
                    }
                    
                    if(typeof result === 'object' && 'softSortEventsPerBin' in result)
                    {
                        resultObject.softSortEventsPerBin = (function(){
                            if(typeof result.softSortEventsPerBin !== 'number')
                            {
                                return Number(result.softSortEventsPerBin);
                            }
                
                            return result.softSortEventsPerBin;
                        }());
                    }
                    else
                    {
                        resultObject.softSortEventsPerBin = 0;
                    }
                    
                    if(typeof result === 'object' && 'totalSoftSortEventsCount' in result)
                    {
                        resultObject.totalSoftSortEventsCount = (function(){
                            if(typeof result.totalSoftSortEventsCount !== 'number')
                            {
                                return Number.isInteger(Number(result.totalSoftSortEventsCount)) ? Number(result.totalSoftSortEventsCount) : Math.floor(Number(result.totalSoftSortEventsCount));
                            }
                
                            return Number.isInteger(result.totalSoftSortEventsCount) ? result.totalSoftSortEventsCount : Math.floor(result.totalSoftSortEventsCount);
                        }());
                    }
                    else
                    {
                        resultObject.totalSoftSortEventsCount = 0;
                    }
                    
                    if(typeof result === 'object' && 'averageSoftSortEventsDuration' in result)
                    {
                        resultObject.averageSoftSortEventsDuration = (function(){
                            if(typeof result.averageSoftSortEventsDuration !== 'number')
                            {
                                return Number(result.averageSoftSortEventsDuration);
                            }
                
                            return result.averageSoftSortEventsDuration;
                        }());
                    }
                    else
                    {
                        resultObject.averageSoftSortEventsDuration = 0;
                    }
                    
                    if(typeof result === 'object' && 'totalSoftSortEventsDuration' in result)
                    {
                        resultObject.totalSoftSortEventsDuration = (function(){
                            if(typeof result.totalSoftSortEventsDuration !== 'number')
                            {
                                return Number(result.totalSoftSortEventsDuration);
                            }
                
                            return result.totalSoftSortEventsDuration;
                        }());
                    }
                    else
                    {
                        resultObject.totalSoftSortEventsDuration = 0;
                    }
                    
                    if(typeof result === 'object' && 'softSortEventsIsAccurate' in result)
                    {
                        resultObject.softSortEventsIsAccurate = (function(){
                            if(result.softSortEventsIsAccurate === null)
                            {
                                return null;
                            }
                
                            if(typeof result.softSortEventsIsAccurate !== 'boolean')
                            {
                                return Boolean(result.softSortEventsIsAccurate);
                            }
                
                            return result.softSortEventsIsAccurate;
                        }());
                    }
                    else
                    {
                        resultObject.softSortEventsIsAccurate = null;
                    }
                    
                    if(typeof result === 'object' && 'softSortEventsNotAccurateReason' in result)
                    {
                        resultObject.softSortEventsNotAccurateReason = (function(){
                            if(result.softSortEventsNotAccurateReason === null)
                            {
                                return null;
                            }
                
                            if(typeof result.softSortEventsNotAccurateReason !== 'string')
                            {
                                return String(result.softSortEventsNotAccurateReason);
                            }
                
                            return result.softSortEventsNotAccurateReason;
                        }());
                    }
                    else
                    {
                        resultObject.softSortEventsNotAccurateReason = null;
                    }
                
                    return resultObject;
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Retrive a Packrun's Latest Summary Data [GET /packhouse/sites/{siteId}/packruns/{id}/latestSummaryData]
     * 
     * Retrieves the Latest Summary Data for a Packrun
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {string} id The Packrun ID
     * @return {Promise<PackrunController.PackrunLatestSummaryData>}
     */
    static getLatestSummaryData(siteId, id)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}/latestSummaryData`)
            .then((result) => {
                let resolveValue = (function(){
                    let resultObject = {};
                    
                    if(typeof result === 'object' && 'id' in result)
                    {
                        resultObject.id = (function(){
                            if(typeof result.id !== 'string')
                            {
                                return String(result.id);
                            }
                
                            return result.id;
                        }());
                    }
                    else
                    {
                        resultObject.id = "";
                    }
                    
                    if(typeof result === 'object' && 'name' in result)
                    {
                        resultObject.name = (function(){
                            if(typeof result.name !== 'string')
                            {
                                return String(result.name);
                            }
                
                            return result.name;
                        }());
                    }
                    else
                    {
                        resultObject.name = "";
                    }
                    
                    if(typeof result === 'object' && 'createdTimestamp' in result)
                    {
                        resultObject.createdTimestamp = (function(){
                            if(typeof result.createdTimestamp !== 'string')
                            {
                                return new Date(String(result.createdTimestamp));
                            }
                
                            return new Date(result.createdTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.createdTimestamp = new Date();
                    }
                    
                    if(typeof result === 'object' && 'growerName' in result)
                    {
                        resultObject.growerName = (function(){
                            if(typeof result.growerName !== 'string')
                            {
                                return String(result.growerName);
                            }
                
                            return result.growerName;
                        }());
                    }
                    else
                    {
                        resultObject.growerName = "";
                    }
                    
                    if(typeof result === 'object' && 'growerCode' in result)
                    {
                        resultObject.growerCode = (function(){
                            if(typeof result.growerCode !== 'string')
                            {
                                return String(result.growerCode);
                            }
                
                            return result.growerCode;
                        }());
                    }
                    else
                    {
                        resultObject.growerCode = "";
                    }
                    
                    if(typeof result === 'object' && 'maturityArea' in result)
                    {
                        resultObject.maturityArea = (function(){
                            if(result.maturityArea === null)
                            {
                                return null;
                            }
                
                            if(typeof result.maturityArea !== 'string')
                            {
                                return String(result.maturityArea);
                            }
                
                            return result.maturityArea;
                        }());
                    }
                    else
                    {
                        resultObject.maturityArea = null;
                    }
                    
                    if(typeof result === 'object' && 'startTimestamp' in result)
                    {
                        resultObject.startTimestamp = (function(){
                            if(result.startTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.startTimestamp !== 'string')
                            {
                                return new Date(String(result.startTimestamp));
                            }
                
                            return new Date(result.startTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.startTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'finishTimestamp' in result)
                    {
                        resultObject.finishTimestamp = (function(){
                            if(result.finishTimestamp === null)
                            {
                                return null;
                            }
                
                            if(typeof result.finishTimestamp !== 'string')
                            {
                                return new Date(String(result.finishTimestamp));
                            }
                
                            return new Date(result.finishTimestamp);
                        }());
                    }
                    else
                    {
                        resultObject.finishTimestamp = null;
                    }
                    
                    if(typeof result === 'object' && 'variety' in result)
                    {
                        resultObject.variety = (function(){
                            let varietyObject = {};
                            
                            if(typeof result.variety === 'object' && 'id' in result.variety)
                            {
                                varietyObject.id = (function(){
                                    if(typeof result.variety.id !== 'string')
                                    {
                                        return String(result.variety.id);
                                    }
                
                                    return result.variety.id;
                                }());
                            }
                            else
                            {
                                varietyObject.id = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'code' in result.variety)
                            {
                                varietyObject.code = (function(){
                                    if(typeof result.variety.code !== 'string')
                                    {
                                        return String(result.variety.code);
                                    }
                
                                    return result.variety.code;
                                }());
                            }
                            else
                            {
                                varietyObject.code = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'name' in result.variety)
                            {
                                varietyObject.name = (function(){
                                    if(typeof result.variety.name !== 'string')
                                    {
                                        return String(result.variety.name);
                                    }
                
                                    return result.variety.name;
                                }());
                            }
                            else
                            {
                                varietyObject.name = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'description' in result.variety)
                            {
                                varietyObject.description = (function(){
                                    if(typeof result.variety.description !== 'string')
                                    {
                                        return String(result.variety.description);
                                    }
                
                                    return result.variety.description;
                                }());
                            }
                            else
                            {
                                varietyObject.description = "";
                            }
                            
                            if(typeof result.variety === 'object' && 'image' in result.variety)
                            {
                                varietyObject.image = (function(){
                                    if(typeof result.variety.image !== 'string')
                                    {
                                        return String(result.variety.image);
                                    }
                
                                    return result.variety.image;
                                }());
                            }
                            else
                            {
                                varietyObject.image = "";
                            }
                
                            return varietyObject;
                        }());
                    }
                    else
                    {
                        resultObject.variety = (function(){
                            let varietyDefaultValue = {};
                            
                            varietyDefaultValue.id = "";
                            
                            varietyDefaultValue.code = "";
                            
                            varietyDefaultValue.name = "";
                            
                            varietyDefaultValue.description = "";
                            
                            varietyDefaultValue.image = "";
                            
                            return varietyDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'growingMethod' in result)
                    {
                        resultObject.growingMethod = (function(){
                            let growingMethodObject = {};
                            
                            if(typeof result.growingMethod === 'object' && 'id' in result.growingMethod)
                            {
                                growingMethodObject.id = (function(){
                                    if(typeof result.growingMethod.id !== 'string')
                                    {
                                        return String(result.growingMethod.id);
                                    }
                
                                    return result.growingMethod.id;
                                }());
                            }
                            else
                            {
                                growingMethodObject.id = "";
                            }
                            
                            if(typeof result.growingMethod === 'object' && 'code' in result.growingMethod)
                            {
                                growingMethodObject.code = (function(){
                                    if(typeof result.growingMethod.code !== 'string')
                                    {
                                        return String(result.growingMethod.code);
                                    }
                
                                    return result.growingMethod.code;
                                }());
                            }
                            else
                            {
                                growingMethodObject.code = "";
                            }
                            
                            if(typeof result.growingMethod === 'object' && 'name' in result.growingMethod)
                            {
                                growingMethodObject.name = (function(){
                                    if(typeof result.growingMethod.name !== 'string')
                                    {
                                        return String(result.growingMethod.name);
                                    }
                
                                    return result.growingMethod.name;
                                }());
                            }
                            else
                            {
                                growingMethodObject.name = "";
                            }
                            
                            if(typeof result.growingMethod === 'object' && 'description' in result.growingMethod)
                            {
                                growingMethodObject.description = (function(){
                                    if(typeof result.growingMethod.description !== 'string')
                                    {
                                        return String(result.growingMethod.description);
                                    }
                
                                    return result.growingMethod.description;
                                }());
                            }
                            else
                            {
                                growingMethodObject.description = "";
                            }
                
                            return growingMethodObject;
                        }());
                    }
                    else
                    {
                        resultObject.growingMethod = (function(){
                            let growingMethodDefaultValue = {};
                            
                            growingMethodDefaultValue.id = "";
                            
                            growingMethodDefaultValue.code = "";
                            
                            growingMethodDefaultValue.name = "";
                            
                            growingMethodDefaultValue.description = "";
                            
                            return growingMethodDefaultValue;
                        }());
                    }
                    
                    if(typeof result === 'object' && 'packingLineId' in result)
                    {
                        resultObject.packingLineId = (function(){
                            if(typeof result.packingLineId !== 'string')
                            {
                                return String(result.packingLineId);
                            }
                
                            return result.packingLineId;
                        }());
                    }
                    else
                    {
                        resultObject.packingLineId = "";
                    }
                    
                    if(typeof result === 'object' && 'packingLineName' in result)
                    {
                        resultObject.packingLineName = (function(){
                            if(typeof result.packingLineName !== 'string')
                            {
                                return String(result.packingLineName);
                            }
                
                            return result.packingLineName;
                        }());
                    }
                    else
                    {
                        resultObject.packingLineName = "";
                    }
                    
                    if(typeof result === 'object' && 'status' in result)
                    {
                        resultObject.status = (function(){
                            if(typeof result.status !== 'string')
                            {
                                return String(result.status);
                            }
                
                            return result.status;
                        }());
                    }
                    else
                    {
                        resultObject.status = "";
                    }
                    
                    if(typeof result === 'object' && 'allocatedBins' in result)
                    {
                        resultObject.allocatedBins = (function(){
                            if(typeof result.allocatedBins !== 'number')
                            {
                                return Number.isInteger(Number(result.allocatedBins)) ? Number(result.allocatedBins) : Math.floor(Number(result.allocatedBins));
                            }
                
                            return Number.isInteger(result.allocatedBins) ? result.allocatedBins : Math.floor(result.allocatedBins);
                        }());
                    }
                    else
                    {
                        resultObject.allocatedBins = 0;
                    }
                    
                    if(typeof result === 'object' && 'tippedBins' in result)
                    {
                        resultObject.tippedBins = (function(){
                            if(typeof result.tippedBins !== 'number')
                            {
                                return Number.isInteger(Number(result.tippedBins)) ? Number(result.tippedBins) : Math.floor(Number(result.tippedBins));
                            }
                
                            return Number.isInteger(result.tippedBins) ? result.tippedBins : Math.floor(result.tippedBins);
                        }());
                    }
                    else
                    {
                        resultObject.tippedBins = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1FruitSizeProfile' in result)
                    {
                        resultObject.class1FruitSizeProfile = (function(){
                            if(Array.isArray(result.class1FruitSizeProfile) !== true)
                            {
                                return [];
                            }
                
                            return result.class1FruitSizeProfile.map((class1FruitSizeProfileItem) => {
                                return (function(){
                                    let class1FruitSizeProfileItemObject = {};
                                    
                                    if(typeof class1FruitSizeProfileItem === 'object' && 'fruitSize' in class1FruitSizeProfileItem)
                                    {
                                        class1FruitSizeProfileItemObject.fruitSize = (function(){
                                            if(typeof class1FruitSizeProfileItem.fruitSize !== 'string')
                                            {
                                                return String(class1FruitSizeProfileItem.fruitSize);
                                            }
                
                                            return class1FruitSizeProfileItem.fruitSize;
                                        }());
                                    }
                                    else
                                    {
                                        class1FruitSizeProfileItemObject.fruitSize = "";
                                    }
                                    
                                    if(typeof class1FruitSizeProfileItem === 'object' && 'fruitCount' in class1FruitSizeProfileItem)
                                    {
                                        class1FruitSizeProfileItemObject.fruitCount = (function(){
                                            if(typeof class1FruitSizeProfileItem.fruitCount !== 'number')
                                            {
                                                return Number.isInteger(Number(class1FruitSizeProfileItem.fruitCount)) ? Number(class1FruitSizeProfileItem.fruitCount) : Math.floor(Number(class1FruitSizeProfileItem.fruitCount));
                                            }
                
                                            return Number.isInteger(class1FruitSizeProfileItem.fruitCount) ? class1FruitSizeProfileItem.fruitCount : Math.floor(class1FruitSizeProfileItem.fruitCount);
                                        }());
                                    }
                                    else
                                    {
                                        class1FruitSizeProfileItemObject.fruitCount = 0;
                                    }
                                    
                                    if(typeof class1FruitSizeProfileItem === 'object' && 'percentage' in class1FruitSizeProfileItem)
                                    {
                                        class1FruitSizeProfileItemObject.percentage = (function(){
                                            if(typeof class1FruitSizeProfileItem.percentage !== 'number')
                                            {
                                                return Number(class1FruitSizeProfileItem.percentage);
                                            }
                
                                            return class1FruitSizeProfileItem.percentage;
                                        }());
                                    }
                                    else
                                    {
                                        class1FruitSizeProfileItemObject.percentage = 0;
                                    }
                
                                    return class1FruitSizeProfileItemObject;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.class1FruitSizeProfile = [];
                    }
                    
                    if(typeof result === 'object' && 'class1TotalTrays' in result)
                    {
                        resultObject.class1TotalTrays = (function(){
                            if(typeof result.class1TotalTrays !== 'number')
                            {
                                return Number(result.class1TotalTrays);
                            }
                
                            return result.class1TotalTrays;
                        }());
                    }
                    else
                    {
                        resultObject.class1TotalTrays = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1TraysPerBin' in result)
                    {
                        resultObject.class1TraysPerBin = (function(){
                            if(typeof result.class1TraysPerBin !== 'number')
                            {
                                return Number(result.class1TraysPerBin);
                            }
                
                            return result.class1TraysPerBin;
                        }());
                    }
                    else
                    {
                        resultObject.class1TraysPerBin = 0;
                    }
                    
                    if(typeof result === 'object' && 'class1AverageFruitSize' in result)
                    {
                        resultObject.class1AverageFruitSize = (function(){
                            if(typeof result.class1AverageFruitSize !== 'number')
                            {
                                return Number(result.class1AverageFruitSize);
                            }
                
                            return result.class1AverageFruitSize;
                        }());
                    }
                    else
                    {
                        resultObject.class1AverageFruitSize = 0;
                    }
                    
                    if(typeof result === 'object' && 'class2TotalTrays' in result)
                    {
                        resultObject.class2TotalTrays = (function(){
                            if(typeof result.class2TotalTrays !== 'number')
                            {
                                return Number(result.class2TotalTrays);
                            }
                
                            return result.class2TotalTrays;
                        }());
                    }
                    else
                    {
                        resultObject.class2TotalTrays = 0;
                    }
                    
                    if(typeof result === 'object' && 'classTypeTotals' in result)
                    {
                        resultObject.classTypeTotals = (function(){
                            if(Array.isArray(result.classTypeTotals) !== true)
                            {
                                return [];
                            }
                
                            return result.classTypeTotals.map((classTypeTotalsItem) => {
                                return (function(){
                                    let classTypeTotalsItemObject = {};
                                    
                                    if(typeof classTypeTotalsItem === 'object' && 'classType' in classTypeTotalsItem)
                                    {
                                        classTypeTotalsItemObject.classType = (function(){
                                            if(typeof classTypeTotalsItem.classType !== 'string')
                                            {
                                                return String(classTypeTotalsItem.classType);
                                            }
                
                                            return classTypeTotalsItem.classType;
                                        }());
                                    }
                                    else
                                    {
                                        classTypeTotalsItemObject.classType = "";
                                    }
                                    
                                    if(typeof classTypeTotalsItem === 'object' && 'name' in classTypeTotalsItem)
                                    {
                                        classTypeTotalsItemObject.name = (function(){
                                            if(typeof classTypeTotalsItem.name !== 'string')
                                            {
                                                return String(classTypeTotalsItem.name);
                                            }
                
                                            return classTypeTotalsItem.name;
                                        }());
                                    }
                                    else
                                    {
                                        classTypeTotalsItemObject.name = "";
                                    }
                                    
                                    if(typeof classTypeTotalsItem === 'object' && 'percentage' in classTypeTotalsItem)
                                    {
                                        classTypeTotalsItemObject.percentage = (function(){
                                            if(typeof classTypeTotalsItem.percentage !== 'number')
                                            {
                                                return Number(classTypeTotalsItem.percentage);
                                            }
                
                                            return classTypeTotalsItem.percentage;
                                        }());
                                    }
                                    else
                                    {
                                        classTypeTotalsItemObject.percentage = 0;
                                    }
                
                                    return classTypeTotalsItemObject;
                                }());
                            });
                        }());
                    }
                    else
                    {
                        resultObject.classTypeTotals = [];
                    }
                
                    return resultObject;
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * List all Packruns [GET /packhouse/sites/{siteId}/packruns]
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {PackrunController.GetAllQueryParameters} [queryParameters] The Optional Query Parameters
     * @return {Promise<PackrunModel[]>}
     */
    static getAll(siteId, queryParameters = {})
    {
        return new Promise((resolve, reject) => {
            RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns`, queryParameters)
            .then((result) => {
                let resolveValue = (function(){
                    if(Array.isArray(result) !== true)
                    {
                        return [];
                    }
                
                    return result.map((resultItem) => {
                        return (function(){
                            return PackrunModel.fromJSON(resultItem, siteId);
                        }());
                    });
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }

    /**
     * Create a Packrun [POST /packhouse/sites/{siteId}/packruns]
     * 
     * @static
     * @public
     * @param {number} siteId The Site ID
     * @param {PackrunController.CreateData} createData The Packrun Create Data
     * @return {Promise<PackrunModel>}
     */
    static create(siteId, createData)
    {
        return new Promise((resolve, reject) => {
            RequestHelper.postRequest(`/packhouse/sites/${siteId}/packruns`, createData)
            .then((result) => {
                let resolveValue = (function(){
                    return PackrunModel.fromJSON(result, siteId);
                }());
                
                resolve(resolveValue);
            })
            .catch(error => reject(error));
        });
    }
}

export default PackrunController;

/**
 * The Optional Query Parameters for the getAll Function
 * 
 * @typedef {Object} PackrunController.GetAllQueryParameters
 * @property {string} [packingLineId] The Packing Line ID this Packrun is associated with
 * @property {string} [name] The Packrun Name
 * @property {string} [growerName] The Grower Name for this Packrun
 * @property {string} [growerCode] The Grower Code for this Packrun
 * @property {string} [maturityArea] The Maturity Area for this Packrun
 * @property {?Date} [startTimestamp] When this Packrun was Started
 * @property {?Date} [finishTimestamp] When this Packrun was Finished
 * @property {string} [varietyId] The Variety for this Packrun
 * @property {?string} [growingMethodId] The Growing Method for this Packrun
 * @property {?number} [freshPackGraderId] The FreshPack Grader ID associated with this Packrun
 * @property {?string} [freshPackBinLotCode] The FreshPack Bin Lot Code associated with this Packrun
 * @property {Date} [createdTimestampBegin] Filter by the Timestamp when this Packrun was Created. Results Greater than or Equal to Timestamp
 * @property {Date} [createdTimestampEnd] Filter by the Timestamp when this Packrun was Created. Results Less than or Equal to Timestamp
 * @property {Date} [startTimestampBegin] Filter by the Timestamp when this Packrun was Started. Results Greater than or Equal to Timestamp
 * @property {Date} [startTimestampEnd] Filter by the Timestamp when this Packrun was Started. Results Less than or Equal to Timestamp
 * @property {Date} [finishTimestampBegin] Filter by the Timestamp when this Packrun was Finished. Results Greater than or Equal to Timestamp
 * @property {Date} [finishTimestampEnd] Filter by the Timestamp when this Packrun was Finished. Results Less than or Equal to Timestamp
 * @memberof Controllers.Packhouse.Site
 */

/**
 * The Create Data for a Packrun
 * 
 * @typedef {Object} PackrunController.CreateData
 * @property {string} packingLineId The Packing Line ID this Packrun is associated with
 * @property {string} [name] The Packrun Name
 * @property {Date} [createdTimestamp] When this Packrun was Created
 * @property {string} growerName The Grower Name for this Packrun
 * @property {string} growerCode The Grower Code for this Packrun
 * @property {string} maturityArea The Maturity Area for this Packrun
 * @property {?Date} [startTimestamp] When this Packrun was Started
 * @property {?Date} [finishTimestamp] When this Packrun was Finished
 * @property {string} varietyId The Variety for this Packrun
 * @property {?string} [growingMethodId] The Growing Method for this Packrun
 * @property {number} [allocatedBins] The Number of Allocated Bins for this Packrun
 * @property {Array<PackrunController.TimeBatch>} [timeBatches] The Time Batches for this Packrun
 * @property {?number} [freshPackGraderId] The FreshPack Grader ID associated with this Packrun
 * @property {?string} [freshPackBinLotCode] The FreshPack Bin Lot Code associated with this Packrun
 * @property {?string} [freshPackProduceCode] The FreshPack Produce Code associated with this Packrun
 * @memberof Controllers.Packhouse.Site
 */

/**
 * The Update Data for a Packrun
 * 
 * @typedef {Object} PackrunController.UpdateData
 * @property {string} [packingLineId] The Packing Line ID this Packrun is associated with
 * @property {Date} [createdTimestamp] When this Packrun was Created
 * @property {string} [growerName] The Grower Name for this Packrun
 * @property {string} [growerCode] The Grower Code for this Packrun
 * @property {string} [maturityArea] The Maturity Area for this Packrun
 * @property {?Date} [startTimestamp] When this Packrun was Started
 * @property {?Date} [finishTimestamp] When this Packrun was Finished
 * @property {string} [varietyId] The Variety for this Packrun
 * @property {?string} [growingMethodId] The Growing Method for this Packrun
 * @property {number} [allocatedBins] The Number of Allocated Bins for this Packrun
 * @property {Array<PackrunController.TimeBatch>} [timeBatches] The Time Batches for this Packrun
 * @property {?number} [freshPackGraderId] The FreshPack Grader ID associated with this Packrun
 * @property {?string} [freshPackBinLotCode] The FreshPack Bin Lot Code associated with this Packrun
 * @property {?string} [freshPackProduceCode] The FreshPack Produce Code associated with this Packrun
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **UserAccount** Type
 * 
 * @typedef {Object} PackrunController.UserAccount
 * @property {?string} id The User Account ID
 * @property {?string} firstName The User's First Name
 * @property {?string} lastName The User's Last Name
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **CommentItem** Type
 * 
 * @typedef {Object} PackrunController.CommentItem
 * @property {string} id The Comment ID
 * @property {PackrunController.UserAccount} userAccount 
 * @property {?string} content The Content of the Comment
 * @property {?Date} createdTimestamp When the Comment was Created
 * @property {?Date} updatedTimestamp When the Comment was last Updated
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **TimeBatchItem** Type
 * 
 * @typedef {Object} PackrunController.TimeBatchItem
 * @property {string} id The Time Batch ID (A Single Letter starting from 'A'
 * @property {Date} timestamp When the Time Batch was Created
 * @memberof Controllers.Packhouse.Site
 */

/**
 * The Variety for the Packrun
 * 
 * @typedef {Object} PackrunController.VarietyItem
 * @property {string} id The Variety ID
 * @property {string} code The Variety Code
 * @property {string} name The Variety Name
 * @property {string} description The Variety Description
 * @property {string} image The Base64 Encoded Image for the Variety
 * @memberof Controllers.Packhouse.Site
 */

/**
 * The Growing Method for the Packrun
 * 
 * @typedef {Object} PackrunController.GrowingMethodItem
 * @property {string} id The Growing Method ID
 * @property {string} code The Growing Method Code
 * @property {string} name The Growing Method Name
 * @property {string} description The Growing Method Description
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **ClassTypeItem** Type
 * 
 * @typedef {Object} PackrunController.ClassTypeItem
 * @property {string} classType The Class Type
 * @property {string} name The Class Type Name
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **SizerBatchSummaryItem** Type
 * 
 * @typedef {Object} PackrunController.SizerBatchSummaryItem
 * @property {string} id The Sizer Batch ID
 * @property {number} number The Sizer Batch Number
 * @property {string} name The Sizer Batch Name
 * @property {string} varietyName The Sizer Variety Name
 * @property {Date} timestamp The Sizer Batch Timestamp
 * @property {number} totalFruitCount The Total Fruit Count for the Batch
 * @property {number} totalFruitWeight The Total Fruit Weight (kg) for the Batch
 * @property {number} recycleFruitCount The Recycled Fruit Count for the Batch
 * @property {number} recycleFruitWeight The Recycled Fruit Weight (kg) for the Batch
 * @property {number} recyclePercentage The Percentage of Total Fruit that was Recycled for the Batch
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **SizerItem** Type
 * 
 * @typedef {Object} PackrunController.SizerItem
 * @property {string} id The Sizer ID
 * @property {string} name The Sizer Name
 * @property {Array<PackrunController.SizerBatchSummaryItem>} batchSummaries An Array of Summarized Batches for the Sizer
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **PackrunSummaryReport** Type
 * 
 * @typedef {Object} PackrunController.PackrunSummaryReport
 * @property {string} id The Packrun ID
 * @property {string} name The Packrun Name
 * @property {Date} createdTimestamp When the Packrun was Created
 * @property {string} growerName The Grower Name
 * @property {string} growerCode The Grower Code
 * @property {?string} maturityArea The Maturity Area
 * @property {?Date} startTimestamp When the Packrun was Started
 * @property {?Date} finishTimestamp When the Packrun was Finished
 * @property {number} allocatedBins The Number of Bins Allocated for the Packrun
 * @property {Array<PackrunController.TimeBatchItem>} timeBatches The Time Batches for the Packrun
 * @property {PackrunController.VarietyItem} variety The Variety for the Packrun
 * @property {PackrunController.GrowingMethodItem} growingMethod The Growing Method for the Packrun
 * @property {string} packingLineId The Packing Line ID
 * @property {?string} packingLineName The Packing Line Name
 * @property {Array<PackrunController.ClassTypeItem>} classTypes An Array of Class Types for the Packing Line
 * @property {Object[]} compacSizers *DEPRECATED* - An Array of Summarized Compac Sizer Data
 * @property {Array<PackrunController.SizerItem>} sizers 
 * @property {Object} rejectBinSummary The Reject Bin Summary for the Packrun
 * @property {Object} binTipSummary The Bin Tip Summary for the Packrun
 * @property {Object[]} classTypeTotals An Array of Totals for each Class Type within the Packrun
 * @property {Object[]} class1SizerSummary An Array of Class 1 Fruit Summaries by Size for all Sizers within the Packrun
 * @property {number} class1TotalTrays The Total Class 1 Trays for this Packrun
 * @property {number} class1AverageTrayWeight The Average Class 1 Tray Weight for this Packrun
 * @property {Object[]} class1FruitSizeProfile An Array of Class 1 Fruit Profiles by Size for the Packrun
 * @property {number} class1AverageFruitSize The Average Class 1 Fruit Size for this Packrun
 * @property {number} class1TraysPerBin The Number of Class 1 Trays per Bin for this Packrun
 * @property {Object[]} class1FreshPackSummary An Array of Class 1 Fruit Summaries by Size from FreshPack for the Packrun
 * @property {Object[]} class2SizerSummary An Array of Class 2 Fruit Summaries by Size for all Sizers within the Packrun
 * @property {number} class2TotalTrays The Total Class 2 Trays for this Packrun
 * @property {number} class2AverageTrayWeight The Average Class 2 Tray Weight for this Packrun
 * @property {Object[]} class2FreshPackSummary An Array of Class 2 Fruit Summaries by Size from FreshPack for the Packrun
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **PackrunInfeedReport** Type
 * 
 * @typedef {Object} PackrunController.PackrunInfeedReport
 * @property {string} id The Packrun ID
 * @property {string} name The Packrun Name
 * @property {Date} createdTimestamp When the Packrun was Created
 * @property {?Date} startTimestamp When the Packrun was Started
 * @property {?Date} finishTimestamp When the Packrun was Finished
 * @property {string} packingLineId The Packing Line ID
 * @property {?string} packingLineName The Packing Line Name
 * @property {string} growerName The Grower Name
 * @property {string} growerCode The Grower Code
 * @property {?string} maturityArea The Maturity Area
 * @property {number} allocatedBins The Number of Bins Allocated for the Packrun
 * @property {number} tippedBins The Number of Bins Tipped for the Packrun
 * @property {number} softSortRejectWeight The Total Reject Weight for the Soft-Sort category expressed in kilograms
 * @property {number} softSortRejectPercentage The Percentage of Packrun Weight categorized as Soft-Sort
 * @property {number} softSortEventsPerBin The Number of Soft-Sort Events per Bin
 * @property {number} totalSoftSortEventsCount The Number of Soft-Sort Events that occurred for the Packrun
 * @property {number} averageSoftSortEventsDuration The Average Duration of Soft-Sort Events for the Packrun expressed in Seconds
 * @property {number} totalSoftSortEventsDuration The Total Duration of all Soft-Sort Events for the Packrun expressed in Seconds
 * @property {?boolean} softSortEventsIsAccurate Whether the Soft-Sort Events Data is considered accurate or not
 * @property {?string} softSortEventsNotAccurateReason A Reason for why the Soft-Sort Events Data is not accurate. Applies when `softSortEventsIsAccurate` is false
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **FruitSizeProfileItem** Type
 * 
 * @typedef {Object} PackrunController.FruitSizeProfileItem
 * @property {string} fruitSize The Fruit Size
 * @property {number} fruitCount The Fruit Count
 * @property {number} percentage The Percentage of Total Fruit for this Fruit Size
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **ClassTypePercentageItem** Type
 * 
 * @typedef {Object} PackrunController.ClassTypePercentageItem
 * @property {string} classType The Class Type
 * @property {string} name The Class Type Name
 * @property {number} percentage The Percentage of Total Weight for this Class Type
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **PackrunLatestSummaryData** Type
 * 
 * @typedef {Object} PackrunController.PackrunLatestSummaryData
 * @property {string} id The Packrun ID
 * @property {string} name The Packrun Name
 * @property {Date} createdTimestamp When the Packrun was Created
 * @property {string} growerName The Grower Name
 * @property {string} growerCode The Grower Code
 * @property {?string} maturityArea The Maturity Area
 * @property {?Date} startTimestamp When the Packrun was Started
 * @property {?Date} finishTimestamp When the Packrun was Finished
 * @property {PackrunController.VarietyItem} variety The Variety for the Packrun
 * @property {PackrunController.GrowingMethodItem} growingMethod The Growing Method for the Packrun
 * @property {string} packingLineId The Packing Line ID
 * @property {string} packingLineName The Packing Line Name
 * @property {string} status The Status of this Packrun
 * @property {number} allocatedBins The Number of Bins Allocated for the Packrun
 * @property {number} tippedBins The Number of Bins Tipped for the Packrun
 * @property {Array<PackrunController.FruitSizeProfileItem>} class1FruitSizeProfile An Array of Class 1 Fruit Profiles by Size for the Packrun
 * @property {number} class1TotalTrays The Total Class 1 Trays for this Packrun
 * @property {number} class1TraysPerBin The Number of Class 1 Trays per Bin for this Packrun
 * @property {number} class1AverageFruitSize The Average Class 1 Fruit Size for this Packrun
 * @property {number} class2TotalTrays The Total Class 2 Trays for this Packrun
 * @property {Array<PackrunController.ClassTypePercentageItem>} classTypeTotals An Array of Class Types and their Percentages for this Packrun
 * @memberof Controllers.Packhouse.Site
 */

/**
 * A **TimeBatch** Type
 * 
 * @typedef {Object} PackrunController.TimeBatch
 * @property {string} id The Single Letter ID of this Time Batch (Starts at A and proceeds through to Z)
 * @property {Date} timestamp Timestamp when this Time Batch was Created
 * @memberof Controllers.Packhouse.Site
 */