//public string RESTServiceURL { get; set; }


        public RestResponse <CRMTask> CreateTask(CRMTask task, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method = Method.POST;

            if (config.CredentialCache != null)
            {
                request.Credentials = config.CredentialCache;
            }
            if (config.Credentials != null)
            {
                request.Credentials = config.Credentials;
            }

            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMCreateTask";

            request.AddBody(task);
            RestResponse <CRMTask> response = null;

            if (config.Async)
            {
                client.ExecuteAsync <CRMTask>(request, null);
            }
            else
            {
                response = client.Execute <CRMTask>(request);
            }
            return(response);
        }
        //public string RESTServiceURL { get; set; }


        public RestResponse<CRMTask> CreateTask(CRMTask task, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;

            if (config.CredentialCache != null)
            {
                request.Credentials = config.CredentialCache;
            }
            if (config.Credentials != null)
            {
                request.Credentials = config.Credentials;
            }

            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMCreateTask";

            request.AddBody(task);
            RestResponse<CRMTask> response = null; 
            if (config.Async)
            {
                client.ExecuteAsync<CRMTask>(request, null);
            }
            else
            {
                response = client.Execute<CRMTask>(request);
            }
            return response;
        }
        public RestResponse <CRMBulkActionTask> BulkActionTasksSetCriteria(CRMBulkActionTask crmBulk, K2CRMConfig config, CRMTask crmTask)
        {
            string K2TasksFetchXML = Resources.K2CRMTaskCleanUpFetchXML.Replace("[entityid]", crmTask.RegardingId).Replace("[entityname]", crmTask.Regarding).Replace("[activityname]", crmTask.K2ActivityName).Replace("[processname]", crmTask.K2ProcessName).Replace("[statuscode]", crmBulk.FromStatus.ToString()).Replace("[processinstanceid]", crmTask.K2ProcessInstanceId.ToString());

            crmBulk.FetchXML = K2TasksFetchXML;

            return(BulkActionTasks(crmBulk, config));
        }
        public RestResponse<CRMBulkActionTask> BulkActionTasksSetCriteria(CRMBulkActionTask crmBulk, K2CRMConfig config, CRMTask crmTask)
        {
            string K2TasksFetchXML = Resources.K2CRMTaskCleanUpFetchXML.Replace("[entityid]", crmTask.RegardingId).Replace("[entityname]", crmTask.Regarding).Replace("[activityname]", crmTask.K2ActivityName).Replace("[processname]", crmTask.K2ProcessName).Replace("[statuscode]", crmBulk.FromStatus.ToString()).Replace("[processinstanceid]", crmTask.K2ProcessInstanceId.ToString());
            crmBulk.FetchXML = K2TasksFetchXML;

            return BulkActionTasks(crmBulk, config);
        }