/// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Address address;
            IValidator <Address> validator;

            try
            {
                address = new Address
                {
                    AddressLine1 = AddressLine1,
                    AddressLine2 = AddressLine2,
                    City         = City,
                    Country      = Country,
                    PostalCode   = PostalCode,
                    Region       = Region,
                    State        = State
                };

                validator = new AddressValidator(Partner);

                WriteObject(validator.IsValid(address));
            }
            finally
            {
                address = null;
            }
        }
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            OrganizationProfile  profile;
            IValidator <Address> validator;

            if (ShouldProcess("Updates the partner's organization profile"))
            {
                profile = Partner.Profiles.OrganizationProfile.Get();

                profile.CompanyName = UpdateValue(CompanyName, profile.CompanyName);
                profile.Email       = UpdateValue(Email, profile.Email);
                profile.Language    = UpdateValue(Language, profile.Language);
                profile.Culture     = UpdateValue(Culture, profile.Culture);

                profile.DefaultAddress.AddressLine1 = UpdateValue(AddressLine1, profile.DefaultAddress.AddressLine1);
                profile.DefaultAddress.AddressLine2 = UpdateValue(AddressLine2, profile.DefaultAddress.AddressLine2);
                profile.DefaultAddress.City         = UpdateValue(City, profile.DefaultAddress.City);
                profile.DefaultAddress.Country      = UpdateValue(Country, profile.DefaultAddress.Country);
                profile.DefaultAddress.PostalCode   = UpdateValue(PostalCode, profile.DefaultAddress.PostalCode);
                profile.DefaultAddress.State        = UpdateValue(State, profile.DefaultAddress.State);
                profile.DefaultAddress.FirstName    = UpdateValue(FirstName, profile.DefaultAddress.FirstName);
                profile.DefaultAddress.LastName     = UpdateValue(LastName, profile.DefaultAddress.LastName);
                profile.DefaultAddress.PhoneNumber  = UpdateValue(PhoneNumber, profile.DefaultAddress.PhoneNumber);

                validator = new AddressValidator(Partner);

                if (validator.IsValid(profile.DefaultAddress))
                {
                    profile = Partner.Profiles.OrganizationProfile.Update(profile);
                    WriteObject(new PSOrganizationProfile(profile));
                }
            }
        }
        public void CanDetectInvalidAddress()
        {
            var invalidAddress   = "invalid";
            var addressValidator = new AddressValidator(NBitcoin.Altcoins.BGold.Instance.Testnet);

            Assert.False(addressValidator.IsValid(invalidAddress));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            IValidator <Address> validator;
            LegalBusinessProfile profile;

            if (ShouldProcess(Resources.SetPartnerLegalProfileWhatIf))
            {
                profile = Partner.Profiles.LegalBusinessProfile.GetAsync().GetAwaiter().GetResult();

                profile.Address.AddressLine1   = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                profile.Address.AddressLine2   = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                profile.Address.City           = UpdateValue(City, profile.Address.City);
                profile.Address.Country        = UpdateValue(Country, profile.Address.Country);
                profile.Address.PostalCode     = UpdateValue(PostalCode, profile.Address.PostalCode);
                profile.Address.Region         = UpdateValue(Region, profile.Address.Region);
                profile.Address.State          = UpdateValue(State, profile.Address.State);
                profile.CompanyApproverAddress = profile.Address;
                profile.CompanyApproverEmail   = UpdateValue(EmailAddress, profile.CompanyApproverEmail);

                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(profile.Address, d => WriteDebug(d)))
                    {
                        throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                    }
                }

                profile = Partner.Profiles.LegalBusinessProfile.UpdateAsync(profile).GetAwaiter().GetResult();

                WriteObject(new PSLegalBusinessProfile(profile));
            }
        }
        public void IsValidDEAddress()
        {
            Address          address;
            AddressValidator validator;
            Mock <IPartner>  partnerOperations;

            try
            {
                partnerOperations = new Mock <IPartner>();
                partnerOperations.Setup(p => p.CountryValidationRules.ByCountry("DE").Get())
                .Returns(OperationFactory.Instance.GetResource <CountryValidationRules>("GetCountryValidationRules-DE"));
                partnerOperations.Setup(p => p.Validations.IsAddressValid(It.IsAny <Address>())).Returns(true);

                validator = new AddressValidator(partnerOperations.Object);

                address = new Address
                {
                    AddressLine1 = "Walter-Gropius-Str. 5",
                    City         = "München",
                    Country      = "DE",
                    FirstName    = "John",
                    LastName     = "Doe",
                    PhoneNumber  = "49 (89) 3176 4900",
                    PostalCode   = "80807"
                };

                Assert.AreEqual(true, validator.IsValid(address));
            }
            finally
            {
                address           = null;
                partnerOperations = null;
                validator         = null;
            }
        }
        public void IsValidCNAddress()
        {
            Address          address;
            AddressValidator validator;
            Mock <IPartner>  partnerOperations;

            partnerOperations = new Mock <IPartner>();
            partnerOperations.Setup(p => p.CountryValidationRules.ByCountry("CN").Get())
            .Returns(OperationFactory.Instance.GetResource <CountryValidationRules>("GetCountryValidationRules-CN"));
            partnerOperations.Setup(p => p.Validations.IsAddressValid(It.IsAny <Address>())).Returns(true);

            validator = new AddressValidator(partnerOperations.Object);

            address = new Address
            {
                AddressLine1 = "5 Danling Street",
                City         = "Haidian District",
                Country      = "CN",
                FirstName    = "John",
                LastName     = "Doe",
                PhoneNumber  = "(86-10) 5917-0101",
                PostalCode   = "100080",
                State        = "BJ"
            };

            Assert.AreEqual(true, validator.IsValid(address));
        }
        public void IsValidGBAddress()
        {
            Address          address;
            AddressValidator validator;
            Mock <IPartner>  partnerOperations;

            try
            {
                partnerOperations = new Mock <IPartner>();
                partnerOperations.Setup(p => p.CountryValidationRules.ByCountry("GB").Get())
                .Returns(OperationFactory.Instance.GetResource <CountryValidationRules>("GetCountryValidationRules-GB"));
                partnerOperations.Setup(p => p.Validations.IsAddressValid(It.IsAny <Address>())).Returns(true);

                validator = new AddressValidator(partnerOperations.Object);

                address = new Address
                {
                    AddressLine1 = "Manchester Business Park 3000 Aviator Way",
                    City         = "Manchester",
                    Country      = "GB",
                    FirstName    = "John",
                    LastName     = "Doe",
                    PhoneNumber  = "0344 800 2400",
                    PostalCode   = "M22 5TG"
                };

                Assert.AreEqual(true, validator.IsValid(address));
            }
            finally
            {
                address           = null;
                partnerOperations = null;
                validator         = null;
            }
        }
        public void InvalidAddressValueTest()
        {
            Address          address;
            AddressValidator validator;
            Mock <IPartner>  partnerOperations;

            partnerOperations = new Mock <IPartner>();
            partnerOperations.Setup(p => p.CountryValidationRules.ByCountry("US").Get())
            .Returns(OperationFactory.Instance.GetResource <CountryValidationRules>("GetCountryValidationRules-US"));
            partnerOperations.Setup(p => p.Validations.IsAddressValid(It.IsAny <Address>())).Returns(false);

            validator = new AddressValidator(partnerOperations.Object);

            address = new Address
            {
                AddressLine1 = "1 Microsoft Way",
                City         = "Redmond",
                Country      = "US",
                FirstName    = "John",
                LastName     = "Doe",
                PhoneNumber  = "425-55-5555",
                PostalCode   = "98052",
                State        = "Washington"
            };

            validator.IsValid(address);
        }
        public void CanDetectInvalidAddress()
        {
            var invalidAddress   = "invalid";
            var addressValidator = new AddressValidator(Network.Main, BCash.Instance.Mainnet);

            Assert.False(addressValidator.IsValid(invalidAddress));
        }
