// Path: erp-library/src/main/java/com.jukusoft/erp/lib/exception/HandlerException.java
// public class HandlerException extends RuntimeException {
// 
//     public HandlerException (String message) {
//         super(message);
//     }
// 
// }


import com.jukusoft.erp.lib.exception.HandlerException;
import io.vertx.core.json.JsonObject;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
package com.jukusoft.erp.lib.message.request;



public class ApiRequest {

    //name of event
    protected String eventName = "";

    //json data
    protected JSONObject data = null;

    protected String ackID = "";

    //cluster wide unique message id for logging
    protected long messageID = 0;

    //external ID (for ack requests, generated by client), UUID as string
    protected String externalID = "";

    //meta information
    protected JSONObject meta = new JSONObject();
    protected String sessionID = "";
    protected boolean isLoggedIn = false;
    protected long userID = -1;

    //user permissions
    protected List<String> permissions = new ArrayList<>();

    /**
    * default constructor
     *
     * @param event event name
     * @param data json data
    */
    public ApiRequest (String event, JSONObject data, long messageID, String externalID, String sessionID, boolean isLoggedIn, long userID) {
        this.eventName = event;
        this.data = data;
        this.messageID = messageID;
        this.externalID = externalID;
        this.sessionID = sessionID;
        this.isLoggedIn = isLoggedIn;
        this.userID = userID;
    }

    protected ApiRequest () {
        //
    }

    public String getEvent () {
        return this.eventName;
    }

    public JSONObject getData () {
        return this.data;
    }

    /**
    * check, if param exists, else throw an exception
     *
     * @param key key of param
    */
// Path: erp-library/src/main/java/com.jukusoft/erp/lib/exception/HandlerException.java
// public class HandlerException extends RuntimeException {
// 
//     public HandlerException (String message) {
//         super(message);
//     }
// 
// }


// Path: erp-library/src/main/java/com.jukusoft/erp/lib/message/request/ApiRequest.java
import com.jukusoft.erp.lib.exception.HandlerException;
import io.vertx.core.json.JsonObject;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;

package com.jukusoft.erp.lib.message.request;



public class ApiRequest {

    //name of event
    protected String eventName = "";

    //json data
    protected JSONObject data = null;

    protected String ackID = "";

    //cluster wide unique message id for logging
    protected long messageID = 0;

    //external ID (for ack requests, generated by client), UUID as string
    protected String externalID = "";

    //meta information
    protected JSONObject meta = new JSONObject();
    protected String sessionID = "";
    protected boolean isLoggedIn = false;
    protected long userID = -1;

    //user permissions
    protected List<String> permissions = new ArrayList<>();

    /**
    * default constructor
     *
     * @param event event name
     * @param data json data
    */
    public ApiRequest (String event, JSONObject data, long messageID, String externalID, String sessionID, boolean isLoggedIn, long userID) {
        this.eventName = event;
        this.data = data;
        this.messageID = messageID;
        this.externalID = externalID;
        this.sessionID = sessionID;
        this.isLoggedIn = isLoggedIn;
        this.userID = userID;
    }

    protected ApiRequest () {
        //
    }

    public String getEvent () {
        return this.eventName;
    }

    public JSONObject getData () {
        return this.data;
    }

    /**
    * check, if param exists, else throw an exception
     *
     * @param key key of param
    */
    public void checkParam (String key) throws HandlerException {