Exemple #1
0
        public IEnumerator RemoveUserFromSession(string @namespace, string accessToken, string channelName, string matchId, string userId, MatchmakingResult body, ResultCallback callback)
        {
            Assert.IsFalse(string.IsNullOrEmpty(accessToken), "RemoveUserFromSession failed. accessToken parameter is null or empty!");
            Assert.IsFalse(string.IsNullOrEmpty(matchId), "RemoveUserFromSession failed. accessToken parameter is null or empty!");
            Assert.IsFalse(string.IsNullOrEmpty(channelName), "RemoveUserFromSession failed, channelName is null or empty!");
            Assert.IsFalse(string.IsNullOrEmpty(userId), "RemoveUserFromSession failed, userId is null or empty!");

            var requestBuilder = HttpRequestBuilder.CreateDelete(this.baseUrl + "/v1/admin/namespaces/{namespace}/channels/{channelName}/sessions/{matchId}/users/{userId}")
                                 .WithPathParam("namespace", @namespace)
                                 .WithPathParam("channelName", channelName)
                                 .WithPathParam("matchId", matchId)
                                 .WithPathParam("userId", userId)
                                 .WithBearerAuth(accessToken)
                                 .WithContentType(MediaType.ApplicationJson)
                                 .Accepts(MediaType.ApplicationJson);

            if (body != null)
            {
                requestBuilder.WithBody(body.ToJsonString());
            }

            var request = requestBuilder.GetResult();

            IHttpResponse respose = null;

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

            var result = respose.TryParse();

            callback.Try(result);
        }
Exemple #2
0
        public IEnumerator UnlinkOtherPlatform(PlatformType platformType, ResultCallback callback, string namespace_ = "")
        {
            Report.GetFunctionLog(this.GetType().Name);

            var builder = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v3/public/namespaces/{namespace}/users/me/platforms/{platformId}")
                          .WithPathParam("namespace", this.@namespace)
                          .WithPathParam("platformId", platformType.ToString().ToLower())
                          .WithBearerAuth(this.session.AuthorizationToken)
                          .WithContentType(MediaType.ApplicationJson);

            if (!string.IsNullOrEmpty(namespace_))
            {
                UnlinkPlatformAccountRequest unlinkPlatformAccountRequest = new UnlinkPlatformAccountRequest
                {
                    platformNamespace = namespace_
                };
                builder.WithBody(unlinkPlatformAccountRequest.ToUtf8Json());
            }

            var request = builder.GetResult();

            IHttpResponse response = null;

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

            Result result = response.TryParse();

            callback.Try(result);
        }
Exemple #3
0
        public IEnumerator DeleteUserRecord(string @namespace, string userId, string accessToken, string key,
                                            ResultCallback callback)
        {
            Assert.IsNotNull(@namespace, "Can't delete user record! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't delete user record! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't delete user record! AccessToken parameter is null!");
            Assert.IsNotNull(key, "Can't delete user record! Key parameter is null!");

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v1/admin/namespaces/{namespace}/users/{userId}/records/{key}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("key", key)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParse();

            callback.Try(result);
        }
