Esempio n. 1
0
        public IEnumerator Update(UpdateUserRequest updateUserRequest, ResultCallback <UserData> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(updateUserRequest, "Update failed. updateUserRequest is null!");
            if (!string.IsNullOrEmpty(updateUserRequest.emailAddress))
            {
                Error error = new Error(ErrorCode.BadRequest, "Cannot update user email using this function. Use UpdateEmail instead.");
                callback.TryError(error);
            }

            var request = HttpRequestBuilder.CreatePatch(this.baseUrl + "/v4/public/namespaces/{namespace}/users/me")
                          .WithPathParam("namespace", this.@namespace)
                          .WithBearerAuth(this.session.AuthorizationToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(updateUserRequest.ToUtf8Json())
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParseJson <UserData>();

            callback.Try(result);
        }
        public IEnumerator IncrementUserStatItems(string @namespace, string userId, StatItemIncrement[] data,
                                                  string accessToken, ResultCallback <StatItemOperationResult[]> callback)
        {
            Assert.IsNotNull(@namespace, nameof(@namespace) + " cannot be null");
            Assert.IsNotNull(userId, nameof(userId) + " cannot be null");
            Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null");
            Assert.IsNotNull(data, nameof(data) + " cannot be null");

            var request = HttpRequestBuilder
                          .CreatePatch(this.baseUrl + "/v1/admin/namespaces/{namespace}/users/{userId}/statitems/value/bulk")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(data.ToUtf8Json())
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParseJson <StatItemOperationResult[]>();

            callback.Try(result);
        }
Esempio n. 3
0
        public IEnumerator ChangeUserBanStatus(string @namespace, string accessToken, string userId, string banId, bool enabled, ResultCallback <UserBanResponseV3> callback)
        {
            Assert.IsNotNull(@namespace, nameof(@namespace) + " cannot be null");
            Assert.IsNotNull(userId, nameof(userId) + " cannot be null");
            Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null");

            UserEnableBan changeRequest = new UserEnableBan {
                enabled = enabled
            };

            var request = HttpRequestBuilder
                          .CreatePatch(this.baseUrl + "/v3/admin/namespaces/{namespace}/users/{userId}/bans/{banId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("banId", banId)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBody(changeRequest.ToUtf8Json())
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParseJson <UserBanResponseV3>();

            callback.Try(result);
        }
Esempio n. 4
0
        public IEnumerator Update(UpdateUserRequest updateUserRequest, ResultCallback <UserData> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(updateUserRequest, "Update failed. updateUserRequest is null!");

            var request = HttpRequestBuilder.CreatePatch(this.baseUrl + "/v3/public/namespaces/{namespace}/users/me")
                          .WithPathParam("namespace", this.@namespace)
                          .WithBearerAuth(this.session.AuthorizationToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(updateUserRequest.ToUtf8Json())
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParseJson <UserData>();

            callback.Try(result);
        }