/// <summary>
        /// Add a customer charge for a customer
        /// </summary>
        /// <param name="customCharge">A CustomerChargePost object with the customer charge and customer code</param>
        /// <returns>A Customer object with the reflected custom charge</returns>
        public static Customer AddCustomCharge(CustomChargePost customCharge)
        {
            Customers customers = new Customers();
            Customer editCustomer = new Customer();

            try
            {
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/set-item-quantity/productCode/{0}/code/{1}/itemCode/{2}", _ProductCode, customCharge.CustomerCode, customCharge.ItemCode);
                string postParams = string.Format(
                  "chargeCode={0}" +
                  "&quantity={1}" +
                  "&eachAmount={2}" +
                  "&description={3}",
                  HttpUtility.UrlEncode(customCharge.ChargeCode),
                  HttpUtility.UrlEncode(customCharge.Quantity.ToString()),
                  HttpUtility.UrlEncode(customCharge.EachAmount.ToString()),
                  HttpUtility.UrlEncode(customCharge.Description));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    editCustomer = customers.CustomerList[0];
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return editCustomer;
        }
        /// <summary>
        /// Update a customer's subscription
        /// </summary>
        /// <param name="customer">A CustomerPost object with the subscription details to update</param>
        /// <returns>A Customer object with the applied changes</returns>
        public static Customer UpdateSubscription(CustomerPost customer)
        {
            Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit-subscription/productCode/{0}/code/{1}", _ProductCode, customer.Code);

                //note: expiration date must be in MM/YYYY format
                StringBuilder postParamsSB = new StringBuilder();
                postParamsSB.Append(string.Format("planCode={0}", HttpUtility.UrlEncode(customer.PlanCode.ToString().ToUpper())));
                postParamsSB.Append(string.Format("&ccFirstName={0}", HttpUtility.UrlEncode(customer.CCFirstName)));
                postParamsSB.Append(string.Format("&ccLastName={0}", HttpUtility.UrlEncode(customer.CCLastName)));

                if (!string.IsNullOrEmpty(customer.CCNumber))
                {
                    postParamsSB.Append(string.Format("&ccNumber={0}", HttpUtility.UrlEncode(customer.CCNumber)));
                }

                postParamsSB.Append(string.Format("&ccExpiration={0}", HttpUtility.UrlEncode(string.Format("{0}/{1}", formatMonth(customer.CCExpMonth), customer.CCExpYear))));

                if (!string.IsNullOrEmpty(customer.CCCardCode))
                {
                    postParamsSB.Append(string.Format("&ccCardCode={0}", HttpUtility.UrlEncode(customer.CCCardCode)));
                }

                postParamsSB.Append(string.Format("&ccZip={0}", HttpUtility.UrlEncode(customer.CCZip)));

                string result = postRequest(urlBase, urlPath, postParamsSB.ToString());
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
        }
        /// <summary>
        /// Update a customer's subscription plan
        /// </summary>
        /// <param name="customerCode">The customer's code of the customer to be updated</param>
        /// <param name="newPlan">The plan to set the customer to</param>
        /// <returns>A Customer object with the updated changes applied</returns>
        public static Customer UpdateSubscriptionPlanOnly(string customerCode, PlanCodeEnum newPlan)
        {
            Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit-subscription/productCode/{0}/code/{1}", _ProductCode, customerCode);

                //note: expiration date must be in MM/YYYY format
                string postParams = string.Format("planCode={0}", HttpUtility.UrlEncode(newPlan.ToString().ToUpper()));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
        }
        /// <summary>
        /// Update a customer and their subscription
        /// </summary>
        /// <param name="customer">A CustomerPost object that represents the changes to be updated</param>
        /// <returns>An updated Customer object with the changes applied</returns>
        public static Customer UpdateCustomerAndSubscription(CustomerPost customer)
        {
            Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit/productCode/{0}/code/{1}", _ProductCode, customer.Code);
                string postParams = string.Format(
                    "firstName={0}" +
                    "&lastName={1}" +
                    "&email={2}" +
                    "&company={3}" +
                    "&notes={4}" +
                    "&subscription[planCode]={5}" +
                    "&subscription[ccFirstName]={6}" +
                    "&subscription[ccLastName]={7}" +
                    "&subscription[ccNumber]={8}" +
                    "&subscription[ccExpiration]={9}" +
                    "&subscription[ccCardCode]={10}" +
                    "&subscription[ccZip]={11}",
                    HttpUtility.UrlEncode(customer.FirstName),
                    HttpUtility.UrlEncode(customer.LastName),
                    HttpUtility.UrlEncode(customer.Email),
                    HttpUtility.UrlEncode(customer.Company),
                    HttpUtility.UrlEncode(customer.Notes),
                    HttpUtility.UrlEncode(customer.PlanCode.ToString().ToUpper()),
                    HttpUtility.UrlEncode(customer.CCFirstName),
                    HttpUtility.UrlEncode(customer.CCLastName),
                    HttpUtility.UrlEncode(customer.CCNumber),
                    HttpUtility.UrlEncode(string.Format("{0}/{1}", formatMonth(customer.CCExpMonth), customer.CCExpYear)),
                    HttpUtility.UrlEncode(customer.CCCardCode),
                    HttpUtility.UrlEncode(customer.CCZip));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
        }
        /// <summary>
        /// Update a customer
        /// </summary>
        /// <param name="customer">A CustomerPost object that represents the changes to be updated</param>
        /// <returns>An updated Customer object with the changes applied</returns>
        public static Customer UpdateCustomer(CustomerPost customer)
        {
            Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit-customer/productCode/{0}/code/{1}", _ProductCode, customer.Code);
                string postParams = string.Format(
                    "firstName={0}" +
                    "&lastName={1}" +
                    "&email={2}" +
                    "&company={3}",
                    "&notes={4}",
                    HttpUtility.UrlEncode(customer.FirstName),
                    HttpUtility.UrlEncode(customer.LastName),
                    HttpUtility.UrlEncode(customer.Email),
                    HttpUtility.UrlEncode(customer.Company),
                    HttpUtility.UrlEncode(customer.Notes));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
        }
        /// <summary>
        /// Set an item count to a specific quantity
        /// </summary>
        /// <param name="customerCode">The customer's code of the customer that will be updated </param>
        /// <param name="itemCode">The code of the item that will be updated</param>
        /// <param name="quantityToSet">The quantity to set for the item</param>
        /// <returns>A Customer object reflecting the updated item and quantity count</returns>
        public static Customer SetItem(string customerCode, ProductItemCode itemCode, int quantityToSet)
        {
            Customers customers = new Customers();
            Customer editCustomer = new Customer();

            try
            {
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/set-item-quantity/productCode/{0}/code/{1}/itemCode/{2}", _ProductCode, customerCode, itemCode.ToString());
                string postParams = string.Format("quantity={0}", HttpUtility.UrlEncode(quantityToSet.ToString()));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    editCustomer = customers.CustomerList[0];
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return editCustomer;
        }
        /// <summary>
        /// Get a particular customer based on a passed in customer code and your product code
        /// </summary>
        /// <param name="customerCode">A string representing a customer's code in CG </param>
        /// <returns>A associated Customer object for the passed in customer code</returns>
        public static Customer GetCustomer(string customerCode)
        {
            Customers customers = new Customers();
            Customer customer = new Customer();

            string urlBase = "https://cheddargetter.com/xml";
            string urlPath = string.Format("/customers/get/productCode/{0}/code/{1}", _ProductCode, customerCode);
            try
            {
                string result = getRequest(urlBase, urlPath);

                XDocument customersXML = XDocument.Parse(result);

                customers = getCustomerList(customersXML);

                if (customers.CustomerList.Count > 0)
                {
                    customer = customers.CustomerList[0];
                }
            }
            catch (WebException ex)
            {
                HttpWebResponse response = (HttpWebResponse)ex.Response;
                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    return null;
                }
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return customer;
        }
        /// <summary>
        /// Cancel a customer's subscription
        /// </summary>
        /// <param name="customerCode">The customer code of the customer to cancel</param>
        /// <returns>A bool representing the success of the cancel</returns>
        public static bool CancelSubscription(string customerCode)
        {
            Customers customers = new Customers();
            Customer editCustomer = new Customer();
            bool canceled = false;

            try
            {
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/cancel/productCode/{0}/code/{1}", _ProductCode, customerCode);

                string result = getRequest(urlBase, urlPath);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    editCustomer = customers.CustomerList[0];
                }

                canceled = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return canceled;
        }