public virtual void GetPurchases(string query, Action <Dictionary <string, object> > doneCallbackAction, Action <UIError> errorCallbackAction) { HandleHttpRequest(() => { var httpRequest = m_HttpClientFactory.GetASyncHTTPClient($"{host}{k_PurchasesUri}{query ?? string.Empty}"); httpRequest.tag = $"GetPurchases{query}"; return(httpRequest); }, doneCallbackAction, errorCallbackAction); }
private void GetTokenInfo(Action <TokenInfo> doneCallback) { GetAccessToken(accessToken => { if (m_TokenInfo?.IsValid() ?? false) { doneCallback?.Invoke(m_TokenInfo); return; } m_OnTokenInfoFetched += doneCallback; if (m_TokenRequest != null) { return; } m_TokenRequest = m_HttpClientFactory.GetASyncHTTPClient($"{host}{k_TokenInfoUri}?access_token={accessToken.accessToken}"); m_TokenRequest.doneCallback = httpClient => { m_TokenRequest = null; m_TokenInfo = null; var response = AssetStoreUtils.ParseResponseAsDictionary(httpClient); if (response != null) { if (response.ContainsKey("errorMessage")) { OnOperationError(string.Format(L10n.Tr("Error while getting token info: {0}"), response.GetString("errorMessage"))); return; } var tokenInfo = new TokenInfo(response); if (tokenInfo.IsValid()) { m_TokenInfo = tokenInfo; m_OnTokenInfoFetched?.Invoke(m_TokenInfo); m_OnTokenInfoFetched = null; } else { OnOperationError(L10n.Tr("Token info invalid")); } } }; m_TokenRequest.Begin(); }); }
public virtual void DownloadImageAsync(long productID, string url, Action <long, Texture2D> doneCallbackAction = null) { if (m_MissingTexture == null) { m_MissingTexture = (Texture2D)EditorGUIUtility.LoadRequired("Icons/UnityLogo.png"); } var texture = LoadImage(productID, url); if (texture != null) { doneCallbackAction?.Invoke(productID, texture); return; } var httpRequest = m_HttpClientFactory.GetASyncHTTPClient(url); httpRequest.doneCallback = httpClient => { if (httpClient.IsSuccess() && httpClient.texture != null) { SaveImage(productID, url, httpClient.texture); doneCallbackAction?.Invoke(productID, httpClient.texture); return; } doneCallbackAction?.Invoke(productID, m_MissingTexture); }; httpRequest.Begin(); }
public virtual void DownloadImageAsync(long productID, string url, Action <long, Texture2D> doneCallbackAction = null) { var texture = LoadImage(productID, url); if (texture != null) { doneCallbackAction?.Invoke(productID, texture); return; } var httpRequest = m_HttpClientFactory.GetASyncHTTPClient(url); httpRequest.doneCallback = httpClient => { if (httpClient.IsSuccess() && httpClient.texture != null) { SaveImage(productID, url, httpClient.texture); doneCallbackAction?.Invoke(productID, httpClient.texture); return; } doneCallbackAction?.Invoke(productID, null); }; httpRequest.Begin(); }