예제 #1
0
        /// <summary>
        /// Logs the user out and deletes the user session.
        /// </summary>
        /// <see cref="https://developers.xsolla.com/login-api/auth/oauth-20/log-user-out/"/>
        /// <param name="token">JWT from Xsolla Login.</param>
        /// <param name="logoutType">Shows how the user is logged out and how the user session is deleted.</param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void OAuthLogout(string token, OAuthLogoutType logoutType, Action onSuccess, Action <Error> onError = null)
        {
            var logoutTypeFlag = logoutType.ToString().ToLowerInvariant();
            var url            = string.Format(URL_OAUTH_LOGOUT, logoutTypeFlag);

            WebRequestHelper.Instance.GetRequest(SdkType.Login, url, WebRequestHeader.AuthHeader(token), onSuccess, onError);
        }
        /// <summary>
        /// Gets links for authentication via the social networks enabled in Publisher Account > Login settings > Social Networks.
        /// The links are valid for 10 minutes. You can get the link by this method and add it to your button for authentication via the social network.
        /// </summary>
        /// <remarks> Swagger method name:<c>Get Links for Social Auth</c>.</remarks>
        /// <see cref="https://developers.xsolla.com/user-account-api/social-networks/getusersmeloginurls/"/>.
        /// <param name="onSuccess">Success operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        /// <param name="locale">Defines localization request localization settings.</param>
        public void GetLinksForSocialAuth(Action <List <SocialNetworkLink> > onSuccess, Action <Error> onError = null, string locale = null)
        {
            var localeParam = GetLocaleUrlParam(locale).Replace("&", string.Empty);
            var url         = string.Format(URL_GET_AVAILABLE_SOCIAL_NETWORKS, localeParam);

            WebRequestHelper.Instance.GetRequest(SdkType.Login, url, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError);
        }
        /// <summary>
        /// Begins processing to update a list of user’s friends from a social provider.
        /// </summary>
        /// <remarks> Swagger method name:<c>Update User's Friends</c>.</remarks>
        /// <see cref="https://developers.xsolla.com/login-api/methods/users/update-users-friends/"/>.
        /// <param name="token">JWT from Xsolla Login.</param>
        /// <param name="provider">Name of social provider.</param>
        /// <param name="onSuccess">Success operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void UpdateUserSocialFriends(string token, SocialProvider provider = SocialProvider.None, Action onSuccess = null, Action <Error> onError = null)
        {
            var providerUrlAddition = provider != SocialProvider.None ? $"?platform={provider.GetParameter()}" : string.Empty;
            var url = string.Format(URL_USER_UPDATE_SOCIAL_FRIENDS, providerUrlAddition);

            WebRequestHelper.Instance.PostRequest(SdkType.Login, url, WebRequestHeader.AuthHeader(token), onSuccess, onError);
        }
        /// <summary>
        /// Grants entitlement by a provided game code.
        /// </summary>
        /// <see cref="https://developers.xsolla.com/commerce-api/game-keys/entitlement/redeem-game-pin-code/"/>
        /// <param name="projectId">Project ID from your Publisher Account.</param>
        /// <param name="gameCode">Game code.</param>
        /// <param name="sandbox">Redeem game code in the sandbox mode. The option is available for those users who are specified in the list of company users.</param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void RedeemGameCode(string projectId, string gameCode, bool sandbox, Action onSuccess, Action <Error> onError = null)
        {
            var url  = string.Format(URL_REDEEM_GAME_CODE, projectId);
            var data = new RedeemGameCodeRequest(gameCode, sandbox);

            WebRequestHelper.Instance.PostRequest(SdkType.Login, url, data, WebRequestHeader.AuthHeader(Token.Instance), onSuccess, onError, Error.LoginErrors);
        }
        /// <summary>
        /// Gets user’s friends from social provider.
        /// </summary>
        /// <remarks> Swagger method name:<c>Get User's Friends</c>.</remarks>
        /// <see cref="https://developers.xsolla.com/login-api/methods/users/get-users-friends/"/>.
        /// <param name="token">JWT from Xsolla Login.</param>
        /// <param name="provider">Name of social provider.</param>
        /// <param name="offset">Offset.</param>
        /// <param name="limit">Limit.</param>
        /// <param name="withUid"></param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void GetUserSocialFriends(string token, SocialProvider provider = SocialProvider.None, uint offset = 0, uint limit = 500, bool withUid = false, Action <UserSocialFriends> onSuccess = null, Action <Error> onError = null)
        {
            var withUidFlag         = withUid ? "true" : "false";
            var providerUrlAddition = provider != SocialProvider.None ? $"&platform={provider.GetParameter()}" : string.Empty;
            var url = string.Format(URL_USER_SOCIAL_FRIENDS, offset, limit, withUidFlag, providerUrlAddition);

            WebRequestHelper.Instance.GetRequest(SdkType.Login, url, WebRequestHeader.AuthHeader(token), onSuccess, onError);
        }
