/// <summary> /// Create a new routing rule condition in the Connection directory /// </summary> /// <param name="pConnectionServer"> /// Connection server being edited /// </param> /// <param name="pRoutingRuleObjectId"> /// Routing rule to add the condition for /// </param> /// <param name="pOperator"> /// operator (equals, lessThan etc...) /// </param> /// <param name="pParameter"> /// Parameter (calling number, called number etc...) /// </param> /// <param name="pOperandValue"> /// Value to evaluate the parameter against using the operator /// </param> /// <returns> /// Instance of the WebCallResult class. /// </returns> public static WebCallResult AddRoutingRuleCondition(ConnectionServerRest pConnectionServer, string pRoutingRuleObjectId, RoutingRuleConditionOperator pOperator, RoutingRuleConditionParameter pParameter, string pOperandValue) { WebCallResult res = new WebCallResult(); res.Success = false; if (pConnectionServer == null) { res.ErrorText = "Null ConnectionServer referenced passed to AddRoutingRuleCondition"; return(res); } if (string.IsNullOrEmpty(pRoutingRuleObjectId)) { res.ErrorText = "Empty RoutingRuleObjectID passed to AddRoutingRuleCondition"; return(res); } if (string.IsNullOrEmpty(pOperandValue)) { res.ErrorText = "Empty pOperandValue passed to AddRoutingRuleCondition"; return(res); } string strBody = "<RoutingRuleCondition>"; //strBody += string.Format("<{0}>{1}</{0}>", "RoutingRuleObjectId", pRoutingRuleObjectId); strBody += string.Format("<{0}>{1}</{0}>", "Parameter", (int)pParameter); strBody += string.Format("<{0}>{1}</{0}>", "Operator", (int)pOperator); strBody += string.Format("<{0}>{1}</{0}>", "OperandValue", pOperandValue); strBody += "</RoutingRuleCondition>"; res = pConnectionServer.GetCupiResponse(pConnectionServer.BaseUrl + "routingrules/" + pRoutingRuleObjectId + "/routingruleconditions", MethodType.POST, strBody, false); //if the call went through then the ObjectId will be returned in the URI form. if (res.Success) { if (res.ResponseText.Contains(@"/vmrest/routingrules/" + pRoutingRuleObjectId + "/routingruleconditions/")) { res.ReturnedObjectId = res.ResponseText.Replace(@"/vmrest/routingrules/" + pRoutingRuleObjectId + "/routingruleconditions/", "").Trim(); } } return(res); }
/// <summary> /// Add a new routing rule condition to a routing rule /// </summary> /// <param name="pConnectionServer">ConnectionServer the rule is homed on</param> /// <param name="pRoutingRuleObjectId">Identifier for the rule to add the condition for</param> /// <param name="pOperator">operator (equals, less than...)</param> /// <param name="pParameter">parameter (calling number, dialed number, port...)</param> /// <param name="pOperandValue">value to evaluate the parameter for using the operator</param> /// <param name="pCondition">New condition object is returned on this out parameter</param> /// <returns></returns> public static WebCallResult AddRoutingRuleCondition(ConnectionServerRest pConnectionServer, string pRoutingRuleObjectId, RoutingRuleConditionOperator pOperator, RoutingRuleConditionParameter pParameter, string pOperandValue, out RoutingRuleCondition pCondition) { pCondition = null; WebCallResult res = AddRoutingRuleCondition(pConnectionServer, pRoutingRuleObjectId, pOperator, pParameter, pOperandValue); //if the create goes through, fetch the condition as an object and return it all filled in. if (res.Success) { res = GetRoutingRuleCondition(out pCondition, pConnectionServer, pRoutingRuleObjectId, res.ReturnedObjectId); } return(res); }
/// <summary> /// Add a condition that must be met for this routing rule to fire. /// </summary> /// <param name="pOperator"> /// Operator to use (equals, less than etc...) /// </param> /// <param name="pParameter"> /// Which parameter to evaluate (calling number, dialed number etc...) /// </param> /// <param name="pOperand"> /// Value to apply the operator on against the parameter. /// </param> /// <returns></returns> public WebCallResult AddRoutingRuleCondition(RoutingRuleConditionOperator pOperator, RoutingRuleConditionParameter pParameter, string pOperand) { return(RoutingRuleCondition.AddRoutingRuleCondition(HomeServer, ObjectId, pOperator, pParameter, pOperand)); }