コード例 #1
0
        public IEnumerator GetSessionId(string accessToken, ResultCallback <ServerSessionResponse> callback)
        {
            Assert.IsNotNull(accessToken, "Can't check session ID! accessToken parameter is null!");

            if (this.serverType == ServerType.NONE)
            {
                callback.TryError(new Error(ErrorCode.NotFound, "Server not registered yet"));
                yield break;
            }

            var request = HttpRequestBuilder.CreateGet(this.baseUrl + "/namespaces/{namespace}/servers/{server}/session")
                          .WithPathParam("namespace", this.namespace_)
                          .WithPathParam("server", serverSetup.pod_name)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #2
0
        public IEnumerator GetUserBannedList(string @namespace, string accessToken, bool activeOnly, BanType banType, int offset, int limit, ResultCallback <UserBanPagedList> callback)
        {
            Assert.IsNotNull(@namespace, nameof(@namespace) + " cannot be null");
            Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v3/admin/namespaces/{namespace}/bans/users")
                          .WithPathParam("namespace", @namespace)
                          .WithQueryParam("activeOnly", activeOnly ? "true" : "false")
                          .WithQueryParam("banType", banType.ToString())
                          .WithQueryParam("offset", (offset >= 0) ? offset.ToString() : "")
                          .WithQueryParam("limit", (limit > 0) ? limit.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.TryParseJson <UserBanPagedList>();

            callback.Try(result);
        }
コード例 #3
0
        public IEnumerator GetUserProfilePublicInfosByIds(string @namespace, string userAccessToken, string[] userIds,
                                                          ResultCallback <PublicUserProfile[]> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get user profile public info by ids! Namespace parameter is null!");
            Assert.IsNotNull(
                userAccessToken,
                "Can't get user profile public info by ids! UserAccessToken parameter is null!");

            Assert.IsNotNull(userIds, "Can't get user profile info by ids! userIds parameter is null!");

            var request = HttpRequestBuilder.CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/profiles/public")
                          .WithPathParam("namespace", @namespace)
                          .WithBearerAuth(userAccessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithQueryParam("userIds", string.Join(",", userIds))
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #4
0
        public IEnumerator GetCurrentUserSeason(string @namespace, string accessToken, string userId, ResultCallback <UserSeasonInfo> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't Get User Current Season! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't Get User Current Season! AccessToken parameter is null!");
            Assert.IsNotNull(userId, "Can't Get User Current Season! userId parameter is null!");

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

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #5
0
        public IEnumerator GetReasons(string @namespace, string accessToken, string reasonGroup, ResultCallback <ReportingReasonsResponse> callback, int offset, int limit)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't create content! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't create content! AccessToken parameter is null!");
            Assert.IsNotNull(reasonGroup, "Can't create content! reasonGroup parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/reasons")
                          .WithPathParam("namespace", @namespace)
                          .WithQueryParam("group", reasonGroup)
                          .WithQueryParam("limit", limit.ToString())
                          .WithQueryParam("offset", offset.ToString())
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #6
0
        public IEnumerator GetAllSlots(string @namespace, string userId, string accessToken,
                                       ResultCallback <Slot[]> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get all slots! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get all slots! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get all slots! accessToken parameter is null!");

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

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #7
0
        public IEnumerator GetUserRanking(string @namespace, string accessToken, string leaderboardCode, string userId,
                                          ResultCallback <UserRankingData> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get item! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get item! AccessToken parameter is null!");
            Assert.IsNotNull(leaderboardCode, "Can't get item! Leaderboard Code parameter is null!");
            Assert.IsNotNull(userId, "Can't get item! UserId parameter is null!");

            var builder = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/leaderboards/{leaderboardCode}/users/{userId}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("leaderboardCode", leaderboardCode)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson);

            var request = builder.GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #8
0
        public IEnumerator GetItem(string @namespace, string accessToken, string itemId, string region, string language,
                                   ResultCallback <PopulatedItemInfo> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get item! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get item! AccessToken parameter is null!");
            Assert.IsNotNull(itemId, "Can't get item! ItemId parameter is null!");

            var builder = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/items/{itemId}/locale")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("itemId", itemId)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson);

            if (region != null)
            {
                builder.WithQueryParam("region", region);
            }

            if (language != null)
            {
                builder.WithQueryParam("language", language);
            }

            var request = builder.GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #9
0
        public IEnumerator GetItemByAppId(string publisherNamespace, string accessToken, string appId, ResultCallback <ItemInfo> callback, string language = null, string region = null)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(publisherNamespace, "Can't get items by appId! publisherNamespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get items by appId! AccessToken parameter is null!");
            Assert.IsNotNull(appId, "Can't get items by appId! appId parameter is null!");

            var builder = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/items/byAppId")
                          .WithPathParam("namespace", publisherNamespace)
                          .WithQueryParam("appId", appId)
                          .Accepts(MediaType.ApplicationJson);

            if (region != null)
            {
                builder.WithQueryParam("region", region);
            }

            if (language != null)
            {
                builder.WithQueryParam("language", language);
            }

            var request = builder.GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #10
0
        public IEnumerator <ITask> GetPlatformLinks(string @namespace, string userAccessToken,
                                                    string userId, ResultCallback <PlatformLink[]> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get linked platfrom account! Namespace parameter is null!");
            Assert.IsNotNull(userAccessToken,
                             "Can't get linked platfrom account! ClientAccessToken parameter is null!");
            Assert.IsNotNull(userId, "Can't get linked platfrom account! UserId parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/iam/namespaces/{namespace}/users/{userId}/platforms")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBearerAuth(userAccessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .ToRequest();

            HttpWebResponse response = null;

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

            var result = response.TryParseJsonBody <PlatformLink[]>();

            callback.Try(result);
        }
コード例 #11
0
        public IEnumerator <ITask> GetChildCategories(string @namespace, string accessToken, string categoryPath,
                                                      string language,
                                                      ResultCallback <Category[]> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get child categories! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get child categories! AccessToken parameter is null!");
            Assert.IsNotNull(categoryPath, "Can't get child categories! CategoryPath parameter is null!");
            Assert.IsNotNull(language, "Can't get child categoreis! Language parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl +
                                     "/platform/public/namespaces/{namespace}/categories/{categoryPath}/children")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("categoryPath", categoryPath)
                          .WithQueryParam("language", language)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .ToRequest();

            HttpWebResponse response = null;

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

            var result = response.TryParseJsonBody <Category[]>();

            callback.Try(result);
        }
コード例 #12
0
        public IEnumerator GetGameProfileAtrribute(string @namespace, string userId, string accessToken,
                                                   string profileId, string attributeName, ResultCallback <GameProfileAttribute> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get a game profile attribute! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get a game profile attribute! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get a game profile attribute! accessToken parameter is null!");
            Assert.IsNotNull(profileId, "Can't get a game profile attribute! profileId parameter is null!");
            Assert.IsNotNull(attributeName, "Can't get a game profile attribute! attributeName parameter is null!");

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

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #13
0
        public IEnumerator SearchGroups(string namespace_, string accessToken,
                                        ResultCallback <PaginatedGroupListResponse> callback, string groupName = "", string groupRegion = "", int limit = 0, int offset = 0)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsFalse(string.IsNullOrEmpty(namespace_), "Can't get list of groups! Namespace parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(accessToken), "Can't get list of groups! AccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/groups")
                          .WithPathParam("namespace", namespace_)
                          .WithQueryParam("groupName", groupName)
                          .WithQueryParam("groupRegion", groupRegion)
                          .WithQueryParam("limit", (limit > 0) ? limit.ToString() : "")
                          .WithQueryParam("offset", (offset >= 0) ? offset.ToString() : "")
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #14
0
        public IEnumerator SearchUserOtherPlatformUserId(string namespace_, string accessToken, string platformUserId,
                                                         PlatformType platformType, ResultCallback <UserOtherPlatformInfo> callback)
        {
            Assert.IsNotNull(namespace_, nameof(namespace_) + " cannot be null");
            Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null");
            Assert.IsNotNull(platformUserId, nameof(platformUserId) + " cannot be null");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/iam/v3/admin/namespaces/{namespace_}/platforms/{platformId}/users/{platformUserId}")
                          .WithPathParam("namespace_", namespace_)
                          .WithPathParam("platformId", platformType.ToString().ToLower())
                          .WithPathParam("platformUserId", platformUserId)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .WithBearerAuth(accessToken)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #15
0
        public IEnumerator GetUserOrder(string @namespace, string userId, string userAccessToken, string orderNumber,
                                        ResultCallback <OrderInfo> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get user's order! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user's order! UserId parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get user's order! UserAccessToken parameter is null!");
            Assert.IsNotNull(orderNumber, "Can't get user's order! OrderNumber parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/users/{userId}/orders/{orderNo}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("orderNo", orderNumber)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #16
0
        public IEnumerator GetLegalPoliciesByCountry(string countryCode, AgreementPolicyType agreementPolicyType, string[] tags, bool defaultOnEmpty, string accessToken,
                                                     ResultCallback <PublicPolicy[]> callback)
        {
            string functionName = "GetLegalPoliciesByCountry";

            Report.GetFunctionLog(GetType().Name, functionName);
            Assert.IsNotNull(countryCode, "Can't " + functionName + "! CountryCode parameter is null!");
            Assert.IsNotNull(accessToken, "Can't " + functionName + "! AccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(baseUrl + "/public/policies/countries/{countryCode}")
                          .WithPathParam("countryCode", countryCode)
                          .WithQueryParam("policyType", (agreementPolicyType == AgreementPolicyType.EMPTY) ? "" : agreementPolicyType.ToString())
                          .WithQueryParam("tags", string.Join(",", tags))
                          .WithQueryParam("defaultOnEmpty", defaultOnEmpty.ToString())
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #17
0
        public IEnumerator GetChildCategories(string @namespace, string accessToken, string categoryPath,
                                              string language, ResultCallback <CategoryInfo[]> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get child categories! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get child categories! AccessToken parameter is null!");
            Assert.IsNotNull(categoryPath, "Can't get child categories! CategoryPath parameter is null!");
            Assert.IsNotNull(language, "Can't get child categories! Language parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/categories/{categoryPath}/children")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("categoryPath", categoryPath)
                          .WithQueryParam("language", language)
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #18
0
        public IEnumerator QueryUserEntitlements(string @namespace, string userId, string userAccessToken, string entitlementName, string itemId, int offset,
                                                 int limit, EntitlementClazz entitlementClazz, EntitlementAppType entitlementAppType, ResultCallback <EntitlementPagingSlicedResult> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get user entitlements! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user entitlements! UserId parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get user entitlements! UserAccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/users/{userId}/entitlements")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithQueryParam("entitlementClazz", (entitlementClazz == EntitlementClazz.NONE) ? "" : entitlementClazz.ToString())
                          .WithQueryParam("entitlementAppType", (entitlementAppType == EntitlementAppType.NONE) ? "" : entitlementAppType.ToString())
                          .WithQueryParam("entitlementName", entitlementName)
                          .WithQueryParam("itemId", itemId)
                          .WithQueryParam("offset", (offset >= 0) ? offset.ToString() : "")
                          .WithQueryParam("limit", (limit >= 0)? limit.ToString() : "")
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #19
0
        public IEnumerator GetCustomAttributes(string @namespace, string userId, string userAccessToken,
                                               ResultCallback <Dictionary <string, object> > callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get custom attributes! Namespace parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get custom attributes! userId is null!");
            Assert.IsNotNull(userAccessToken, "Can't get custom attributes! UserAccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/profiles/customAttributes")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            var result = response.TryParseJson <Dictionary <string, object> >();

            callback.Try(result);
        }
コード例 #20
0
        public IEnumerator GetUserEntitlementOwnershipByAppId(string publisherNamespace, string userId, string userAccessToken, string appId,
                                                              ResultCallback <Ownership> callback)
        {
            Assert.IsNotNull(publisherNamespace, "Can't get user entitlements! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user entitlements! UserId parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get user entitlements! UserAccessToken parameter is null!");
            Assert.IsNotNull(appId, "Can't get user entitlements! appId parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/users/me/entitlements/ownership/byAppId")
                          .WithPathParam("namespace", publisherNamespace)
                          .WithPathParam("userId", userId)
                          .WithQueryParam("appId", appId)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #21
0
        public IEnumerator GetWalletInfoByCurrencyCode(string @namespace, string userId, string userAccessToken,
                                                       string currencyCode, ResultCallback <WalletInfo> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get wallet info by currency code! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get wallet info by currency code! UserId parameter is null!");
            Assert.IsNotNull(
                userAccessToken,
                "Can't get wallet info by currency code! UserAccessToken parameter is null!");

            Assert.IsNotNull(currencyCode, "Can't get wallet info by currency code! CurrencyCode parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/public/namespaces/{namespace}/users/me/wallets/{currencyCode}")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("currencyCode", currencyCode)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #22
0
        public IEnumerator GetUserRecord(string @namespace, string userId, string accessToken, string key, bool isPublic,
                                         ResultCallback <UserRecord> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get user record! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user record! userId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get user record! AccessToken parameter is null!");
            Assert.IsNotNull(key, "Can't get user record! Key parameter is null!");

            string url = "/v1/admin/namespaces/{namespace}/users/{userId}/records/{key}";

            if (isPublic)
            {
                url += "/public";
            }

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + url)
                          .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.TryParseJson <UserRecord>();

            callback.Try(result);
        }
コード例 #23
0
        public IEnumerator GetUserStatItems(string @namespace, string userId,
                                            string accessToken, ICollection <string> statCodes, ICollection <string> tags, ResultCallback <PagedStatItems> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get stat items! namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get stat items! userIds parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get stat items! accessToken parameter is null!");

            var builder = HttpRequestBuilder
                          .CreateGet(
                this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/statitems")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson);

            if (statCodes != null && statCodes.Count > 0)
            {
                builder.WithQueryParam("statCodes", string.Join(",", statCodes));
            }

            if (tags != null && tags.Count > 0)
            {
                builder.WithQueryParam("tags", string.Join(",", tags));
            }

            var           request  = builder.GetResult();
            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #24
0
        public IEnumerator QueryAchievements(string @namespace, string accessToken, string language, AchievementSortBy sortBy,
                                             ResultCallback <PaginatedPublicAchievement> callback, int offset, int limit)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't query achievements! Namespace parameter is null!");
            Assert.IsNotNull(accessToken, "Can't query achievements! AccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v1/public/namespaces/{namespace}/achievements")
                          .WithPathParam("namespace", @namespace)
                          .WithQueryParam("language", language)
                          .WithQueryParam("sortBy", ConvertAchievementSortByToString(sortBy))
                          .WithQueryParam("offset", offset.ToString())
                          .WithQueryParam("limit", limit.ToString())
                          .WithBearerAuth(accessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #25
0
        public IEnumerator SearchUsers(string query, SearchType by, ResultCallback <PagedPublicUsersInfo> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(query, nameof(query) + " cannot be null.");

            string[] filter = { "", "displayName", "username" };

            var builder = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/v3/public/namespaces/{namespace}/users")
                          .WithPathParam("namespace", this.@namespace)
                          .WithQueryParam("query", query)
                          .WithBearerAuth(this.session.AuthorizationToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson);

            if (by != SearchType.ALL)
            {
                builder.WithQueryParam("by", filter[(int)by]);
            }

            var request = builder.GetResult();

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }
コード例 #26
0
        public IEnumerator <ITask> GetUserOrderHistory(string @namespace, string userId, string userAccessToken,
                                                       string orderNo, ResultCallback <OrderHistoryInfo[]> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get user's order history! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user's order history! UserId parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get user's order history! UserAccessToken parameter is null!");
            Assert.IsNotNull(orderNo, "Can't get user's order history! OrderNo parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/platform/public/namespaces/{namespace}/users/{userId}/orders/{orderNo}/history")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithPathParam("orderNo", orderNo)
                          .WithBearerAuth(userAccessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .ToRequest();

            HttpWebResponse response = null;

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

            var result = response.TryParseJsonBody <OrderHistoryInfo[]>();

            callback.Try(result);
        }
コード例 #27
0
        public IEnumerator SendRequests_WithValidUrls_AllCompleted()
        {
            var worker            = new UnityHttpWorker();
            int serverErrorCount  = 0;
            int networkErrorCount = 0;

            worker.ServerErrorOccured  += req => serverErrorCount++;
            worker.NetworkErrorOccured += req => networkErrorCount++;
            var runner = new CoroutineRunner();

            IHttpResponse[] responses = new IHttpResponse[15];

            for (int i = 0; i < responses.Length; i++)
            {
                int index = i;

                var request = HttpRequestBuilder.CreateGet(string.Format("http://www.example.com/?id={0}", i))
                              .GetResult();

                runner.Run(worker.SendRequest(request, rsp => responses[index] = rsp));
            }

            yield return(new WaitUntil(() => responses.All(req => req != null)));

            TestHelper.Assert.That(serverErrorCount, Is.EqualTo(0));
            TestHelper.Assert.That(networkErrorCount, Is.EqualTo(0));
            Assert.That(responses.Count(req => req != null), Is.EqualTo(15));
        }
コード例 #28
0
        public IEnumerator <ITask> GetUserOrders(string @namespace, string userId, string userAccessToken,
                                                 uint page, uint size, ResultCallback <PagedOrderInfo> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get user's order! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user's order! UserId parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get user's order! UserAccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl + "/platform/public/namespaces/{namespace}/users/{userId}/orders")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("userId", userId)
                          .WithBearerAuth(userAccessToken)
                          .WithQueryParam("page", page.ToString())
                          .WithQueryParam("size", size.ToString())
                          .WithContentType(MediaType.ApplicationJson)
                          .Accepts(MediaType.ApplicationJson)
                          .ToRequest();

            HttpWebResponse response = null;

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

            var result = response.TryParseJsonBody <PagedOrderInfo>();

            callback.Try(result);
        }
コード例 #29
0
        public IEnumerator <ITask> GetUserProfilePublicInfo(string @namespace, string userId,
                                                            string userAccessToken,
                                                            ResultCallback <PublicUserProfile> callback)
        {
            Assert.IsNotNull(@namespace, "Can't get user profile public info! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get user profile public info! userId parameter is null!");
            Assert.IsNotNull(userAccessToken, "Can't get user profile public info! UserAccessToken parameter is null!");

            var request = HttpRequestBuilder
                          .CreateGet(this.baseUrl +
                                     "/basic/public/namespaces/{namespace}/users/{user_id}/profiles/public")
                          .WithPathParam("namespace", @namespace)
                          .WithPathParam("user_id", userId)
                          .WithBearerAuth(userAccessToken)
                          .Accepts(MediaType.ApplicationJson)
                          .ToRequest();

            HttpWebResponse response = null;

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

            var result = response.TryParseJsonBody <PublicUserProfile>();

            callback.Try(result);
        }
コード例 #30
0
        public IEnumerator GetChannels(string @namespace, string userId, string accessToken, ResultCallback <UGCChannelPagingResponse> callback, int offset, int limit)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(@namespace, "Can't get channels! Namespace parameter is null!");
            Assert.IsNotNull(userId, "Can't get channels! UserId parameter is null!");
            Assert.IsNotNull(accessToken, "Can't get channels! AccessToken parameter is null!");

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

            IHttpResponse response = null;

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

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

            callback.Try(result);
        }