/// <summary>
        /// Create account This REST API reference describes how to create a customer account with a credit-card payment method, a bill-to contact, and an optional sold-to contact. Request and response field descriptions and sample code are provided. Use this method to optionally create a subscription, invoice for that subscription, and collect payment through the default payment method. The transaction is atomic; if any part fails for any reason, the entire transaction is rolled back.  This API call is CORS Enabled, so you can use client-side Javascript to invoke the call. For more information, visit the [Zuora CORS REST](https://knowledgecenter.zuora.com/DC_Developers/REST_API/A_REST_basics/G_CORS_REST) page.  ## Notes 1. The account is created in active status.   2. The request must provide either a **creditCard** structure or the **hpmCreditCardPaymentMethodId** field (but not both). The one provided becomes the default payment method for this account. If the credit card information is declined or can&#39;t be verified, then the account is not created. 3. Customer accounts created with this call are automatically be set to Auto Pay. 4. If either the **workEmail** or **personalEmail** are specified, then the account&#39;s email delivery preference is automatically set to &#x60;true&#x60;. (In that case, emails go to the **workEmail** address, if it exists, or else the **personalEmail**.) If neither field is specified, the email delivery preference is automatically set to &#x60;false&#x60;.  ## Defaults for customerAcceptanceDate and serviceActivationDate Default values for **customerAcceptanceDate** and **serviceActivationDate** are set as follows.  |        | serviceActivationDate(SA) specified          | serviceActivationDate (SA) NOT specified  | | ------------- |:-------------:| -----:| | customerAcceptanceDate (CA) specified      | SA uses value in the request call; CA uses value in the request call| CA uses value in the request call;SA uses CE as default | | customerAcceptanceDate (CA) NOT specified      | SA uses value in the request call; CA uses SA as default |   SA and CA use CE as default |
        /// </summary>
        /// <param name="request"></param>
        /// <param name="zuoraVersion">The minor version of the Zuora REST API. You only need to set this parameter if you use the __collect__ or __invoice__ fields. See [REST API Basics](https://knowledgecenter.zuora.com/DC_Developers/REST_API/A_REST_basics) for more information.</param>
        /// <returns>POSTAccountResponseType</returns>
        public POSTAccountResponseType POSTAccount(POSTAccountType request, string zuoraVersion)
        {
            // verify the required parameter 'request' is set
            if (request == null)
            {
                throw new ApiException(400, "Missing required parameter 'request' when calling POSTAccount");
            }


            var path = "/accounts";

            path = path.Replace("{format}", "json");

            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;

            if (zuoraVersion != null)
            {
                headerParams.Add("zuora-version", ApiClient.ParameterToString(zuoraVersion)); // header parameter
            }
            postBody = ApiClient.Serialize(request);                                          // http body (model) parameter

            // authentication setting, if any
            String[] authSettings = new String[] {  };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling POSTAccount: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling POSTAccount: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((POSTAccountResponseType)ApiClient.Deserialize(response.Content, typeof(POSTAccountResponseType), response.Headers));
        }
        /**
         * Method for creating a Zuora Account and Subscription with the given product
         *
         * prodId: The ID of the product to be added to the new subscription
         */
        public POSTAccountResponseType createAccountAndSub(String prodId)
        {
            //Initialize the Account container
            POSTAccountType zAcc = new POSTAccountType();

            //Initialize the Bill-To Contact container
            POSTAccountTypeBillToContact bill2Contact = new POSTAccountTypeBillToContact();

            //Populate the Bill-To Contact with all required fields
            bill2Contact.FirstName = "John";
            bill2Contact.LastName  = "Doe";
            bill2Contact.Country   = "USA";
            bill2Contact.State     = "Georgia";

            //Initialize the Sold-To Contact container
            POSTAccountTypeSoldToContact sold2Contact = new POSTAccountTypeSoldToContact();

            //Populate the Sold-To Contact with all required fields
            sold2Contact.FirstName = "John";
            sold2Contact.LastName  = "Doe";
            sold2Contact.Country   = "USA";
            sold2Contact.State     = "Georgia";

            //Initialize the Credit Card container
            POSTAccountTypeCreditCard creditCard = new POSTAccountTypeCreditCard();

            //Initialize the Card-Holder Information container
            POSTAccountTypeCreditCardCardHolderInfo info = new POSTAccountTypeCreditCardCardHolderInfo();

            //Populate the Card-Holder Information with all required fields
            info.CardHolderName = "John Doe";
            info.AddressLine1   = "3525 Piedmont Road";
            info.City           = "Atlanta";
            info.City           = "USA";
            info.State          = "GA";
            info.ZipCode        = "30305";

            //Set the Card-Holder Information on the Credit Card container
            creditCard.CardHolderInfo = info;

            //Populate the Credit Card with all required fields
            creditCard.CardType        = "Visa";
            creditCard.CardNumber      = "4111111111111111";
            creditCard.ExpirationMonth = "10";
            creditCard.ExpirationYear  = "2020";
            creditCard.SecurityCode    = "111";

            //Initialize the Subscription container
            POSTAccountTypeSubscription subscription = new POSTAccountTypeSubscription();

            //Initialize the Rate Plan container list (Must use a list as the subscription can have multiple rate plans)
            List <POSTSrpCreateType> ratePlanList = new List <POSTSrpCreateType>();

            //Initialize the individual Rate Plan container
            POSTSrpCreateType ratePlan = new POSTSrpCreateType();

            //Populate the Rate Plan container with the required field
            ratePlan.ProductRatePlanId = prodId;

            //Add the individual Rate Plan container to the list
            ratePlanList.Add(ratePlan);

            //Add the list of Rate Plans to the Subscription container
            subscription.SubscribeToRatePlans = ratePlanList;

            //Populate the subscription with all other required fields
            subscription.TermType              = "TERMED";
            subscription.AutoRenew             = false;
            subscription.InitialTerm           = 12;
            subscription.RenewalTerm           = 12;
            subscription.ContractEffectiveDate = new DateTime(2016, 10, 17);

            //Add the Bill-To Contact container to the Account
            zAcc.BillToContact = bill2Contact;

            //Add the Sold-To Contact container to the Account
            zAcc.SoldToContact = sold2Contact;

            //Add the Credit Card container to the Account
            zAcc.CreditCard = creditCard;

            //Add the Subscription container to the Account
            zAcc.Subscription = subscription;

            //Populate all other required fields on the Account
            zAcc.Name     = "Test Account";
            zAcc.Currency = "USD";

            //Submit the API call by passing in the required Account container and the API version
            return(accountsApi.POSTAccount(zAcc, "196.0"));
        }