Ejemplo n.º 10
0
        public void Validates_To_False_If_Address_Null(Address address, bool expected)
        {
            var sut = new AddressValidator();

            var result = sut.IsValid(address);

            result.Should().Be(expected);
        }
        public void CanDetectInvalidAddress()
        {
            PrepareNetworks.EnsureLiteCoinPrepared();

            var invalidAddress   = "invalid";
            var addressValidator = new AddressValidator(NBitcoin.Litecoin.Networks.Testnet);

            Assert.False(addressValidator.IsValid(invalidAddress));
        }
        public void CanDetectInvalidAddress()
        {
            PrepareNetworks.EnsureVertcoinPrepared();

            var invalidAddress   = "invalid";
            var addressValidator = new AddressValidator();

            Assert.False(addressValidator.IsValid(invalidAddress));
        }
Ejemplo n.º 13
0
        public void IsValid_validValues_returnTrue()
        {
            var address = CreateAddress(country: "country-1", city: "city-1", street: "street");

            var target = new AddressValidator();

            var result = target.IsValid(address);

            Assert.True(result);
        }
Ejemplo n.º 14
0
        public void IsValid_doesNotHaveStreet_returnFalse()
        {
            var address = CreateAddress(street: null);

            var target = new AddressValidator();

            var result = target.IsValid(address);

            Assert.False(result);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Customer             customer;
            IValidator <Address> validator;
            string customerId;

            try
            {
                customerId = (InputObject == null) ? CustomerId : InputObject.CustomerId;

                if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.SetPartnerCustomerWhatIf, customerId)))
                {
                    if (InputObject == null && string.IsNullOrEmpty(CustomerId))
                    {
                        throw new PSInvalidOperationException(Resources.InvalidSetCustomerIdentifierException);
                    }

                    customer = Partner.Customers[customerId].Get();

                    customer.BillingProfile.DefaultAddress.AddressLine1 = UpdateValue(BillingAddressLine1, customer.BillingProfile.DefaultAddress.AddressLine1);
                    customer.BillingProfile.DefaultAddress.AddressLine2 = UpdateValue(BillingAddressLine2, customer.BillingProfile.DefaultAddress.AddressLine2);
                    customer.BillingProfile.DefaultAddress.City         = UpdateValue(BillingAddressCity, customer.BillingProfile.DefaultAddress.City);
                    customer.BillingProfile.DefaultAddress.Country      = UpdateValue(BillingAddressCountry, customer.BillingProfile.DefaultAddress.Country);
                    customer.BillingProfile.DefaultAddress.PhoneNumber  = UpdateValue(BillingAddressPhoneNumber, customer.BillingProfile.DefaultAddress.PhoneNumber);
                    customer.BillingProfile.DefaultAddress.PostalCode   = UpdateValue(BillingAddressPostalCode, customer.BillingProfile.DefaultAddress.PostalCode);
                    customer.BillingProfile.DefaultAddress.Region       = UpdateValue(BillingAddressRegion, customer.BillingProfile.DefaultAddress.Region);
                    customer.BillingProfile.DefaultAddress.State        = UpdateValue(BillingAddressState, customer.BillingProfile.DefaultAddress.State);
                    customer.BillingProfile.CompanyName = UpdateValue(Name, customer.BillingProfile.CompanyName);

                    validator = new AddressValidator(Partner);

                    if (validator.IsValid(customer.BillingProfile.DefaultAddress))
                    {
                        Partner.Customers[customerId].Profiles.Billing.Update(customer.BillingProfile);

                        WriteObject(new PSCustomer(customer));
                    }
                    else
                    {
                        throw new PSInvalidOperationException("The address specified was invalid. Please check the values and try again.");
                    }
                }
            }
            catch (PartnerException ex)
            {
                throw new PSPartnerException("An error was encountered when communicating with Partner Center.", ex);
            }
            finally
            {
                customer = null;
            }
        }
        public void CanPassValidTestnetAddress()
        {
            var addresses = new[]
            {
                "muLn6NV9aB9VLM7rJvh5i1wtUEXgDGNxW2"
            };
            var addressValidator = new AddressValidator(Network.TestNet);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
        public void CanPassValidMainetAddress()
        {
            var addresses = new[]
            {
                "19xM6HywehvSYfPvf3C8JVZPfE7zh1ziCD"
            };
            var addressValidator = new AddressValidator(Network.Main);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            BillingProfile       profile;
            IValidator <Address> validator;

            try
            {
                if (ShouldProcess("Updates the partner's billing profile"))
                {
                    profile = Partner.Profiles.BillingProfile.Get();

                    profile.Address.AddressLine1 = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                    profile.Address.AddressLine2 = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                    profile.Address.City         = UpdateValue(City, profile.Address.City);
                    profile.Address.PostalCode   = UpdateValue(PostalCode, profile.Address.PostalCode);
                    profile.Address.Region       = UpdateValue(Region, profile.Address.Region);
                    profile.Address.State        = UpdateValue(State, profile.Address.State);

                    try
                    {
                        validator = new AddressValidator(Partner);

                        if (!validator.IsValid(profile.Address))
                        {
                            throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                        }
                    }
                    catch (PartnerException ex)
                    {
                        throw new PSPartnerException("The specified address is invalid. Please verify the address and try again.", ex);
                    }

                    profile.PrimaryContact.Email       = UpdateValue(EmailAddress, profile.PrimaryContact.Email);
                    profile.PrimaryContact.FirstName   = UpdateValue(FirstName, profile.PrimaryContact.FirstName);
                    profile.PrimaryContact.LastName    = UpdateValue(LastName, profile.PrimaryContact.LastName);
                    profile.PrimaryContact.PhoneNumber = UpdateValue(PhoneNumber, profile.PrimaryContact.PhoneNumber);

                    profile.PurchaseOrderNumber = UpdateValue(PurchaseOrderNumber, profile.PurchaseOrderNumber);
                    profile.TaxId = UpdateValue(TaxId, profile.TaxId);

                    Partner.Profiles.BillingProfile.Update(profile);

                    WriteObject(new PSBillingProfile(profile));
                }
            }
            finally
            {
                profile   = null;
                validator = null;
            }
        }
        public void CanPassValidTestnetAddress()
        {
            var addresses = new[]
            {
                "muLn6NV9aB9VLM7rJvh5i1wtUEXgDGNxW2",
                "bchreg:qq79zqy00c02p6jxx4vavx9gpl78uq8f0qmadakpzx"
            };
            var addressValidator = new AddressValidator(Network.TestNet, BCash.Instance.Regtest);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
        public void CanPassValidMainNetAddress()
        {
            var addresses = new[]
            {
                "GQ6Btf3KmRz4VoMsEZi7WBdCYuY1XeXTrY",
                "AJcr6T2b5C8UcJusDHR18jESaqUm5jhRPo"
            };
            var addressValidator = new AddressValidator(NBitcoin.Altcoins.BGold.Instance.Mainnet);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
        public void CanPassValidMainetAddress()
        {
            var addresses = new[]
            {
                "19xM6HywehvSYfPvf3C8JVZPfE7zh1ziCD",
                "bitcoincash:qpykm9qwke5zj8je0sqqwu2tde6ej7lsvu2z4swqqj"
            };
            var addressValidator = new AddressValidator(Network.Main, BCash.Instance.Mainnet);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
        public void CanPassValidAddress()
        {
            var addresses = new[]
            {
                "mycEmS1rCNnrjzU2PVfC14bvhj8Kj8Uqio",
                "n2gGJpH3PuXBVn2o3ALiQjiNodcEJDRJHh"
            };
            var addressValidator = new AddressValidator(NBitcoin.Altcoins.BGold.Instance.Testnet);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            CustomerConverter    converter;
            Customer             customer;
            IValidator <Address> validator;
            string customerId;

            try
            {
                customerId = (InputObject == null) ? CustomerId : InputObject.CustomerId;

                if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.SetPartnerCustomerWhatIf, customerId)))
                {
                    if (InputObject == null && string.IsNullOrEmpty(CustomerId))
                    {
                        throw new PSInvalidOperationException(Resources.InvalidSetCustomerIdentifierException);
                    }

                    customer = Partner.Customers[customerId].Get();

                    converter = new CustomerConverter(this, customer);
                    converter.Convert();

                    validator = new AddressValidator(Partner);

                    if (validator.IsValid(customer.BillingProfile.DefaultAddress))
                    {
                        Partner.Customers[customerId].Profiles.Billing.Update(customer.BillingProfile);

                        WriteObject(new PSCustomer(customer));
                    }
                    else
                    {
                        throw new PSInvalidOperationException("The address specified was invalid. Please check the values and try again.");
                    }
                }
            }
            catch (PartnerException ex)
            {
                throw new PSPartnerException("An error was encountered when communicating with Partner Center.", ex);
            }
            finally
            {
                converter = null;
                customer  = null;
            }
        }
        public void DoNotPassBTCAddress()
        {
            PrepareNetworks.EnsureLiteCoinPrepared();


            var addresses = new[]
            {
                "LLgJTbzZMsRTCUF1NtvvL9SR1a4pVieW89",
                "Le6rZj8bLTbUATVhcZBxd3Z1u8b542C63T"
            };
            var addressValidator = new AddressValidator(NBitcoin.Litecoin.Networks.Mainnet);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            IValidator <Address> validator;
            LegalBusinessProfile profile;

            try
            {
                if (ShouldProcess(Resources.SetPartnerLegalProfileWhatIf))
                {
                    profile = Partner.Profiles.LegalBusinessProfile.Get();

                    profile.Address.AddressLine1   = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                    profile.Address.AddressLine2   = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                    profile.Address.City           = UpdateValue(City, profile.Address.City);
                    profile.Address.Country        = UpdateValue(Country, profile.Address.Country);
                    profile.Address.PostalCode     = UpdateValue(PostalCode, profile.Address.PostalCode);
                    profile.Address.Region         = UpdateValue(Region, profile.Address.Region);
                    profile.Address.State          = UpdateValue(State, profile.Address.State);
                    profile.CompanyApproverAddress = profile.Address;
                    profile.CompanyApproverEmail   = UpdateValue(EmailAddress, profile.CompanyApproverEmail);

                    try
                    {
                        validator = new AddressValidator(Partner);

                        if (!validator.IsValid(profile.Address))
                        {
                            throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                        }
                    }
                    catch (PartnerException ex)
                    {
                        throw new PSPartnerException("The specified address is invalid. Please verify the address and try again.", ex);
                    }

                    profile = Partner.Profiles.LegalBusinessProfile.Update(profile);

                    WriteObject(new PSLegalBusinessProfile(profile));
                }
            }
            finally
            {
                profile   = null;
                validator = null;
            }
        }
        public void PassTestNetLTCAddress()
        {
            PrepareNetworks.EnsureLiteCoinPrepared();


            var addresses = new[]
            {
                "mu5a17UQDh2hsRk9ZJzFkTfCbzZhMVBHY3",
                "mifUh8hTMomrQL1dyVykffhcsYAfExzdxa",
                "msiJHQf1BVXD6fuUyLn9D8mD6gMbPibiDV"
            };
            var addressValidator = new AddressValidator(NBitcoin.Litecoin.Networks.Testnet);

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
        public void PassMainNetLTCAddress()
        {
            PrepareNetworks.EnsureLiteCoinPrepared();


            var addresses = new[]
            {
                "13xWF5cWE1Byyvq8FiKUafTHTX4kx3MD7p",
                "1Q7Jmho4FixWBiTVcZ5aKXv4rTMMp6CjiD",
                "1LU4xEKf7SFnQ3GX8CDfDHvWkszaKrYRcD"
            };
            var addressValidator = new AddressValidator(NBitcoin.Litecoin.Networks.Mainnet);

            foreach (var address in addresses)
            {
                Assert.False(addressValidator.IsValid(address));
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            Customer             customer;
            IValidator <Address> validator;
            string customerId;

            customerId = (InputObject == null) ? CustomerId : InputObject.CustomerId;

            if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.SetPartnerCustomerWhatIf, customerId)))
            {
                if (InputObject == null && string.IsNullOrEmpty(CustomerId))
                {
                    throw new PSInvalidOperationException(Resources.InvalidSetCustomerIdentifierException);
                }

                customer = Partner.Customers[customerId].GetAsync().ConfigureAwait(false).GetAwaiter().GetResult();

                customer.BillingProfile.DefaultAddress.AddressLine1 = UpdateValue(BillingAddressLine1, customer.BillingProfile.DefaultAddress.AddressLine1);
                customer.BillingProfile.DefaultAddress.AddressLine2 = UpdateValue(BillingAddressLine2, customer.BillingProfile.DefaultAddress.AddressLine2);
                customer.BillingProfile.DefaultAddress.City         = UpdateValue(BillingAddressCity, customer.BillingProfile.DefaultAddress.City);
                customer.BillingProfile.DefaultAddress.Country      = UpdateValue(BillingAddressCountry, customer.BillingProfile.DefaultAddress.Country);
                customer.BillingProfile.DefaultAddress.PhoneNumber  = UpdateValue(BillingAddressPhoneNumber, customer.BillingProfile.DefaultAddress.PhoneNumber);
                customer.BillingProfile.DefaultAddress.PostalCode   = UpdateValue(BillingAddressPostalCode, customer.BillingProfile.DefaultAddress.PostalCode);
                customer.BillingProfile.DefaultAddress.Region       = UpdateValue(BillingAddressRegion, customer.BillingProfile.DefaultAddress.Region);
                customer.BillingProfile.DefaultAddress.State        = UpdateValue(BillingAddressState, customer.BillingProfile.DefaultAddress.State);
                customer.BillingProfile.CompanyName = UpdateValue(Name, customer.BillingProfile.CompanyName);
                customer.BillingProfile.Email       = UpdateValue(Email, customer.BillingProfile.Email);


                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(customer.BillingProfile.DefaultAddress, d => WriteDebug(d)))
                    {
                        throw new PartnerException("The address for the customer is not valid.");
                    }
                }

                Partner.Customers[customerId].Profiles.Billing.UpdateAsync(customer.BillingProfile).GetAwaiter().GetResult();

                WriteObject(new PSCustomer(customer));
            }
        }
        public void CanPassValidAddress()
        {
            PrepareNetworks.EnsureVertcoinPrepared();


            var addresses = new[]
            {
                "mu5a17UQDh2hsRk9ZJzFkTfCbzZhMVBHY3",
                "mifUh8hTMomrQL1dyVykffhcsYAfExzdxa",
                "msiJHQf1BVXD6fuUyLn9D8mD6gMbPibiDV",
                "LLgJTbzZMsRTCUF1NtvvL9SR1a4pVieW89",
                "Le6rZj8bLTbUATVhcZBxd3Z1u8b542C63T"
            };
            var addressValidator = new AddressValidator();

            foreach (var address in addresses)
            {
                Assert.True(addressValidator.IsValid(address));
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Executes the operations associated with the cmdlet.
        /// </summary>
        public override void ExecuteCmdlet()
        {
            BillingProfile       profile;
            IValidator <Address> validator;

            if (ShouldProcess("Updates the partner's billing profile"))
            {
                profile = Partner.Profiles.BillingProfile.GetAsync().GetAwaiter().GetResult();

                profile.Address.AddressLine1 = UpdateValue(AddressLine1, profile.Address.AddressLine1);
                profile.Address.AddressLine2 = UpdateValue(AddressLine2, profile.Address.AddressLine2);
                profile.Address.City         = UpdateValue(City, profile.Address.City);
                profile.Address.PostalCode   = UpdateValue(PostalCode, profile.Address.PostalCode);
                profile.Address.Region       = UpdateValue(Region, profile.Address.Region);
                profile.Address.State        = UpdateValue(State, profile.Address.State);

                profile.PrimaryContact.Email       = UpdateValue(EmailAddress, profile.PrimaryContact.Email);
                profile.PrimaryContact.FirstName   = UpdateValue(FirstName, profile.PrimaryContact.FirstName);
                profile.PrimaryContact.LastName    = UpdateValue(LastName, profile.PrimaryContact.LastName);
                profile.PrimaryContact.PhoneNumber = UpdateValue(PhoneNumber, profile.PrimaryContact.PhoneNumber);

                profile.PurchaseOrderNumber = UpdateValue(PurchaseOrderNumber, profile.PurchaseOrderNumber);
                profile.TaxId = UpdateValue(TaxId, profile.TaxId);


                if (!DisableValidation.ToBool())
                {
                    validator = new AddressValidator(Partner);

                    if (!validator.IsValid(profile.Address, d => WriteDebug(d)))
                    {
                        throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again.");
                    }
                }

                Partner.Profiles.BillingProfile.UpdateAsync(profile).GetAwaiter().GetResult();

                WriteObject(new PSBillingProfile(profile));
            }
        }