Example #1
0
        public Task SendGiftRequestEmailAsync(string productKey, string recipientEmail)
        {
            if (productKey == null)
            {
                throw new ArgumentNullException(nameof(productKey));
            }
            if (recipientEmail == null)
            {
                throw new ArgumentNullException(nameof(productKey));
            }
            return(Task.Run(() =>
            {
                DrmClient.EnsureLoggedIn(false);
                var resp = Rest.DoPost("Product/Gift/Request", new
                {
                    SessionKey = DrmClient.SessionKey,
                    ProductKeyToGift = productKey,
                    EmailAddressToGiftTo = recipientEmail
                });

                if (resp.Message == "user_not_found")
                {
                    throw new AccountDetailsIncorrectException("user_not_found");
                }

                if (resp.Message == "product_key_not_found")
                {
                    throw new ProductKeyNotFoundException();
                }
            }));
        }
Example #2
0
        public Task <bool> RedeemAsync(string productKey)
        {
            if (!DrmClient._initialized)
            {
                throw new NotInitializedException();
            }
            if (productKey == null)
            {
                throw new ArgumentNullException(nameof(productKey));
            }
            return(Task.Run(() =>
            {
                DrmClient.EnsureLoggedIn();

                var resp = Rest.DoPost("Product/Redeem", new
                {
                    SessionKey = DrmClient.SessionKey,
                    ProductKey = productKey
                });

                if (resp.Message == "product_key_not_found")
                {
                    throw new ProductKeyNotFoundException();
                }

                if (resp.Message == "product_key_already_redeemed")
                {
                    throw new ProductKeyAlreadyRedeemedException();
                }

                return true;
            }));
        }
Example #3
0
        public Task <string> GetServerTokenAsync()
        {
            return(Task.Run(() =>
            {
                DrmClient.EnsureLoggedIn(false);

                var resp = Rest.DoPost <GetServerTokenResponse>("Token/Get", new
                {
                    SessionKey = DrmClient.SessionKey
                });

                return resp.Data.Token;
            }));
        }