public IEnumerator UpdateGameProfileAtrribute(string @namespace, string userId, string accessToken,
                                                      string profileId, GameProfileAttribute attribute, ResultCallback <GameProfile> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't update a game profile attribute! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't update a game profile attribute! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't update a game profile attribute! accessToken parameter is null!");
            Assert.IsNotNull(profileId, "Can't update a game profile attribute! profileId parameter is null!");
            Assert.IsNotNull(attribute, "Can't update a game profile attribute! attribute parameter is null!");
            Assert.IsNotNull(attribute.name, "Can't update a game profile attribute! attribute.name is null!");

            var request = HttpRequestBuilder
                          .CreatePut(
                this.baseUrl +
                "/public/namespaces/{namespace}/users/{userId}/profiles/{profileId}/attributes/{attributeName}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("profileId", profileId)
                          .WithPathParam("attributeName", attribute.name)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBody(attribute.ToUtf8Json())
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
        public void UpdateGameProfileAttribute(string profileId, GameProfileAttribute attribute, ResultCallback <GameProfile> callback)
        {
            if (!this.user.IsLoggedIn)
            {
                callback.Try(Result <GameProfile> .CreateError(ErrorCode.IsNotLoggedIn, "User is not logged in"));
                return;
            }

            this.taskDispatcher.Start(
                Task.Retry(
                    cb => this.api.UpdateGameProfileAtrribute(this.user.Namespace, this.user.UserId,
                                                              this.user.AccessToken, profileId, attribute, result => cb(result)),
                    result => this.coroutineRunner.Run(() => callback((Result <GameProfile>)result)),
                    this.user));
        }
        /// <summary>
        /// Update an attribute of current user's game profile
        /// </summary>
        /// <param name="profileId">The id of game profile that about to update</param>
        /// <param name="attribute">The attribute of game profile that about to update</param>
        /// <param name="callback">Returns updated game profile via callback when completed.</param>
        public void UpdateGameProfileAttribute(string profileId, GameProfileAttribute attribute,
                                               ResultCallback <GameProfile> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            if (!this.session.IsValid())
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);

                return;
            }

            this.coroutineRunner.Run(
                this.api.UpdateGameProfileAtrribute(
                    this.@namespace,
                    this.session.UserId,
                    this.session.AuthorizationToken,
                    profileId,
                    attribute,
                    callback));
        }
        public IEnumerator <ITask> UpdateGameProfileAtrribute(string @namespace, string userId, string accessToken,
                                                              string profileId, GameProfileAttribute attribute, ResultCallback <GameProfile> callback)
        {
            Assert.IsNotNull(@namespace, "Can't update a game profile attribute! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't update a game profile attribute! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't update a game profile attribute! accessToken parameter is null!");
            Assert.IsNotNull(profileId, "Can't update a game profile attribute! profileId parameter is null!");
            Assert.IsNotNull(attribute, "Can't update a game profile attribute! attribute parameter is null!");
            Assert.IsNotNull(attribute.name, "Can't update a game profile attribute! attribute.name is null!");

            var request = HttpRequestBuilder
                          .CreatePut(this.baseUrl + "/soc-profile/public/namespaces/{namespace}/users/{userId}/profiles/{profileId}/attributes/{attributeName}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("profileId", profileId)
                          .WithPathParam("attributeName", attribute.name)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBody(SimpleJson.SimpleJson.SerializeObject(attribute))
                          .ToRequest();

            HttpWebResponse response = null;

            yield return(Task.Await(request, rsp => response = rsp));

            if (response == null)
            {
                callback.Try(Result <GameProfile> .CreateError(ErrorCode.NetworkError, "There is no response"));
                yield break;
            }

            var responseText = response.GetBodyText();

            response.Close();
            Result <GameProfile> result;

            switch (response.StatusCode)
            {
            case HttpStatusCode.OK:
                try
                {
                    GameProfile gameProfile = SimpleJson.SimpleJson.DeserializeObject <GameProfile>(responseText);
                    result = Result <GameProfile> .CreateOk(gameProfile);
                }
                catch (ArgumentException ex)
                {
                    result = Result <GameProfile> .CreateError(ErrorCode.InvalidResponse,
                                                               "Update game profile attribute failed to deserialize response body: " + ex.Message);
                }

                break;

            case HttpStatusCode.NotFound:
                result = Result <GameProfile> .CreateError(ErrorCode.CategoryNotFound,
                                                           "Update game profile attribute failed due to the resource not found");

                break;

            default:
                result = Result <GameProfile> .CreateError((ErrorCode)response.StatusCode,
                                                           "Update game profile attribute failed with status: " + response.StatusCode);

                break;
            }

            callback.Try(result);
        }