Пример #1
0
        private static string GetAllowedActionString(AllowedAction action)
        {
            var rangeString = string.Empty;

            if (action.Type == ActionType.Call)
            {
                rangeString += $" {action.Min}";
            }
            if (action.Type == ActionType.Raise)
            {
                rangeString += $" {action.Min}-{action.Max}";
            }

            return(action.Type + rangeString);
        }
Пример #2
0
        /// <summary>
        /// Delete predefined group rule.
        /// </summary>
        /// <param name="groupId">The group id.</param>
        /// <param name="allowedAction">The rule action of the group.</param>
        /// <param name="callback">Returns a Result via callback when completed</param>
        public void DeleteGroupPredefinedRule(string groupId, AllowedAction allowedAction, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(groupId, "Can't update group predefined rule! GroupId parameter is null!");
            Assert.AreNotEqual(AllowedAction.None, allowedAction, "Can't update group predefined rule! allowedAction parameter is null!");

            if (!this.session.IsValid())
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);

                return;
            }

            this.coroutineRunner.Run(
                this.api.DeleteGroupPredefinedRule(this.@namespace, this.session.AuthorizationToken, groupId, allowedAction, callback));
        }
Пример #3
0
        public IEnumerator DeleteGroupPredefinedRule(string namespace_, string accessToken, string groupId, AllowedAction allowedAction,
                                                     ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsFalse(string.IsNullOrEmpty(namespace_), "Can't delete group predefined rule! Namespace parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(accessToken), "Can't delete group predefined rule! AccessToken parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(groupId), "Can't delete group predefined rule! GroupId parameter is null!");
            Assert.AreNotEqual(AllowedAction.None, allowedAction, "Can't delete group predefined rule! allowedAction parameter is null!");

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v1/public/namespaces/{namespace}/groups/{groupId}/rules/defined/{allowedAction}")
                          .WithPathParam("namespace", namespace_)
                          .WithPathParam("groupId", groupId)
                          .WithPathParam("allowedAction", allowedAction.ToString())
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParse();

            callback.Try(result);
        }