Example #1
0
        /// <summary>
        /// Get other user data by other platform userId(s) (such as SteamID, for example)
        /// For Nintendo Platform you need to append Environment ID into the Platorm ID, with this format PlatformID:EnvironmentID. e.g csgas12312323f:dd1
        /// </summary>
        /// <param name="platformType"></param>
        /// <param name="otherPlatformUserIds"></param>
        /// <param name="callback"></param>
        public void BulkGetUserByOtherPlatformUserIds(PlatformType platformType, string[] otherPlatformUserId,
                                                      ResultCallback <BulkPlatformUserIdResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);

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

                return;
            }
            BulkPlatformUserIdRequest platformUserIds = new BulkPlatformUserIdRequest {
                platformUserIDs = otherPlatformUserId
            };

            this.coroutineRunner.Run(
                this.userAccount.BulkGetUserByOtherPlatformUserIds(platformType, platformUserIds, callback));
        }
Example #2
0
        public IEnumerator BulkGetUserByOtherPlatformUserIds(PlatformType platformType, BulkPlatformUserIdRequest otherPlatformUserId,
                                                             ResultCallback <BulkPlatformUserIdResponse> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(otherPlatformUserId, nameof(otherPlatformUserId) + " cannot be null.");

            var request = HttpRequestBuilder
                          .CreatePost(this.baseUrl + "/v3/public/namespaces/{namespace}/platforms/{platformId}/users")
                          .WithPathParam("namespace", this.@namespace)
                          .WithPathParam("platformId", platformType.ToString().ToLower())
                          .WithBearerAuth(this.session.AuthorizationToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(otherPlatformUserId.ToUtf8Json())
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

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

            Result <BulkPlatformUserIdResponse> result = response.TryParseJson <BulkPlatformUserIdResponse>();

            callback.Try(result);
        }