Exemple #4
0
        public IEnumerator DeleteSlot(string @namespace, string userId, string accessToken, string slotId,
                                      ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't create a slot! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't create a slot! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create a slot! accessToken parameter is null!");
            Assert.IsNotNull(slotId, "Can't create a slot! fileSection parameter is null!");

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/public/namespaces/{namespace}/users/{userId}/slots/{slotId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("slotId", slotId)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBearerAuth(accessToken)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParse();

            callback.Try(result);
        }
        public IEnumerator RemoveRoleFromMember(string namespace_, string memberRoleId, string userId, string accessToken, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsFalse(string.IsNullOrEmpty(namespace_), "Can't remove group role request! Namespace parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(memberRoleId), "Can't remove group role request! MemberRoleId parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(userId), "Can't remove group role request! UserId parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(accessToken), "Can't remove group role request! AccessToken parameter is null!");

            AssignRoleRequest removedUser = new AssignRoleRequest
            {
                userId = userId
            };

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v1/public/namespaces/{namespace}/roles/{memberRoleId}/members")
                          .WithPathParam("namespace", namespace_)
                          .WithPathParam("memberRoleId", memberRoleId)
                          .WithBearerAuth(accessToken)
                          .WithBody(removedUser.ToUtf8Json())
                          .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);
        }
        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);
        }
        public IEnumerator DeleteChannel(string @namespace, string userId, string accessToken, string channelId, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't delete channel! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't delete channel! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't delete channel! AccessToken parameter is null!");
            Assert.IsNotNull(channelId, "Can't delete channel! ChannelId parameter is null!");

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/channels/{channelId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("channelId", channelId)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParse();

            callback.Try(result);
        }
Exemple #8
0
        public IEnumerator <ITask> DeleteSlot(string @namespace, string userId, string accessToken,
                                              string slotId, ResultCallback callback)
        {
            Assert.IsNotNull(@namespace, "Can't create a slot! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't create a slot! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create a slot! accessToken parameter is null!");
            Assert.IsNotNull(slotId, "Can't create a slot! fileSection parameter is null!");


            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/binary-store/namespaces/{namespace}/users/{userId}/slots/{slotId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("slotId", slotId)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBearerAuth(accessToken)
                          .ToRequest();

            HttpWebResponse response = null;

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

            var result = response.TryParse();

            callback.Try(result);
        }
        public void CreateDelete_Success()
        {
            const string url            = "https://example.com/";
            const string expectedMethod = "DELETE";

            var httpRequest = HttpRequestBuilder.CreateDelete(url).GetResult();

            Assert.AreEqual(httpRequest.Method, expectedMethod);
        }
        public IEnumerator <ITask> DeleteGameProfile(string @namespace, string userId, string accessToken,
                                                     string profileId, ResultCallback callback)
        {
            Assert.IsNotNull(@namespace, "Can't delete a game profile! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't delete a game profile! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't delete a game profile! accessToken parameter is null!");
            Assert.IsNotNull(profileId, "Can't delete a game profile! fileSection parameter is null!");


            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/soc-profile/public/namespaces/{namespace}/users/{userId}/profiles/{profileId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("profileId", profileId)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBearerAuth(accessToken)
                          .ToRequest();

            HttpWebResponse response = null;

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

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

            var responseText = response.GetBodyText();

            response.Close();
            Result result;

            switch (response.StatusCode)
            {
            case HttpStatusCode.OK:
            case HttpStatusCode.NoContent:
                result = Result.CreateOk();
                break;

            case HttpStatusCode.NotFound:
                result = Result.CreateError(ErrorCode.NotFound,
                                            "Delete game profile failed due to the resource not found");
                break;

            default:
                result = Result.CreateError((ErrorCode)response.StatusCode,
                                            "Delete game profile failed with status: " + response.StatusCode);
                break;
            }

            callback.Try(result);
        }
Exemple #11
0
        public IEnumerator UnlinkOtherPlatform(PlatformType platformType, ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/v3/public/namespaces/{namespace}/users/me/platforms/{platformId}")
                          .WithPathParam("namespace", this.@namespace)
                          .WithPathParam("platformId", platformType.ToString().ToLower())
                          .WithBearerAuth(this.session.AuthorizationToken)
                          .WithContentType(MediaType.TextPlain)
                          .GetResult();

            IHttpResponse response = null;

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

            Result result = response.TryParse();

            callback.Try(result);
        }
Exemple #12
0
        public IEnumerator DeleteDistributionReceiver(string @namespace, string userId, string userAccessToken, string extUserId,
                                                      ResultCallback callback)
        {
            Assert.IsNotNull(@namespace, "Can't delete distribution receiver! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't delete distribution receiver! UserId parameter is null!");
            Assert.IsNotNull(extUserId, "Can't delete distribution receiver! extUserId parameter is null!");

            var request = HttpRequestBuilder
                          .CreateDelete(this.baseUrl + "/public/namespaces/{namespace}/users/{userId}/entitlements/receivers/{extUserId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("extUserId", extUserId)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParse();

            callback.Try(result);
        }
        public IEnumerator DeleteGroup(string namespace_, string accessToken, string groupId,
                                       ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsFalse(string.IsNullOrEmpty(namespace_), "Can't delete group! Namespace parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(accessToken), "Can't delete group! AccessToken parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(groupId), "Can't delete group! GroupId parameter is null!");

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

            IHttpResponse response = null;

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

            var result = response.TryParse();

            callback.Try(result);
        }