예제 #6
0
        // TODO: coming soon.
        //private const string URL_VIRTUAL_CURRENCY_INFO = "https://store.xsolla.com/api/v2/project/{0}/items/virtual_currency/sku/{1}";
        //public void GetVirtualCurrencyInfo(string projectId, string sku, [NotNull] Action<InventoryItems> onSuccess, [CanBeNull] Action<Error> onError, [CanBeNull] string locale = null)
        //{
        //	var urlBuilder = new StringBuilder(string.Format(URL_VIRTUAL_CURRENCY_INFO, projectId, sku)).Append(AdditionalUrlParams);
        //	urlBuilder.Append(GetLocaleUrlParam(locale));

        //	WebRequestHelper.Instance.GetRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.ItemsListErrors);
        //}

        public void GetVirtualCurrencyPackagesList(string projectId, [NotNull] Action <VirtualCurrencyPackages> onSuccess, [CanBeNull] Action <Error> onError, [CanBeNull] string locale = null)
        {
            var urlBuilder = new StringBuilder(string.Format(URL_VIRTUAL_CURRENCY_PACKAGES_IN_PROJECT, projectId)).Append(AdditionalUrlParams);

            urlBuilder.Append(GetLocaleUrlParam(locale));

            WebRequestHelper.Instance.GetRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.ItemsListErrors);
        }
        public void GetInventoryItems(string projectId, [NotNull] Action <InventoryItems> onSuccess, [CanBeNull] Action <Error> onError, [CanBeNull] string locale = null)
        {
            var urlBuilder = new StringBuilder(string.Format(URL_INVENTORY_GET_ITEMS, projectId)).Append(AdditionalUrlParams);

            urlBuilder.Append(GetLocaleUrlParam(locale));

            WebRequestHelper.Instance.GetRequest(urlBuilder.ToString(), WebRequestHeader.AuthHeader(Token), onSuccess, onError, Error.ItemsListErrors);
        }
예제 #8
0
        /// <summary>
        /// Unlinks the specified device from the user account. To enable authentication via device ID and unlinking, contact your Account Manager.
        /// </summary>
        /// <remarks>Swagger method name:<c>Unlink the device from account</c>.</remarks>
        /// <see cref="https://developers.xsolla.com/login-api/user-account/managed-by-client/devices/unlink-device-from-account/"/>.
        /// <param name="id">Device ID of the device you want to unlink. It is generated by the Xsolla Login server. It is not the same as the `device_id` parameter from Auth via device ID call.</param>
        /// <param name="onSuccess">Successful operation callback.</param>
        /// <param name="onError">Failed operation callback.</param>
        public void UnlinkDeviceFromAccount(int id, Action onSuccess = null, Action <Error> onError = null)
        {
            var url = string.Format(URL_DEVICES_LINKING, id);

            WebRequestHelper.Instance.DeleteRequest(SdkType.Login, url, WebRequestHeader.AuthHeader(Token.Instance),
                                                    onSuccess,
                                                    onError);
        }
예제 #9
0
        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);
        }
예제 #10
0
        /// <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);
        }
예제 #11
0
        /// <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);
        }
예제 #13
0
        /// <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);
        }
예제 #14
0
        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);
        }
        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);
        }
예제 #16
0
        /// <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);
        }
예제 #17
0
        /// <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);
        }
예제 #18
0
        /// <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);
        }
예제 #19
0
        /// <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);
        }
예제 #20
0
        /// <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);
        }
예제 #21
0
        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);
        }
        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);
        }
예제 #24
0
        /// <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);
        }
예제 #25
0
        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);
        }
예제 #26
0
        /// <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);
        }
예제 #27
0
        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);
        }
예제 #28
0
        /// <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);
        }
 /// <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);
 }
예제 #30
0
        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);
        }