public void MakeRequest(string method, string url, Dictionary <string, object> data, RequestReadyDelegate readyDelegate, RequestFailedDelegate failedDelegate) { StartCoroutine(MakeRequestEnumerator(method, url, data, readyDelegate, failedDelegate)); }
private IEnumerator MakeRequestEnumerator(string method, string url, Dictionary <string, object> data, RequestReadyDelegate readyDelegate, RequestFailedDelegate failedDelegate) { if (data == null) { data = new Dictionary <string, object>(); } if (url.IndexOf("http") != 0) { if (url.IndexOf("/") != 0) { url = "/" + url; } url = "https://api.everyplay.com" + url; } method = method.ToLower(); Hashtable headers = new Hashtable(); string accessToken = AccessToken(); if (accessToken != null) { headers["Authorization"] = "Bearer " + accessToken; } else { if (url.IndexOf("client_id") == -1) { if (url.IndexOf("?") == -1) { url += "?"; } else { url += "&"; } url += "client_id=" + clientId; } } data.Add("_method", method); string dataString = Json.Serialize(data); byte[] dataArray = System.Text.Encoding.UTF8.GetBytes(dataString); headers["Accept"] = "application/json"; headers["Content-Type"] = "application/json"; headers["Data-Type"] = "json"; headers["Content-Length"] = dataArray.Length; WWW www = new WWW(url, dataArray, headers); yield return(www); if (!string.IsNullOrEmpty(www.error) && failedDelegate != null) { failedDelegate("Everyplay error: " + www.error); } else if (string.IsNullOrEmpty(www.error) && readyDelegate != null) { readyDelegate(www.text); } }
public override void RequestProductInformation(string[] productIds, ProductInformationDelegate onSucceed, RequestFailedDelegate onFailed) { if (productIds == null || productIds.Length == 0) throw new ArgumentException("InAppPurchaseManager: At least one product id is required."); throw new NotImplementedException(); }
public ProductsRequestDelegate(ProductInformationDelegate onSucceed, RequestFailedDelegate onFailed) { this.onSucceed = onSucceed; this.onFailed = onFailed; }
public override void RequestProductInformation(string[] productIds, ProductInformationDelegate onSucceed, RequestFailedDelegate onFailed) { if (productIds == null || productIds.Length == 0) throw new ArgumentException("InAppPurchaseManager: At least one product id is required."); try { var products = new NSString[productIds.Length]; for (int i = 0; i < productIds.Length; i++) { products[i] = new NSString(productIds[i]); } NSSet productIdentifiers = NSSet.MakeNSObjectSet<NSString>(products); if (productsRequestDelegate == null) { productsRequestDelegate = new ProductsRequestDelegate(onSucceed, onFailed); } SKProductsRequest productsRequest = new SKProductsRequest(productIdentifiers); productsRequest.Delegate = productsRequestDelegate; productsRequest.Start(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); if (onFailed != null) { onFailed(new InAppPurchaseException("Error while requesting product information.", 0, ex)); } } }
public abstract void RequestProductInformation(string[] productIds, ProductInformationDelegate onSucceed, RequestFailedDelegate onFailed);
public virtual void RequestProductInformation(string productId, ProductInformationDelegate onSucceed, RequestFailedDelegate onFailed) { if (String.IsNullOrWhiteSpace(productId) == true) throw new ArgumentException("InAppPurchaseManager: Invalid product id."); RequestProductInformation(new string[]{ productId }, onSucceed, onFailed); }