public void GetCartItems(string projectId, string cartId, [NotNull] Action <CartItems> onSuccess, [CanBeNull] Action <Error> onError, [CanBeNull] string locale = null, [CanBeNull] string currency = null) { var urlBuilder = new StringBuilder(string.Format(URL_CART_GET_ITEMS, projectId, cartId)).Append(AdditionalUrlParams); urlBuilder.Append(GetLocaleUrlParam(locale)); urlBuilder.Append(GetCurrencyUrlParam(currency)); WebRequestHelper.Instance.GetRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.GetCartItemsErrors); }
/// <summary> /// Retrieves the current user’s subscriptions. /// </summary> /// <remarks> Swagger method name:<c>Get the current user's subscriptions</c>.</remarks> /// <see cref="https://developers.xsolla.com/store-api/inventory-client/get-user-subscriptions"/> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void GetSubscriptions(string projectId, [NotNull] Action <SubscriptionItems> onSuccess, [CanBeNull] Action <Error> onError) { var url = string.Format(URL_GET_SUBSCRIPTIONS, projectId); var platformParam = GetPlatformUrlParam(); url = ConcatUrlAndParams(url, platformParam); WebRequestHelper.Instance.GetRequest(SdkType.Store, url, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError, Error.ItemsListErrors); }
/// <summary> /// Removes user attributes. /// </summary> /// <remarks> Swagger method name:<c>Update User's Attributes from Client</c>.</remarks> /// <see cref="https://developers.xsolla.com/login-api/attributes/update-users-attributes-from-client"/> /// <param name="token">JWT from Xsolla Login.</param> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="attributeKeys">Attributes names list.</param> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> /// <seealso cref="GetUserAttributes"/> /// <seealso cref="UpdateUserAttributes"/> public void RemoveUserAttributes(string token, string projectId, List <string> attributeKeys, Action onSuccess, Action <Error> onError) { var removeAttributesRequestBody = new ModifyAttributesJson(null, projectId, attributeKeys); var headers = new List <WebRequestHeader>() { WebRequestHeader.AuthHeader(token), WebRequestHeader.ContentTypeHeader() }; WebRequestHelper.Instance.PostRequest(SdkType.Login, URL_USER_UPDATE_ATTRIBUTES, removeAttributesRequestBody, headers, onSuccess, onError); }
/// <summary> /// Returns balance for all virtual currencies. /// </summary> /// <remarks> Swagger method name:<c>Get the current user's virtual balance</c>.</remarks> /// <see cref="https://developers.xsolla.com/store-api/inventory-client/get-user-virtual-balance"/> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> /// <param name="locale">Defines localization of item's text fields.</param> public void GetVirtualCurrencyBalance(string projectId, [NotNull] Action <VirtualCurrenciesBalance> onSuccess, [CanBeNull] Action <Error> onError, [CanBeNull] string locale = null) { var url = string.Format(URL_VIRTUAL_CURRENCY_BALANCE, projectId); var localeParam = GetLocaleUrlParam(locale); var platformParam = GetPlatformUrlParam(); url = ConcatUrlAndParams(url, localeParam, platformParam); WebRequestHelper.Instance.GetRequest(SdkType.Store, url, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError, Error.ItemsListErrors); }
/// <summary> /// Retrieves the user’s inventory. /// </summary> /// <remarks> Swagger method name:<c>Get the current user's inventory</c>.</remarks> /// <see cref="https://developers.xsolla.com/store-api/inventory-client/get-user-inventory"/> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> /// <param name="locale">Defines localization of item's text fields.</param> /// <param name="limit">Limit for the number of elements on the page.</param> /// <param name="offset">Number of the element from which the list is generated (the count starts from 0).</param> public void GetInventoryItems(string projectId, [NotNull] Action <InventoryItems> onSuccess, [CanBeNull] Action <Error> onError, [CanBeNull] string locale = null, int limit = 50, int offset = 0) { var url = string.Format(URL_INVENTORY_GET_ITEMS, projectId, limit, offset); var localeParam = GetLocaleUrlParam(locale); var platformParam = GetPlatformUrlParam(); url = ConcatUrlAndParams(url, localeParam, platformParam); WebRequestHelper.Instance.GetRequest(SdkType.Store, url, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError, Error.ItemsListErrors); }
public void AddItemToCart(string projectId, string cartId, string itemSku, int quantity, [CanBeNull] Action onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_CART_ITEM_ADD, projectId, cartId, itemSku)).Append(AdditionalUrlParams); string jsonData = JsonConvert.SerializeObject(new Quantity { quantity = quantity }); WebRequestHelper.Instance.PutRequest(urlBuilder.ToString(), jsonData, WebRequestHeader.AuthHeader(Token), WebRequestHeader.ContentTypeHeader(), onSuccess, onError, Error.AddToCartCartErrors); }
/*------------------------------------------------------------------------------------------------------------*/ /// <summary> /// 引き継ぎ チェック処理 /// </summary> /// <returns>The inheriting.</returns> public static IEnumerator CheckInheriting() { // 仮待ち 1.5s yield return(new WaitForSeconds(1.5f)); // リクエスト作成 string url_base = Const.WebRequest.BASE_URL + "CheckInheriting/"; int NUM = cGameManager.Instance.UserData.Data.num; string url_param = "?num=" + NUM.ToString(); UnityWebRequest request = UnityWebRequest.Get(url_base); //+url_param); // ヘッダー情報 クッキーがあれば設定する。 if (WebRequestHeader.HeaderEmpty()) { request.SetRequestHeader(Const.WebRequest.HEADER_NAME_COOKIE, WebRequestHeader.header); } yield return(request.Send()); if (request.isError) { Debug.Log("Error"); // メッセージダイアログ表示 GenericUIManager.Instance.ShowMessageDialog("Inherit", "Error"); } else { if (request.responseCode == 200) { // cookieがあればヘッダーに設定 WebRequestHeader.CookieHeaderSetting(request); // レスポンスからJson形式のテキストデータを取得する。 string text = request.downloadHandler.text; InheritResponseData result = JsonUtility.FromJson <InheritResponseData> (text); cGameManager.Instance.UserData.InheritResData = result; Debug.Log(result.message); string title = "Inherit"; if (result.id != "") { // 引き継ぎ実行 cGameManager.Instance.UserData.InheritUserData(); // メッセージダイアログ表示 GenericUIManager.Instance.ShowMessageDialog(title, result.message, UserAccountManager.InheritOKFunc); } else { // 引き継ぎキャンセル メッセージダイアログ表示 GenericUIManager.Instance.ShowMessageDialog(title, result.message); } } } }
public void ConsumeInventoryItem(string projectId, ConsumeItem item, [CanBeNull] Action onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_INVENTORY_ITEM_CONSUME, projectId)).Append(AdditionalUrlParams); var headers = new List <WebRequestHeader>() { WebRequestHeader.AuthHeader(Token), WebRequestHeader.ContentTypeHeader() }; WebRequestHelper.Instance.PostRequest(urlBuilder.ToString(), item, headers, onSuccess, onError, Error.ConsumeItemErrors); }
/// <summary> /// Uploads the profile picture of the authenticated user by JWT. /// </summary> /// <remarks> Swagger method name:<c>Upload User Picture</c>.</remarks> /// <see cref="https://developers.xsolla.com/user-account-api/user-picture/postusersmepicture"/> /// <param name="token">JWT from Xsolla Login.</param> /// <param name="pictureData">User profile picture in the binary format.</param> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> /// <seealso cref="DeleteUserPicture"/> public void UploadUserPicture(string token, byte[] pictureData, string boundary, Action <string> onSuccess, Action <Error> onError) { var headers = new List <WebRequestHeader>() { WebRequestHeader.AuthHeader(token), new WebRequestHeader() { Name = "Content-type", Value = $"multipart/form-data; boundary ={boundary}" } }; WebRequestHelper.Instance.PostUploadRequest(SdkType.Login, URL_USER_PICTURE, pictureData, headers, onSuccess, onError); }
/// <summary> /// Consumes item from inventory. /// </summary> /// <remarks> Swagger method name:<c>Consume item</c>.</remarks> /// <see cref="https://developers.xsolla.com/store-api/inventory-client/consume-item"/> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="item">Contains consume parameters.</param> /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void ConsumeInventoryItem(string projectId, ConsumeItem item, [CanBeNull] Action onSuccess, [CanBeNull] Action <Error> onError) { var url = string.Format(URL_INVENTORY_ITEM_CONSUME, projectId); var platformParam = GetPlatformUrlParam(); url = ConcatUrlAndParams(url, platformParam); var headers = new List <WebRequestHeader>() { WebRequestHeader.AuthHeader(Token.Instance), WebRequestHeader.ContentTypeHeader() }; WebRequestHelper.Instance.PostRequest(SdkType.Store, url, item, headers, onSuccess, onError, Error.ConsumeItemErrors); }
/// <summary> /// Redeems a coupon code. /// </summary> /// <remarks> Swagger method name:<c>Redeem coupon code</c>.</remarks> /// <see cref="https://developers.xsolla.com/store-api/promotions/coupons/redeem-coupon/"/> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="couponCode">Unique coupon code. Contains letters and numbers.</param> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void RedeemCouponCode(string projectId, CouponCode couponCode, [NotNull] Action <CouponRedeemedItems> onSuccess, [CanBeNull] Action <Error> onError) { var url = string.Format(URL_INVENTORY_REDEEM_COUPON, projectId); var platformParam = GetPlatformUrlParam(); url = ConcatUrlAndParams(url, platformParam); var headers = new List <WebRequestHeader>() { WebRequestHeader.AuthHeader(Token.Instance), WebRequestHeader.ContentTypeHeader() }; WebRequestHelper.Instance.PostRequest(SdkType.Store, url, couponCode, headers, onSuccess, onError, Error.CouponErrors); }
void RequestToken([NotNull] Action <Token> onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format("https://api.xsolla.com/merchant/v2/merchants/{0}/token", XsollaSettings.MerchantId)); var headers = new List <WebRequestHeader>() { WebRequestHeader.ContentTypeHeader(), WebRequestHeader.AuthBasic("API KEY") }; var jsonData = JsonUtility.ToJson(GenerateTestToken()); print(jsonData); WebRequestHelper.Instance.PostRequest(urlBuilder.ToString(), jsonData, new WWWForm(), headers, onSuccess, onError); }
/// <summary> /// Gets coupons rewards by its code. Can be used to allow users to choose one of many items as a bonus. /// The usual case is choosing a DRM if the coupon contains a game as a bonus (type=unit). /// </summary> /// <remarks> Swagger method name:<c>Get coupon rewards</c>.</remarks> /// <see cref="https://developers.xsolla.com/store-api/promotions/coupons/get-coupon-rewards-by-code/"/> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="couponCode">Unique case sensitive code. Contains letters and numbers.</param> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void GetCouponRewards(string projectId, string couponCode, [NotNull] Action <CouponReward> onSuccess, [CanBeNull] Action <Error> onError, [CanBeNull] string locale = null) { var url = string.Format(URL_INVENTORY_GET_COUPON_REWARDS, projectId, couponCode); var localeParam = GetLocaleUrlParam(locale); var platformParam = GetPlatformUrlParam(); url = ConcatUrlAndParams(url, localeParam, platformParam); var headers = new List <WebRequestHeader>() { WebRequestHeader.AuthHeader(Token.Instance), WebRequestHeader.ContentTypeHeader() }; WebRequestHelper.Instance.GetRequest(SdkType.Store, url, headers, onSuccess, onError, Error.CouponErrors); }
/*------------------------------------------------------------------------------------------------------------*/ /// <summary> /// 自動ログインリクエスト /// </summary> /// <returns>The login request.</returns> /// <param name="ID">ID</param> /// <param name="PASS">PASS</param> public static IEnumerator AutoLoginRequest(string ID, string PASS) { // リクエストURLを生成 string url_base = Const.WebRequest.BASE_URL + "Login/"; string url_param = "?id=" + ID + "&pass="******"Error") { yield break; } // ローカルに保存する。 UserAccountData.UserData userdata = new UserAccountData.UserData(ID, PASS, response.name, response.num); cGameManager.Instance.UserData.SaveUserData(userdata); // ログイン状態にする cGameManager.Instance.UserData.IsLogin = true; } } }
/*------------------------------------------------------------------------------------------------------------*/ /// <summary> /// 切断リクエスト /// </summary> /// <returns>The request.</returns> public static IEnumerator DisconnectRequest() { // リクエストURLを生成 string url_base = Const.WebRequest.BASE_URL + "Disconnect/"; UnityWebRequest request = UnityWebRequest.Get(url_base); // ヘッダー情報 クッキーがあれば設定する。 if (WebRequestHeader.HeaderEmpty()) { request.SetRequestHeader(Const.WebRequest.HEADER_NAME_COOKIE, WebRequestHeader.header); } // リクエスト送信 yield return(request.Send()); // レスポンスを処理することがないのでここで終了 }
/*------------------------------------------------------------------------------------------------------------*/ /// <summary> /// 自動サインアップリクエスト /// </summary> /// <param name="_ID">ユーザーID</param> /// <param name="_PASS">ユーザーパスワード</param> /// <param name="_NAME">ユーザーネーム</param> public static IEnumerator AutoSignUpRequest(string _ID, string _PASS, string _NAME) { // リクエストURLを生成 string url_base = Const.WebRequest.BASE_URL + "SignUp/"; string url_param = "?id=" + _ID + "&pass="******"&name=" + _NAME; UnityWebRequest request = UnityWebRequest.Get(url_base + url_param); // リクエスト送信 yield return(request.Send()); // 通信エラーチェック if (request.isError) { Debug.Log(request.error); cGameManager.Instance.UserData.IsLogin = false; } else { if (request.responseCode == 200) { // ヘッダー情報 クッキー取得 WebRequestHeader.CookieHeaderSetting(request); // レスポンスからJson形式のテキストデータを取得する。 string text = request.downloadHandler.text; UserAccountResponseData response = JsonUtility.FromJson <UserAccountResponseData>(text); cGameManager.Instance.UserData.UserResData = response; if (response.message == "Error") { yield return(UserAccountManager.AutoSignUp(_NAME)); yield break; } // ローカルへ保存 UserAccountData.UserData userdata = new UserAccountData.UserData(_ID, _PASS, _NAME, response.num); cGameManager.Instance.UserData.SaveUserData(userdata); // ログイン状態にする。 cGameManager.Instance.UserData.IsLogin = true; } } }
/*------------------------------------------------------------------------------------------------------------*/ /// <summary> /// 引き継ぎ設定 確認処理 /// </summary> /// <returns>The inherit setting.</returns> /// <param name="_ID">I.</param> /// <param name="_PASS">PAS.</param> public static IEnumerator CheckInheritSetting(string _ID, string _PASS) { // 仮待ち 1.5s yield return(new WaitForSeconds(1.5f)); // リクエスト作成 string url_base = Const.WebRequest.BASE_URL + "CheckInheritSetting/"; string url_param = "?id=" + _ID + "&pass="******"Error"); // メッセージダイアログ表示 GenericUIManager.Instance.ShowMessageDialog("InheritSetting", "Error"); } else { if (request.responseCode == 200) { // cookieがあればヘッダーに設定 WebRequestHeader.CookieHeaderSetting(request); // レスポンスからJson形式のテキストデータを取得する。 string text = request.downloadHandler.text; MessageResponseData response = JsonUtility.FromJson <MessageResponseData>(text); cGameManager.Instance.UserData.MessageResData = response; // メッセージダイアログ表示 GenericUIManager.Instance.ShowMessageDialog("InheritSetting", response.message); } } }
/// <summary> /// Returns user attributes. /// </summary> /// <remarks> Swagger method name:<c>Get User's Attributes from Client</c>.</remarks> /// <see cref="https://developers.xsolla.com/login-api/attributes/get-user-attributes-from-client"/> /// <param name="token">JWT from Xsolla Login.</param> /// <param name="projectId">Project ID from your Publisher Account.</param> /// <param name="attributeKeys">Attributes names list filter</param> /// <param name="userId">Login user ID. Can be null, because this info exist in the token.</param> /// <param name="attributeType">User attribute type to get</param> /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> /// <seealso cref="UpdateUserAttributes"/> /// <seealso cref="RemoveUserAttributes"/> public void GetUserAttributes(string token, string projectId, UserAttributeType attributeType, [CanBeNull] List <string> attributeKeys, [CanBeNull] string userId, [NotNull] Action <List <UserAttribute> > onSuccess, [CanBeNull] Action <Error> onError) { var getAttributesRequestBody = new GetAttributesJson(attributeKeys, projectId, userId); var headers = new List <WebRequestHeader> { WebRequestHeader.AuthHeader(token), WebRequestHeader.ContentTypeHeader() }; string url = default(string); switch (attributeType) { case UserAttributeType.CUSTOM: url = URL_USER_GET_ATTRIBUTES; break; case UserAttributeType.READONLY: url = URL_USER_GET_READONLY_ATTRIBUTES; break; } WebRequestHelper.Instance.PostRequest(SdkType.Login, url, getAttributesRequestBody, headers, onSuccess, onError); }
/*------------------------------------------------------------------------------------------------------------*/ /// <summary> /// 削除リクエスト /// </summary> /// <returns>The user account.</returns> /// <param name="_ID">I.</param> /// <param name="_PASS">PAS.</param> public static IEnumerator DeleteUserAccount(string _ID, string _PASS) { // リクエスト作成 string url_base = Const.WebRequest.BASE_URL + "Delete/"; string url_param = "?id=" + _ID + "&pass="******"Error"); } else { if (request.responseCode == 200) { WebRequestHeader.CookieHeaderSetting(request); // レスポンスからJson形式のテキストデータを取得する。 string text = request.downloadHandler.text; MessageResponseData response = JsonUtility.FromJson <MessageResponseData> (text); Debug.Log(response.message); if (response.message != "") { // ローカルから削除 cGameManager.Instance.UserData.DeleteData(); // メッセージダイアログ表示 GenericUIManager.Instance.ShowMessageDialog("DELETE", response.message); } } } }
/// <summary> /// スコアランキングの取得リクエスト /// </summary> /// <returns>The ranking request.</returns> public static IEnumerator ScoreRankingRequest(UserAccountData.UserData userdata) { // リクエストURLを生成 string url_base = Const.WebRequest.BASE_URL + "ScoreRanking/"; string url_param = "?id=" + userdata.id; UnityWebRequest request = UnityWebRequest.Get(url_base); //+url_param); if (WebRequestHeader.HeaderEmpty()) { request.SetRequestHeader(Const.WebRequest.HEADER_NAME_COOKIE, WebRequestHeader.header); } // リクエスト送信 yield return(request.Send()); // 通信エラーチェック if (request.isError) { Debug.Log(request.error); GenericUIManager.Instance.ShowMessageDialog("Error", request.error); } else { if (request.responseCode == 200) { WebRequestHeader.CookieHeaderSetting(request); string text = request.downloadHandler.text; // レスポンスデータの変換 ScoreRankingResponseData res = JsonUtility.FromJson <ScoreRankingResponseData> (text); if (res.Data.Count != 0) { cGameManager.Instance._RankingData = res; } } } }
/// <summary> /// Request code from unified account to link publishing platform account. /// </summary> /// <remarks> Swagger method name:<c>Create Code for Linking Accounts</c>.</remarks> /// <see cref="https://developers.xsolla.com/login-api/users/create-code-for-linking-accounts"/> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> /// <seealso cref="SignInConsoleAccount"/> /// <seealso cref="LinkConsoleAccount"/> #endregion public void RequestLinkingCode(Action <LinkingCode> onSuccess, Action <Error> onError) { WebRequestHelper.Instance.PostRequest <LinkingCode>(SdkType.Login, URL_LINKING_CODE_REQUEST, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError); }
public void CheckOrderStatus(string projectId, int orderId, [NotNull] Action <OrderStatus> onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_ORDER_GET_STATUS, projectId, orderId)).Append(AdditionalUrlParams); WebRequestHelper.Instance.GetRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.OrderStatusErrors); }
public void BuyCart(string projectId, string cartId, [CanBeNull] Action <PurchaseData> onSuccess, [CanBeNull] Action <Error> onError, PurchaseParams purchaseParams = null) { TempPurchaseParams tempPurchaseParams = new TempPurchaseParams { sandbox = XsollaSettings.IsSandbox }; var urlBuilder = new StringBuilder(string.Format(URL_BUY_CART, projectId, cartId)).Append(AdditionalUrlParams); WebRequestHelper.Instance.PostRequest <PurchaseData, TempPurchaseParams>(urlBuilder.ToString(), tempPurchaseParams, WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.BuyCartErrors); }
/// <summary> /// Adds the username/email and password authentication to the existing user account. This call is used if the account is created via device ID or phone number. /// </summary> /// <remarks>Swagger method name:<c>Add username/email auth to account</c>.</remarks> /// <see cref="https://developers.xsolla.com/login-api/user-account/managed-by-client/user-profile/add-username-email-auth-to-account/"/>. /// <param name="email">User email.</param> /// <param name="password">User password.</param> /// <param name="username">Username.</param> /// <param name="promoEmailAgreement">User consent to receive the newsletter.</param> /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void AddUsernameEmailAuthToAccount(string email, string password, string username, int?promoEmailAgreement = null, Action <bool> onSuccess = null, Action <Error> onError = null) { var requestBody = new AddUsernameAndEmailRequest(email, password, promoEmailAgreement, username); var loginUrl = XsollaSettings.CallbackUrl; var url = string.Format(URL_ADD_USERNAME_EMAIL, loginUrl); Action <AddUsernameAndEmailResponse> onComplete = response => { onSuccess?.Invoke(response.email_confirmation_required); }; WebRequestHelper.Instance.PostRequest <AddUsernameAndEmailResponse, AddUsernameAndEmailRequest>(SdkType.Login, url, requestBody, WebRequestHeader.AuthHeader(Token.Instance), onComplete: onComplete, onError: onError); }
/// <summary> /// Gets a list of user's devices. /// </summary> /// <remarks>Swagger method name:<c>Get user's devices</c>.</remarks> /// <see cref="https://developers.xsolla.com/login-api/user-account/managed-by-client/devices/get-users-devices/"/>. /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void GetUserDevices(Action <List <UserDeviceInfo> > onSuccess = null, Action <Error> onError = null) { var url = URL_GET_USERS_DEVICES; Action <List <UserDeviceInfo> > onComplete = responseItems => { onSuccess?.Invoke(responseItems); }; WebRequestHelper.Instance.GetRequest <List <UserDeviceInfo> >(SdkType.Login, url, WebRequestHeader.AuthHeader(Token.Instance), onComplete: onComplete, onError: onError); }
/// <summary> /// Links the specified device to the user account. To enable authentication via device ID and linking, contact your Account Manager. /// </summary> /// <remarks>Swagger method name:<c>Link device to account</c>.</remarks> /// <see cref="https://developers.xsolla.com/login-api/user-account/managed-by-client/devices/link-device-to-account/"/>. /// <param name="deviceType">Type of the device.</param> /// <param name="deviceName">Manufacturer and model name of the device.</param> /// <param name="deviceId">Device ID: For Android it is an ANDROID_ID constant. For iOS it is an identifierForVendor property.</param> /// <param name="onSuccess">Successful operation callback.</param> /// <param name="onError">Failed operation callback.</param> public void LinkDeviceToAccount(DeviceType deviceType, string deviceName, string deviceId, Action onSuccess = null, Action <Error> onError = null) { var deviceTypeAsString = deviceType.ToString().ToLower(); var requestBody = new LoginDeviceIdRequest(deviceName, deviceId); var url = string.Format(URL_DEVICES_LINKING, deviceTypeAsString); WebRequestHelper.Instance.PostRequest <LoginDeviceIdRequest>(SdkType.Login, url, requestBody, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError); }
public void RemoveItemFromCart(string projectId, string cartId, string itemSku, [CanBeNull] Action onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_CART_ITEM_REMOVE, projectId, cartId, itemSku)).Append(AdditionalUrlParams); WebRequestHelper.Instance.DeleteRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.DeleteFromCartErrors); }
public void ClearCart(string projectId, string cartId, [CanBeNull] Action onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_CART_CLEAR, projectId, cartId)).Append(AdditionalUrlParams); WebRequestHelper.Instance.PutRequest <Quantity>(urlBuilder.ToString(), null, WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.AddToCartCartErrors); }
public void AddItemToCart(string projectId, string cartId, string itemSku, int quantity, [CanBeNull] Action onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_CART_ITEM_ADD, projectId, cartId, itemSku)).Append(AdditionalUrlParams); Quantity jsonObject = new Quantity { quantity = quantity }; WebRequestHelper.Instance.PutRequest <Quantity>(urlBuilder.ToString(), jsonObject, WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.AddToCartCartErrors); }
public void CreateNewCart(string projectId, [NotNull] Action <Cart> onSuccess, [CanBeNull] Action <Error> onError) { var urlBuilder = new StringBuilder(string.Format(URL_CART_CREATE_NEW, projectId)).Append(AdditionalUrlParams); WebRequestHelper.Instance.GetRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.CreateCartErrors); }