public ApiResponse Any(ApiMqRequest request)
 {
     try
     {
         GetApiObject(request);
         InitializeExecution();
     }
     catch (Exception e)
     {
         Console.WriteLine("---API SERVICE END POINT EX CATCH---");
         Console.WriteLine(e.Message + "\n" + e.StackTrace);
     }
     return(this.Api.ApiResponse);
 }
        public void GetApiObject(ApiMqRequest request)
        {
            int    UserId;
            string SolutionId;
            string UserAuthId;
            Dictionary <string, object> ApiData;

            if (request.HasRefId())
            {
                SolutionId = request.JobArgs.SolnId;
                UserAuthId = request.JobArgs.UserAuthId;
                ApiData    = request.JobArgs.ApiData;
                UserId     = request.JobArgs.UserId;

                try
                {
                    this.Api = new EbApi();
                    this.EbConnectionFactory = new EbConnectionFactory(SolutionId, Redis);
                    this.Api             = Api.GetApi(request.JobArgs?.RefId, this.Redis, this.EbConnectionFactory.DataDB, this.EbConnectionFactory.ObjectsDB);
                    this.Api.ApiResponse = new ApiResponse();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Failed resolve api object from refid '{request.JobArgs?.RefId}'");
                    Console.WriteLine(ex.Message);
                }
            }
            else
            {
                SolutionId = request.SolnId;
                UserAuthId = request.UserAuthId;
                ApiData    = request.Data;
                UserId     = request.UserId;

                try
                {
                    this.EbConnectionFactory = new EbConnectionFactory(SolutionId, Redis);
                    this.Api = EbApiHelper.GetApiByName(request.Name, request.Version, this.EbConnectionFactory.ObjectsDB);
                    if (!(this.Api is null))
                    {
                        Api.Redis            = this.Redis;
                        Api.ObjectsDB        = this.EbConnectionFactory.ObjectsDB;
                        Api.DataDB           = this.EbConnectionFactory.DataDB;
                        this.Api.ApiResponse = new ApiResponse();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Failed resolve api object from refid '{this.Api?.RefId}'");
                    Console.WriteLine(ex.Message);
                }
            }

            if (this.Api is null)
            {
                this.Api = new EbApi {
                    ApiResponse = new ApiResponse()
                };
                this.Api.ApiResponse.Message.ErrorCode   = ApiErrorCode.ApiNotFound;
                this.Api.ApiResponse.Message.Status      = "Api does not exist";
                this.Api.ApiResponse.Message.Description = $"Api does not exist!,";

                throw new Exception(this.Api.ApiResponse.Message.Description);
            }

            this.Api.SolutionId = SolutionId;
            this.Api.UserObject = GetUserObject(UserAuthId);

            this.Api.GlobalParams = ProcessGlobalDictionary(ApiData);
            this.Api.GlobalParams["eb_currentuser_id"] = UserId;

            if (!this.Api.GlobalParams.ContainsKey("eb_loc_id"))
            {
                this.Api.GlobalParams["eb_loc_id"] = this.Api.UserObject.Preference.DefaultLocation;
            }
        }