Exemple #1
0
        public Warehouse.Customer[] getCustomers(int page=1)
        {
            if (page <= 0) page = 1;
            List<Warehouse.Customer> customerList = new List<Warehouse.Customer>();
            CustomerAccount customers = new CustomerAccount();
            CustomerAccountCollection results = (CustomerAccountCollection) MZ.Request(customers, typeof(CustomerAccountCollection));
            if (results.Items != null) {
                foreach (CustomerAccount customer in results.Items) {
                    if (customer.AuditInfo == null) continue;
                    if (Utility.getDateTime(customer.AuditInfo.CreateDate) < new DateTime(2015, 5, 28)) continue;

                    Warehouse.Customer c = new Warehouse.Customer();
                    c.FirstName = customer.FirstName;
                    c.LastName = customer.LastName;
                    if (customer.Contacts != null && customer.Contacts.Count > 0) {
                        CustomerContact contact = customer.Contacts[0];
                        c.Address1 = contact.Address.Address1;
                        c.Address2 = contact.Address.Address2;
                        c.City = contact.Address.CityOrTown;
                        c.State = contact.Address.StateOrProvince;
                        c.ZipCode = contact.Address.PostalOrZipCode;
                        c.Country = contact.Address.CountryCode;
                        c.Phone = contact.PhoneNumbers.Home;
                    }
                    c.Email = customer.EmailAddress;
                    if (string.IsNullOrWhiteSpace(c.Email)) continue;

                    if (! string.IsNullOrWhiteSpace(c.Email)) {
                        if (customersAdded.Contains(c.Email)) continue;
                        customersAdded.Add(c.Email);
                    }

                    customerList.Add(c);
                }
            }

            return customerList.ToArray();
        }
Exemple #2
0
        /// <summary>
        /// Generate Customer Account
        /// </summary>
        /// <param name="taxExempt"></param>
        /// <param name="taxId"></param>
        /// <returns></returns>
        public static CustomerAccountAndAuthInfo GenerateCustomerAccountAndAuthInfoRandom(bool taxExempt = false, string taxId = null)
        {
            var firstname = Generator.RandomString(8, RandomCharacterGroup.AlphaOnly);
            var lastname = Generator.RandomString(8, RandomCharacterGroup.AlphaOnly);
            var username = firstname + lastname; // or use Generator.RandomString(12, RandomCharacterGroup.AlphaOnly);
            var customer = new CustomerAccount()
            {
                AcceptsMarketing = false,
                CompanyOrOrganization = "Volusion",
                Contacts = new List<CustomerContact>() { GenerateCustomerContact(0, GenerateAddressRandom(addressType: AddressType.Residential), username + "@mozu.com", firstname, "", lastname) },
                EmailAddress = username + "@mozu.com",//Generator.RandomEmailAddress(),
                FirstName = firstname, // or use Generator.RandomString(10, RandomCharacterGroup.AlphaOnly),
                LastName = lastname, // or use Generator.RandomString(10, RandomCharacterGroup.AlphaOnly),
                UserName = username,
                TaxExempt = taxExempt,
                TaxId = taxId,
                LocaleCode = Constant.LocaleCode,
                Notes = new List<CustomerNote>() { GenerateCustomerNote() }
            };

            var customerAccountAndAuthInfo = new CustomerAccountAndAuthInfo
            {
                Account = customer,
                Password = Constant.Password
            };

            return customerAccountAndAuthInfo;
        }
Exemple #3
0
        /// <summary>
        /// Generate Customer Account
        /// </summary>
        /// <param name="customerAccount"></param>
        /// <returns></returns>
        public static CustomerAccountAndAuthInfo GenerateCustomerAccountAndAuthInfo(CustomerAccount customerAccount)
        {
            var customerAccountAndAuthInfo = new CustomerAccountAndAuthInfo
            {
                Account = customerAccount,
                Password = Constant.Password
            };

            return customerAccountAndAuthInfo;
        }
Exemple #4
0
 public static CustomerAccountAndAuthInfo GenerateCustomerAccountAndAuthInfo(CustomerAccount customerAccount, bool isImport = false, string passwd = Constant.Password)
 {
     return new CustomerAccountAndAuthInfo()
     {
         Account = customerAccount ?? GenerateCustomerAccountRandom(),
         Password = passwd,
         IsImport = isImport
     };
 }
 public void TestDownload()
 {
     CustomerAccount customer = new CustomerAccount();
     object results = Mozu.Mozu.Request(customer);
     Assert.IsNotNull(results);
 }
Exemple #6
0
 private void downloadCustomers()
 {
     CustomerAccount customers = new CustomerAccount();
     CustomerAccountCollection results = (CustomerAccountCollection) MZ.Request(customers, typeof(CustomerAccountCollection));
     if (results.Items != null) {
         foreach (CustomerAccount customer in results.Items) {
             //Warehouse.Warwick.Customer c = new Warehouse.Warwick.Customer();
             Warehouse.Customer c = new Warehouse.Customer();
             //c.customer.system = _system;
             c.FirstName = c.FirstName;
             c.MiddleName = c.MiddleName;
             c.LastName = c.LastName;
             c.Address1 = c.Address1;
             c.Address2 = c.Address2;
             c.City = c.City;
             c.State = c.State;
             c.ZipCode = c.ZipCode;
             c.Country = c.Country;
             c.Phone = c.Phone;
             c.PhoneExtension = c.PhoneExtension;
             c.Email = c.Email;
             c.Fax = c.Fax;
             c.Save();
         }
     }
 }