% MKSRequest is a high level class used to define
% requests to and responses from the WebServer 
% Edition

% Version 2.0 - updated 2024-02-24
classdef MKSRequest < MKSBase

    % Properties
    properties
        entities = MKSEntity.empty
        processor = ""
        fileName = ""
        version = ""
        date = ""
        type = ""
    end

    % Methods
    methods

        % processJson - decoded json input
        function mksReq = processJson(mksReq, jsonStruct)

            % Assign properties
            mksReq.processor = mksReq.getJsonStr(jsonStruct, "Processor");
            mksReq.fileName = mksReq.getJsonStr(jsonStruct, "Filename");
            mksReq.version = mksReq.getJsonStr(jsonStruct, "Version");
            mksReq.date = mksReq.getJsonStr(jsonStruct, "Date");
            mksReq.type = mksReq.getJsonStr(jsonStruct, "Type");

            % Parse each entity structure
            for i = 1:numel(jsonStruct.Entities)

                % Create entity object
                mksEnt = MKSEntity;

                % Parse json input
                mksEnt = mksEnt.processJson(jsonStruct.Entities(i));
                mksReq.entities(end+1) = mksEnt;
                
            end

        end

    end
end