public IEnumerator SendHeartBeat(string name, string accessToken, ResultCallback <MatchRequest> callback) { Assert.IsNotNull(name, "Deregister failed. name is null!"); Assert.IsNotNull(accessToken, "Can't update a slot! accessToken parameter is null!"); var request = HttpRequestBuilder.CreatePost(this.baseUrl + "/namespaces/{namespace}/servers/heartbeat") .WithPathParam("namespace", this.namespace_) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(string.Format("{{\"name\": \"{0}\"}}", name)) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); if (response.BodyBytes == null || response.BodyBytes.Length == 0) { callback.Try(null); } else { var result = response.TryParseJson <MatchRequest>(); callback.Try(result); } }
/// <summary> /// Take a URL and attempt to Download a <see cref="Texture2D"/> from it /// </summary> /// <param name="url">The URL to download the Image from</param> /// <param name="callback">Returns a result that contains a <see cref="Texture2D"/></param> /// <returns></returns> public static IEnumerator DownloadTexture2D(string url, ResultCallback <Texture2D> callback) { UnityWebRequest request = UnityWebRequestTexture.GetTexture(url); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debug.Log(request.error); ErrorCode code; if (request.isNetworkError) { code = ErrorCode.NetworkError; } else { code = (ErrorCode)request.responseCode; } callback.Try(Result <Texture2D> .CreateError(code, request.error)); } else { Texture2D returnedTexture = ((DownloadHandlerTexture)request.downloadHandler).texture; callback.Try(returnedTexture == null ? Result <Texture2D> .CreateError(ErrorCode.NotFound, $"Could not find specified image file {request.url}") : Result <Texture2D> .CreateOk(returnedTexture)); } }
public IEnumerator <ITask> SendPasswordResetCode(string @namespace, string clientId, string clientSecret, string userName, ResultCallback callback) { Assert.IsNotNull(@namespace, "Can't request reset password code! Namespace parameter is null!"); Assert.IsNotNull(clientId, "Can't reset password! clientId parameter is null!"); Assert.IsNotNull(clientSecret, "Can't reset password! clientSecret parameter is null!"); Assert.IsNotNull(userName, "Can't request reset password code! LoginId parameter is null!"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/iam/namespaces/{namespace}/users/forgotPassword") .WithPathParam("namespace", @namespace) .WithBasicAuth(clientId, clientSecret) .WithContentType(MediaType.ApplicationJson) .WithBody(string.Format("{{\"LoginID\": \"{0}\"}}", userName)) .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 result = response.TryParse(); callback.Try(result); }
private IEnumerator <ITask> LoginWithLauncherAsync(string authCode, ResultCallback callback) { if (this.IsLoggedIn) { this.Logout(); } Result <TokenData> loginResult = null; yield return(Task.Await(this.authApi.GetUserTokenWithAuthorizationCode(this.clientId, this.clientSecret, authCode, this.redirectUri, result => { loginResult = result; }))); if (loginResult.IsError) { callback.Try(Result.CreateError(ErrorCode.GenerateTokenFailed, "Generate token with authorization code grant failed.", loginResult.Error)); yield break; } this.tokenData = loginResult.Value; this.nextRefreshTime = User.ScheduleNormalRefresh(this.tokenData.expires_in); callback.Try(Result.CreateOk()); }
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); }
public IEnumerator <ITask> GetSlot(string @namespace, string userId, string accessToken, string slotId, ResultCallback <byte[]> callback) { Assert.IsNotNull(@namespace, "Can't get the slot! namespace parameter is null!"); Assert.IsNotNull(userId, "Can't get the slot! userId parameter is null!"); Assert.IsNotNull(accessToken, "Can't get the slot! accessToken parameter is null!"); Assert.IsNotNull(slotId, "Can't get the slot! slotId parameter is null!"); var request = HttpRequestBuilder .CreateGet(this.baseUrl + "/binary-store/namespaces/{namespace}/users/{userId}/slots/{slotId}") .WithPathParam("namespace", @namespace) .WithPathParam("userId", userId) .WithPathParam("slotId", slotId) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .ToRequest(); HttpWebResponse response = null; yield return(Task.Await(request, rsp => response = rsp)); if (response == null) { callback.Try(Result <byte[]> .CreateError(ErrorCode.NetworkError, "There is no response")); yield break; } //TODO: Might need to transfer data via stream for big files var responseBytes = response.GetBodyRaw(); response.Close(); Result <byte[]> result; switch (response.StatusCode) { case HttpStatusCode.OK: result = Result <byte[]> .CreateOk(responseBytes); break; default: result = Result <byte[]> .CreateError((ErrorCode)response.StatusCode); break; } callback.Try(result); }
public IEnumerator <ITask> CreateUserProfile(string @namespace, string userAccessToken, CreateUserProfileRequest createRequest, ResultCallback <UserProfile> callback) { Assert.IsNotNull(@namespace, "Can't create user profile! Namespace parameter is null!"); Assert.IsNotNull(userAccessToken, "Can't create user profile! UserAccessToken parameter is null!"); Assert.IsNotNull(createRequest, "Can't create user profile! CreateRequest parameter is null!"); Assert.IsNotNull(createRequest.language, "Can't create user profile! CreateRequest.language parameter is null!"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/basic/public/namespaces/{namespace}/users/me/profiles") .WithPathParam("namespace", @namespace) .WithBearerAuth(userAccessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(SimpleJson.SimpleJson.SerializeObject(createRequest)) .ToRequest(); HttpWebResponse response = null; yield return(Task.Await(request, rsp => response = rsp)); var result = response.TryParseJsonBody <UserProfile>(); callback.Try(result); }
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); }
public IEnumerator GrantUserEntitlement(string @namespace, string userId, string accessToken, GrantUserEntitlementRequest[] grantUserEntitlementsRequest, ResultCallback <StackableEntitlementInfo[]> 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(grantUserEntitlementsRequest, nameof(grantUserEntitlementsRequest) + " cannot be null"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/admin/namespaces/{namespace}/users/{userId}/entitlements") .WithPathParam("namespace", @namespace) .WithPathParam("userId", userId) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(grantUserEntitlementsRequest.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParseJson <StackableEntitlementInfo[]>(); callback.Try(result); }
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 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); }
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); }
public IEnumerator ClaimRewards(string @namespace, string accessToken, string userId, SeasonClaimRewardRequest rewardRequest, ResultCallback <SeasonClaimRewardResponse> callback) { Report.GetFunctionLog(this.GetType().Name); Assert.IsNotNull(@namespace, "Can't Claim Rewards! Namespace parameter is null!"); Assert.IsNotNull(accessToken, "Can't Claim Rewards! AccessToken parameter is null!"); Assert.IsNotNull(userId, "Can't Claim Rewards! AccessToken parameter is null!"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/public/namespaces/{namespace}/users/{userId}/seasons/current/rewards") .WithPathParam("namespace", @namespace) .WithPathParam("userId", userId) .WithContentType(MediaType.ApplicationJson) .WithBody(rewardRequest.ToUtf8Json()) .WithBearerAuth(accessToken) .Accepts(MediaType.ApplicationJson) .GetResult(); IHttpResponse response = null; yield return(this.httpClient.SendRequest(request, rsp => { response = rsp; })); var result = response.TryParseJson <SeasonClaimRewardResponse>(); callback.Try(result); }
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); }
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); }
public IEnumerator LinkOtherPlatform(PlatformType platformType, string ticket, ResultCallback callback) { Report.GetFunctionLog(this.GetType().Name); Assert.IsNotNull(ticket, "Can't link platform account! Password parameter is null!"); if (platformType == PlatformType.Stadia) { ticket = ticket.TrimEnd('='); } var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/v3/public/namespaces/{namespace}/users/me/platforms/{platformId}") .WithPathParam("namespace", this.@namespace) .WithPathParam("platformId", platformType.ToString().ToLower()) .WithFormParam("ticket", ticket) .WithBearerAuth(this.session.AuthorizationToken) .Accepts(MediaType.ApplicationJson) .WithContentType(MediaType.ApplicationForm) .GetResult(); IHttpResponse response = null; yield return(this.httpClient.SendRequest(request, rsp => response = rsp)); Result result = response.TryParse(); callback.Try(result); }
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); }
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); }
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); }
public IEnumerator CreateUserStatItems(string @namespace, string userId, string accessToken, CreateStatItemRequest[] statItems, 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(statItems, nameof(statItems) + " cannot be null"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/v1/public/namespaces/{namespace}/users/{userId}/statitems/bulk") .WithPathParam("namespace", @namespace) .WithPathParam("userId", userId) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(statItems.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParseJson <StatItemOperationResult[]>(); callback.Try(result); }
public IEnumerator BulkGetUserInfo(string[] userIds, ResultCallback <ListBulkUserInfoResponse> callback) { Report.GetFunctionLog(this.GetType().Name); Assert.IsNotNull(userIds, "userIds cannot be null."); ListBulkUserInfoRequest bulkUserInfoRequest = new ListBulkUserInfoRequest { userIds = userIds }; var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/v3/public/namespaces/{namespace}/users/bulk/basic") .WithPathParam("namespace", this.@namespace) .WithContentType(MediaType.ApplicationJson) .WithBody(bulkUserInfoRequest.ToUtf8Json()) .Accepts(MediaType.ApplicationJson) .GetResult(); IHttpResponse response = null; yield return(this.httpClient.SendRequest(request, rsp => response = rsp)); Result <ListBulkUserInfoResponse> result = response.TryParseJson <ListBulkUserInfoResponse>(); callback.Try(result); }
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); }
public IEnumerator WritePartyStorage(string @namespace, string accessToken, PartyDataUpdateRequest data, string partyId, ResultCallback <PartyDataUpdateNotif> callback, Action callbackOnConflictedData = null) { Assert.IsNotNull(@namespace, nameof(@namespace) + " cannot be null"); Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null"); Assert.IsNotNull(partyId, nameof(partyId) + " cannot be null"); Assert.IsNotNull(data, nameof(data) + " cannot be null"); var request = HttpRequestBuilder .CreatePut(this.baseUrl + "/v1/admin/party/namespaces/{namespace}/parties/{partyId}/attributes") .WithPathParam("namespace", @namespace) .WithPathParam("partyId", partyId) .WithBearerAuth(accessToken) .WithBody(data.ToUtf8Json()) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParseJson <PartyDataUpdateNotif>(); if (result.IsError && result.Error.Code == ErrorCode.PreconditionFailed) { callbackOnConflictedData?.Invoke(); } else { callback.Try(result); } }
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); }
public IEnumerator CreditUserWallet(string @namespace, string userId, string accessToken, string currencyCode, CreditUserWalletRequest creditUserWalletRequest, ResultCallback <WalletInfo> 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(accessToken, nameof(accessToken) + " cannot be null"); Assert.IsNotNull(currencyCode, nameof(currencyCode) + " cannot be null"); Assert.IsNotNull(creditUserWalletRequest, nameof(creditUserWalletRequest) + " cannot be null"); var request = HttpRequestBuilder .CreatePut(this.baseUrl + "/admin/namespaces/{namespace}/users/{userId}/wallets/{currencyCode}/credit") .WithPathParam("namespace", @namespace) .WithPathParam("userId", userId) .WithPathParam("currencyCode", currencyCode) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(creditUserWalletRequest.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParseJson <WalletInfo>(); callback.Try(result); }
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); }
public IEnumerator UpdateUserProfile(string @namespace, string userAccessToken, UpdateUserProfileRequest updateRequest, ResultCallback <UserProfile> callback) { Report.GetFunctionLog(this.GetType().Name); Assert.IsNotNull(@namespace, "Can't update user profile! Namespace parameter is null!"); Assert.IsNotNull(userAccessToken, "Can't update user profile! UserAccessToken parameter is null!"); Assert.IsNotNull(updateRequest, "Can't update user profile! ProfileRequest parameter is null!"); var request = HttpRequestBuilder .CreatePut(this.baseUrl + "/v1/public/namespaces/{namespace}/users/me/profiles") .WithPathParam("namespace", @namespace) .WithBearerAuth(userAccessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(updateRequest.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParseJson <UserProfile>(); callback.Try(result); }
public IEnumerator AddUserToSession(string @namespace, string accessToken, string channelName, string matchId, string userId, string partyId, 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!"); AddUserIntoSessionRequest body = new AddUserIntoSessionRequest() { user_id = userId, party_id = partyId }; var request = HttpRequestBuilder.CreatePost(this.baseUrl + "/v1/admin/namespaces/{namespace}/channels/{channelName}/sessions/{matchId}") .WithPathParam("namespace", @namespace) .WithPathParam("channelName", channelName) .WithPathParam("matchId", matchId) .WithBody(body.ToUtf8Json()) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .GetResult(); IHttpResponse respose = null; yield return(this.httpClient.SendRequest(request, rsp => respose = rsp)); var result = respose.TryParse(); callback.Try(result); }
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); }
public IEnumerator Verify(string verificationCode, string contactType, ResultCallback callback) { Report.GetFunctionLog(this.GetType().Name); Assert.IsNotNull(verificationCode, "Can't post verification code! VerificationCode parameter is null!"); Assert.IsNotNull(contactType, "Can't post verification code! ContactType parameter is null!"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/v3/public/namespaces/{namespace}/users/me/code/verify") .WithPathParam("namespace", this.@namespace) .WithBearerAuth(this.session.AuthorizationToken) .WithContentType(MediaType.ApplicationJson) .WithBody( string.Format( "{{" + "\"code\": \"{0}\", " + "\"contactType\": \"{1}\"" + "}}", verificationCode, contactType)) .GetResult(); IHttpResponse response = null; yield return(this.httpClient.SendRequest(request, rsp => response = rsp)); var result = response.TryParse(); callback.Try(result); }