diff --git a/Runtime/AvatarCreator/AuthManager.cs b/Runtime/AvatarCreator/AuthManager.cs index 7a4f2c9e..b24d3341 100644 --- a/Runtime/AvatarCreator/AuthManager.cs +++ b/Runtime/AvatarCreator/AuthManager.cs @@ -11,7 +11,7 @@ namespace ReadyPlayerMe.AvatarCreator public static class AuthManager { private const string TAG = nameof(AuthManager); - private static readonly AuthenticationRequests AuthenticationRequests; + private static readonly AuthAPIRequests AuthAPIRequests; private static UserSession userSession; public static UserSession UserSession => userSession; @@ -25,12 +25,12 @@ public static class AuthManager static AuthManager() { - AuthenticationRequests = new AuthenticationRequests(CoreSettingsHandler.CoreSettings.Subdomain); + AuthAPIRequests = new AuthAPIRequests(CoreSettingsHandler.CoreSettings.Subdomain); } public static async Task LoginAsAnonymous() { - userSession = await AuthenticationRequests.LoginAsAnonymous(); + userSession = await AuthAPIRequests.LoginAsAnonymous(); IsSignedInAnonymously = true; } @@ -43,14 +43,14 @@ public static void SetUser(UserSession session) public static async void SendEmailCode(string email) { - await AuthenticationRequests.SendCodeToEmail(email, userSession.Id); + await AuthAPIRequests.SendCodeToEmail(email, userSession.Id); } public static async Task LoginWithCode(string otp) { try { - userSession = await AuthenticationRequests.LoginWithCode(otp); + userSession = await AuthAPIRequests.LoginWithCode(otp); IsSignedIn = true; OnSignedIn?.Invoke(userSession); return true; @@ -64,7 +64,7 @@ public static async Task LoginWithCode(string otp) public static async void Signup(string email) { - await AuthenticationRequests.Signup(email, userSession.Id); + await AuthAPIRequests.Signup(email, userSession.Id); } public static async Task RefreshToken() @@ -72,7 +72,7 @@ public static async Task RefreshToken() (string, string) newTokens; try { - newTokens = await AuthenticationRequests.RefreshToken(userSession.Token, userSession.RefreshToken); + newTokens = await AuthAPIRequests.RefreshToken(userSession.Token, userSession.RefreshToken); } catch (Exception e) { diff --git a/Runtime/AvatarCreator/PartnerAssetsManager.cs b/Runtime/AvatarCreator/PartnerAssetsManager.cs index a10ec13f..7e268162 100644 --- a/Runtime/AvatarCreator/PartnerAssetsManager.cs +++ b/Runtime/AvatarCreator/PartnerAssetsManager.cs @@ -18,14 +18,14 @@ public class PartnerAssetsManager : IDisposable private const string EYE_MASK_SIZE_SIZE = "?w=256"; private const string ASSET_ICON_SIZE = "?w=64"; - private readonly PartnerAssetsRequests partnerAssetsRequests; + private readonly AssetAPIRequests assetAPIRequests; private Dictionary> assetsByCategory; public Action OnError { get; set; } public PartnerAssetsManager() { - partnerAssetsRequests = new PartnerAssetsRequests(CoreSettingsHandler.CoreSettings.AppId); + assetAPIRequests = new AssetAPIRequests(CoreSettingsHandler.CoreSettings.AppId); assetsByCategory = new Dictionary>(); } @@ -33,7 +33,7 @@ public async Task>> GetAssets(BodyType b { var startTime = Time.time; - var assets = await partnerAssetsRequests.Get(bodyType, gender, token); + var assets = await assetAPIRequests.Get(bodyType, gender, token); assetsByCategory = assets.GroupBy(asset => asset.Category).ToDictionary( group => group.Key, @@ -98,7 +98,7 @@ private async Task DownloadIcons(List chunk, Action + var iconTask = assetAPIRequests.GetAssetIcon(url, icon => { onDownload?.Invoke(asset.Id, icon); }, diff --git a/Runtime/AvatarCreator/WebRequests/PartnerAssetsRequests.cs b/Runtime/AvatarCreator/WebRequests/AssetAPIRequests.cs similarity index 97% rename from Runtime/AvatarCreator/WebRequests/PartnerAssetsRequests.cs rename to Runtime/AvatarCreator/WebRequests/AssetAPIRequests.cs index a7398535..00d4b3b8 100644 --- a/Runtime/AvatarCreator/WebRequests/PartnerAssetsRequests.cs +++ b/Runtime/AvatarCreator/WebRequests/AssetAPIRequests.cs @@ -11,16 +11,16 @@ namespace ReadyPlayerMe.AvatarCreator { - public class PartnerAssetsRequests + public class AssetAPIRequests { - private const string TAG = nameof(PartnerAssetsRequests); + private const string TAG = nameof(AssetAPIRequests); private const int LIMIT = 100; private readonly AuthorizedRequest authorizedRequest; private readonly string appId; private readonly Dictionary icons; - public PartnerAssetsRequests(string appId) + public AssetAPIRequests(string appId) { authorizedRequest = new AuthorizedRequest(); icons = new Dictionary(); diff --git a/Runtime/AvatarCreator/WebRequests/PartnerAssetsRequests.cs.meta b/Runtime/AvatarCreator/WebRequests/AssetAPIRequests.cs.meta similarity index 100% rename from Runtime/AvatarCreator/WebRequests/PartnerAssetsRequests.cs.meta rename to Runtime/AvatarCreator/WebRequests/AssetAPIRequests.cs.meta diff --git a/Runtime/AvatarCreator/WebRequests/AuthenticationRequests.cs b/Runtime/AvatarCreator/WebRequests/AuthAPIRequests.cs similarity index 97% rename from Runtime/AvatarCreator/WebRequests/AuthenticationRequests.cs rename to Runtime/AvatarCreator/WebRequests/AuthAPIRequests.cs index 7dd09643..153add42 100644 --- a/Runtime/AvatarCreator/WebRequests/AuthenticationRequests.cs +++ b/Runtime/AvatarCreator/WebRequests/AuthAPIRequests.cs @@ -5,14 +5,14 @@ namespace ReadyPlayerMe.AvatarCreator { - public class AuthenticationRequests + public class AuthAPIRequests { private readonly string domain; private readonly IDictionary headers = CommonHeaders.GetHeadersWithAppId(); private readonly WebRequestDispatcher webRequestDispatcher; - public AuthenticationRequests(string domain) + public AuthAPIRequests(string domain) { this.domain = domain; webRequestDispatcher = new WebRequestDispatcher(); diff --git a/Runtime/AvatarCreator/WebRequests/AuthenticationRequests.cs.meta b/Runtime/AvatarCreator/WebRequests/AuthAPIRequests.cs.meta similarity index 100% rename from Runtime/AvatarCreator/WebRequests/AuthenticationRequests.cs.meta rename to Runtime/AvatarCreator/WebRequests/AuthAPIRequests.cs.meta diff --git a/Runtime/AvatarCreator/WebRequests/AuthorizedRequest.cs b/Runtime/AvatarCreator/WebRequests/AuthorizedRequest.cs index 47318514..24132f6b 100644 --- a/Runtime/AvatarCreator/WebRequests/AuthorizedRequest.cs +++ b/Runtime/AvatarCreator/WebRequests/AuthorizedRequest.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; +using System.Threading; using System.Threading.Tasks; using ReadyPlayerMe.Core; using UnityEngine.Networking; @@ -23,15 +21,8 @@ public class AuthorizedRequest if (response is { IsSuccess: false, ResponseCode: 401 }) { - try - { - await AuthManager.RefreshToken(); - } - catch (Exception) - { - throw; - } - + await AuthManager.RefreshToken(); + response = await Send(requestData, ctx); }