# coding: utf-8

"""
    Zuora API Reference

    REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).

    The version of the OpenAPI document: 2024-05-20
    Contact: docs@zuora.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import date
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from zuora_sdk.models.account_e_invoice_profile import AccountEInvoiceProfile
from zuora_sdk.models.account_object_ns_fields_customer_type_ns import AccountObjectNSFieldsCustomerTypeNS
from zuora_sdk.models.account_object_ns_fields_syncto_net_suite_ns import AccountObjectNSFieldsSynctoNetSuiteNS
from zuora_sdk.models.create_account_contact import CreateAccountContact
from zuora_sdk.models.create_account_credit_card import CreateAccountCreditCard
from zuora_sdk.models.create_account_payment_method import CreateAccountPaymentMethod
from zuora_sdk.models.create_account_subscription import CreateAccountSubscription
from zuora_sdk.models.tax_info import TaxInfo
from typing import Optional, Set
from typing_extensions import Self

class CreateAccountRequest(BaseModel):
    """
    CreateAccountRequest
    """ # noqa: E501
    # avoid validation
    def __init__(self, **kwargs):
        # Directly assign values without validation using `construct()`
        model = self.construct(**kwargs)
        self.__dict__.update(model.__dict__)

        _dict_all = convert_snake_dict_to_camel(kwargs, self.model_fields, self.__properties)

        _dict = self.to_alias_dict(_dict_all)
        for field_name, field_info in self.model_fields.items():
            alias = field_info.alias or field_name
            if alias in _dict:
                self.__dict__[field_name] = _dict.get(alias)
        self.update_additional_properties(self, _dict_all)
        pass

    def __setattr__(self, name, value):
        # Override setattr to bypass validation when setting attributes
        object.__setattr__(self, name, value)

    class__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Value of the Class field for the corresponding customer account in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="Class__NS")
    customer_type__ns: Optional[StrictStr] = Field(default=None, alias="CustomerType__NS")
    department__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Value of the Department field for the corresponding customer account in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="Department__NS")
    integration_id__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="ID of the corresponding object in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="IntegrationId__NS")
    integration_status__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Status of the account's synchronization with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="IntegrationStatus__NS")
    location__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Value of the Location field for the corresponding customer account in NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="Location__NS")
    subsidiary__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Value of the Subsidiary field for the corresponding customer account in NetSuite. The Subsidiary field is required if you use NetSuite OneWorld. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="Subsidiary__NS")
    sync_date__ns: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Date when the account was sychronized with NetSuite. Only available if you have installed the [Zuora Connector for NetSuite](https://www.zuora.com/connect/app/?appId=265). ", alias="SyncDate__NS")
    syncto_net_suite__ns: Optional[StrictStr] = Field(default=None, alias="SynctoNetSuite__NS")
    account_number: Optional[StrictStr] = Field(default=None, description="A unique account number, up to 50 characters that do not begin with the default account number prefix.  If no account number is specified, one is generated. ", alias="accountNumber")
    additional_email_addresses: Optional[List[StrictStr]] = Field(default=None, description="A list of additional email addresses to receive email notifications. Use commas to separate email addresses. ", alias="additionalEmailAddresses")
    application_order: Optional[List[StrictStr]] = Field(default=None, description="The priority order to apply credit memos and/or unapplied payments to an invoice. Possible item values are: `CreditMemo`, `UnappliedPayment`.  **Note:**   - This field is valid only if the `applyCredit` field is set to `true`.   - If no value is specified for this field, the default priority order is used, [\"CreditMemo\", \"UnappliedPayment\"], to apply credit memos first and then apply unapplied payments.   - If only one item is specified, only the items of the spedified type are applied to invoices. For example, if the value is `[\"CreditMemo\"]`, only credit memos are used to apply to invoices. ", alias="applicationOrder")
    apply_credit: Optional[StrictBool] = Field(default=None, description="Whether to automatically apply credit memos or unapplied payments, or both to an invoice.  If the value is `true`, the credit memo or unapplied payment, or both will be automatically applied to the invoice. If no value is specified or the value is `false`, no action is taken.  **Note:** This field is only available if you have [Invoice Settlement](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement) enabled. The Invoice Settlement feature is generally available as of Zuora Billing Release 296 (March 2021). This feature includes Unapplied Payments, Credit and Debit Memo, and Invoice Item Settlement. If you want to enable Invoice Settlement, see [Invoice Settlement Enablement and Checklist Guide](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement/Invoice_Settlement_Migration_Checklist_and_Guide) for more information. ", alias="applyCredit")
    apply_credit_balance: Optional[StrictBool] = Field(default=None, description="Applies a credit balance to an invoice.  If the value is `true`, the credit balance is applied to the invoice. If the value is `false`, no action is taken.  Prerequisite: `invoice` must be `true`.  To view the credit balance adjustment, retrieve the details of the invoice using the Get Invoices method.   **Note:**    - If you are using the field `invoiceCollect` rather than the field `invoice`, the `invoiceCollect` value must be `true`.   - This field is deprecated if you have the Invoice Settlement feature enabled.  ", alias="applyCreditBalance")
    auto_pay: Optional[StrictBool] = Field(default=None, description="Whether future payments are to be automatically billed when they are due.   - If this field is set to `true`, you must specify either the `creditCard` field or the `hpmCreditCardPaymentMethodId` field, but not both. - If this field is set to `false`, you can specify neither the `creditCard` field nor the `hpmCreditCardPaymentMethodId` field. ", alias="autoPay")
    batch: Optional[StrictStr] = Field(default=None, description="The alias name given to a batch. A string of 50 characters or less. ")
    bill_cycle_day: Optional[StrictInt] = Field(default=None, description="The account's bill cycle day (BCD), when bill runs generate invoices for the account.  Specify any day of the month (1-31, where 31 = end-of-month), or 0 for auto-set. Required if no subscription will be created.  Optional if a subscription is created and defaults to the day-of-the-month of the subscription's `contractEffectiveDate`. ", alias="billCycleDay")
    bill_to_contact: CreateAccountContact = Field(alias="billToContact")
    collect: Optional[StrictBool] = Field(default=None, description="Collects an automatic payment for a subscription. The collection generated in this operation is only for this subscription, not for the entire customer account. If the value is `true`, the automatic payment is collected. If the value is `false`, no action is taken. Prerequisite: The `invoice` or `runBilling` field must be `true`.  **Note**: This field is only available if you set the `zuora-version` request header to `196.0` or later. ")
    communication_profile_id: Optional[StrictStr] = Field(default=None, description="The ID of the communication profile that this account is linked to.  You can provide either or both of the `communicationProfileId` and `profileNumber` fields.  If both are provided, the request will fail if they do not refer to the same communication profile. ", alias="communicationProfileId")
    credit_card: Optional[CreateAccountCreditCard] = Field(default=None, alias="creditCard")
    credit_memo_reason_code: Optional[StrictStr] = Field(default=None, description="A code identifying the reason for the credit memo transaction that is generated by the request. The value must be an existing reason code. If you do not pass the field or pass the field with empty value, Zuora uses the default reason code.", alias="creditMemoReasonCode")
    credit_memo_template_id: Optional[StrictStr] = Field(default=None, description="**Note:** This field is only available if you have [Invoice Settlement](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement) enabled. The Invoice Settlement feature is generally available as of Zuora Billing Release 296 (March 2021). This feature includes Unapplied Payments, Credit and Debit Memo, and Invoice Item Settlement. If you want to enable Invoice Settlement, see [Invoice Settlement Enablement and Checklist Guide](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement/Invoice_Settlement_Migration_Checklist_and_Guide) for more information.  The unique ID of the credit memo template, configured in **Billing Settings** > **Manage Billing Document Configuration** through the Zuora UI. For example, 2c92c08a6246fdf101626b1b3fe0144b. ", alias="creditMemoTemplateId")
    crm_id: Optional[StrictStr] = Field(default=None, description="CRM account ID for the account, up to 100 characters. ", alias="crmId")
    currency: StrictStr = Field(description="A currency as defined in Billing Settings in the Zuora UI.  For payment method authorization, if the `paymentMethod` > `currencyCode` field is specified, `currencyCode` is used. Otherwise, this `currency` field is used for payment method authorization. If no currency is specified for the account, the default currency of the account is then used. ")
    debit_memo_template_id: Optional[StrictStr] = Field(default=None, description="**Note:** This field is only available if you have [Invoice Settlement](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement) enabled. The Invoice Settlement feature is generally available as of Zuora Billing Release 296 (March 2021). This feature includes Unapplied Payments, Credit and Debit Memo, and Invoice Item Settlement. If you want to enable Invoice Settlement, see [Invoice Settlement Enablement and Checklist Guide](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement/Invoice_Settlement_Migration_Checklist_and_Guide) for more information.  The unique ID of the debit memo template, configured in **Billing Settings** > **Manage Billing Document Configuration** through the Zuora UI. For example, 2c92c08d62470a8501626b19d24f19e2. ", alias="debitMemoTemplateId")
    document_date: Optional[date] = Field(default=None, description="The date of the billing document, in `yyyy-mm-dd` format. It represents the invoice date for invoices, credit memo date for credit memos, and debit memo date for debit memos.  - If this field is specified, the specified date is used as the billing document date.  - If this field is not specified, the date specified in the `targetDate` is used as the billing document date. ", alias="documentDate")
    hpm_credit_card_payment_method_id: Optional[StrictStr] = Field(default=None, description="The ID of the payment method associated with this account. The payment method specified for this field will be set as the default payment method of the account.  If the `autoPay` field is set to `true`, you must provide the credit card payment method ID for either this field or the `creditCard` field, but not both.  For the Credit Card Reference Transaction payment method, you can specify the payment method ID in this field or use the `paymentMethod` field to create a CC Reference Transaction payment method for an account. ", alias="hpmCreditCardPaymentMethodId")
    invoice: Optional[StrictBool] = Field(default=None, description="**Note:** This field has been replaced by the `runBilling` field. The `invoice` field is only available for backward compatibility.  Creates an invoice for a subscription. The invoice generated in this operation is only for this subscription, not for the entire customer account.  If the value is `true`, an invoice is created. If the value is `false`, no action is taken.  **Note**: This field is only available if you set the `zuora-version` request header to `196.0` or `207.0`. ")
    invoice_collect: Optional[StrictBool] = Field(default=None, description="This field has been replaced by the `invoice` field and the `collect` field. `invoiceCollect` is available only for backward compatibility. If this field is set to `true`, and a subscription is created, an invoice is generated at account creation time and payment is immediately collected using the account's default payment method. This field is only available if you set the `zuora-version` request header to `186.0`, `187.0`, `188.0`, or `189.0`. The default field value is `true`. ", alias="invoiceCollect")
    invoice_delivery_prefs_email: Optional[StrictBool] = Field(default=False, description="Whether the customer wants to receive invoices through email.  ", alias="invoiceDeliveryPrefsEmail")
    invoice_delivery_prefs_print: Optional[StrictBool] = Field(default=False, description="Whether the customer wants to receive printed invoices, such as through postal mail. ", alias="invoiceDeliveryPrefsPrint")
    invoice_target_date: Optional[date] = Field(default=None, description="**Note:** This field has been replaced by the `targetDate` field. The `invoiceTargetDate` field is only available for backward compatibility.     Date through which to calculate charges if an invoice is generated, as yyyy-mm-dd. Default is current date.   This field is in REST API minor version control. To use this field in the method, you can set the `zuora-version` parameter to the minor version number in the request header. Supported minor versions are `207.0` and earlier.  ", alias="invoiceTargetDate")
    invoice_template_id: Optional[StrictStr] = Field(default=None, description="Invoice template ID, configured in Billing Settings in the Zuora UI. ", alias="invoiceTemplateId")
    name: StrictStr = Field(description="Account name, up to 255 characters. ")
    notes: Optional[StrictStr] = Field(default=None, description="A string of up to 65,535 characters.")
    parent_id: Optional[StrictStr] = Field(default=None, description="Identifier of the parent customer account for this Account object. The length is 32 characters. Use this field if you have <a href=\"https://knowledgecenter.zuora.com/Billing/Subscriptions/Customer_Accounts/A_Customer_Account_Introduction#Customer_Hierarchy\" target=\"_blank\">Customer Hierarchy</a> enabled.", alias="parentId")
    partner_account: Optional[StrictBool] = Field(default=None, description="Whether the customer account is a partner, distributor, or reseller.  You can set this field to `true` if you have business with distributors or resellers, or operating in B2B model to manage numerous subscriptions through concurrent API requests. After this field is set to `true`, the calculation of account metrics is performed asynchronously during operations such as subscription creation, order changes, invoice generation, and payments.    **Note**: This field is available only if you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Manage_customer_accounts/AAA_Overview_of_customer_accounts/Reseller_Account\" target=\"_blank\">Reseller Account</a> feature enabled. ", alias="partnerAccount")
    payment_gateway: Optional[StrictStr] = Field(default=None, description="The name of the payment gateway instance. If null or left unassigned, the Account will use the Default Gateway. ", alias="paymentGateway")
    payment_method: Optional[CreateAccountPaymentMethod] = Field(default=None, alias="paymentMethod")
    payment_term: Optional[StrictStr] = Field(default=None, description="Payment terms for this account. Possible values are: `Due Upon Receipt`, `Net 30`, `Net 60`, `Net 90`.  **Note**: If you want to specify a payment term when creating a new account, you must set a value in this field. If you do not set a value in this field, Zuora will use `Due Upon Receipt` as the value instead of the default value set in **Billing Settings** > **Payment Terms** from Zuora UI. ", alias="paymentTerm")
    profile_number: Optional[StrictStr] = Field(default=None, description="The number of the communication profile that this account is linked to.  You can provide either or both of the `communicationProfileId` and `profileNumber` fields.  If both are provided, the request will fail if they do not refer to the same communication profile. ", alias="profileNumber")
    roll_up_usage: Optional[StrictBool] = Field(default=None, description="Whether roll up the usage of the account to its parent account ", alias="rollUpUsage")
    run_billing: Optional[StrictBool] = Field(default=None, description="Creates an invoice for a subscription. If you have the Invoice Settlement feature enabled, a credit memo might also be created based on the [invoice and credit memo generation rule](https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/Invoice_Settlement/B_Credit_and_Debit_Memos/Rules_for_generating_invoices_and_credit_memos).  The billing documents generated in this operation is only for this subscription, not for the entire customer account. Possible values: - `true`: An invoice is created. If you have the Invoice Settlement feature enabled, a credit memo might also be created. - `false`: No invoice is created. **Note:** This field is in Zuora REST API version control. Supported minor versions are `211.0` or later. To use this field in the method, you must set the `zuora-version` parameter to the minor version number in the request header. ", alias="runBilling")
    sales_rep: Optional[StrictStr] = Field(default=None, description="The name of the sales representative associated with this account, if applicable. Maximum of 50 characters.", alias="salesRep")
    sequence_set_id: Optional[StrictStr] = Field(default=None, description="The ID of the billing document sequence set to assign to the customer account.   The billing documents to generate for this account will adopt the prefix and starting document number configured in the sequence set.  If a customer account has no assigned billing document sequence set, billing documents generated for this account adopt the prefix and starting document number from the default sequence set. ", alias="sequenceSetId")
    ship_to_contact: Optional[CreateAccountContact] = Field(default=None, alias="shipToContact")
    ship_to_same_as_bill_to: Optional[StrictBool] = Field(default=None, description="Whether the ship-to contact and bill-to contact are the same entity.   The created account has the same bill-to contact and ship-to contact entity only when all the following conditions are met in the request body:  - This field is set to `true`.  - A bill-to contact is specified. - No ship-to contact is specified. ", alias="shipToSameAsBillTo")
    sold_to_contact: Optional[CreateAccountContact] = Field(default=None, alias="soldToContact")
    sold_to_same_as_bill_to: Optional[StrictBool] = Field(default=None, description="Whether the sold-to contact and bill-to contact are the same entity.   The created account has the same bill-to contact and sold-to contact entity only when all the following conditions are met in the request body:  - This field is set to `true`.  - A bill-to contact is specified. - No sold-to contact is specified. ", alias="soldToSameAsBillTo")
    subscription: Optional[CreateAccountSubscription] = None
    tagging: Optional[StrictStr] = None
    target_date: Optional[date] = Field(default=None, description="Date through which to calculate charges if an invoice or a credit memo is generated, as yyyy-mm-dd. Default is current date.  **Note:** The credit memo is only available only if you have the Invoice Settlement feature enabled.  This field is in Zuora REST API version control. Supported minor versions are `211.0` and later. To use this field in the method, you must set the  `zuora-version` parameter to the minor version number in the request header. ", alias="targetDate")
    tax_info: Optional[TaxInfo] = Field(default=None, alias="taxInfo")
    communication_profile_name: Optional[StrictStr] = Field(default=None, description="communicationProfileName ", alias="communicationProfileName")
    payment_gateway_number: Optional[StrictStr] = Field(default=None, description="paymentGatewayNumber ", alias="paymentGatewayNumber")
    payment_gateway_name: Optional[StrictStr] = Field(default=None, description="paymentGatewayName ", alias="paymentGatewayName")
    organization_id: Optional[StrictStr] = Field(default=None, description="organizationId ", alias="organizationId")
    organization_name: Optional[StrictStr] = Field(default=None, description="organizationName ", alias="organizationName")
    gateway_id: Optional[StrictStr] = Field(default=None, description="gatewayId ", alias="gatewayId")
    payment_method_id: Optional[StrictStr] = Field(default=None, description="paymentMethodId ", alias="paymentMethodId")
    parent_account_number: Optional[StrictStr] = Field(default=None, description="parentAccountNumber ", alias="parentAccountNumber")
    summary_statement_template_id: Optional[StrictStr] = Field(default=None, description="summaryStatementTemplateId ", alias="summaryStatementTemplateId")
    sequence_set_name: Optional[StrictStr] = Field(default=None, description="sequenceSetName ", alias="sequenceSetName")
    einvoice_profile: Optional[AccountEInvoiceProfile] = Field(default=None, alias="einvoiceProfile")
    organization_label: Optional[StrictStr] = Field(default=None, alias="organizationLabel")
    purchase_order_number: Optional[StrictStr] = Field(default=None, description="The purchase order number provided by your customer for services, products, or both purchased.", alias="purchaseOrderNumber")
    customer_service_rep_name: Optional[Annotated[str, Field(strict=True, max_length=50)]] = Field(default=None, description="Name of the account’s customer service representative, if applicable. ", alias="customerServiceRepName")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["Class__NS", "CustomerType__NS", "Department__NS", "IntegrationId__NS", "IntegrationStatus__NS", "Location__NS", "Subsidiary__NS", "SyncDate__NS", "SynctoNetSuite__NS", "accountNumber", "additionalEmailAddresses", "applicationOrder", "applyCredit", "applyCreditBalance", "autoPay", "batch", "billCycleDay", "billToContact", "collect", "communicationProfileId", "creditCard", "creditMemoReasonCode", "creditMemoTemplateId", "crmId", "currency", "debitMemoTemplateId", "documentDate", "hpmCreditCardPaymentMethodId", "invoice", "invoiceCollect", "invoiceDeliveryPrefsEmail", "invoiceDeliveryPrefsPrint", "invoiceTargetDate", "invoiceTemplateId", "name", "notes", "parentId", "partnerAccount", "paymentGateway", "paymentMethod", "paymentTerm", "profileNumber", "rollUpUsage", "runBilling", "salesRep", "sequenceSetId", "shipToContact", "shipToSameAsBillTo", "soldToContact", "soldToSameAsBillTo", "subscription", "tagging", "targetDate", "taxInfo", "communicationProfileName", "paymentGatewayNumber", "paymentGatewayName", "organizationId", "organizationName", "gatewayId", "paymentMethodId", "parentAccountNumber", "summaryStatementTemplateId", "sequenceSetName", "einvoiceProfile", "organizationLabel", "purchaseOrderNumber", "customerServiceRepName"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of CreateAccountRequest from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set([
            "additional_properties",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of bill_to_contact
        if self.bill_to_contact:
            _dict['billToContact'] = self.bill_to_contact.to_dict()
        # override the default output from pydantic by calling `to_dict()` of credit_card
        if self.credit_card:
            _dict['creditCard'] = self.credit_card.to_dict()
        # override the default output from pydantic by calling `to_dict()` of payment_method
        if self.payment_method:
            _dict['paymentMethod'] = self.payment_method.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ship_to_contact
        if self.ship_to_contact:
            _dict['shipToContact'] = self.ship_to_contact.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sold_to_contact
        if self.sold_to_contact:
            _dict['soldToContact'] = self.sold_to_contact.to_dict()
        # override the default output from pydantic by calling `to_dict()` of subscription
        if self.subscription:
            _dict['subscription'] = self.subscription.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tax_info
        if self.tax_info:
            _dict['taxInfo'] = self.tax_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of einvoice_profile
        if self.einvoice_profile:
            _dict['einvoiceProfile'] = self.einvoice_profile.to_dict()
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CreateAccountRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        obj = convert_snake_dict_to_camel(obj, cls.model_fields, cls.__properties)

        _obj = cls.model_validate(cls.to_alias_dict(obj))
        return cls.update_additional_properties(_obj, obj)

    @classmethod
    def update_additional_properties(cls, obj, _dict: Optional[Dict[str, Any]]):
        # store additional fields in additional_properties

        # store additional fields in additional_properties
        for _key in _dict.keys():
            if _key not in cls.__properties:
                obj.additional_properties[_key] = _dict.get(_key)


        return obj
        pass

    @classmethod
    def to_alias_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]:

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        return {
            "Class__NS": obj.get("Class__NS"),
            "CustomerType__NS": obj.get("CustomerType__NS"),
            "Department__NS": obj.get("Department__NS"),
            "IntegrationId__NS": obj.get("IntegrationId__NS"),
            "IntegrationStatus__NS": obj.get("IntegrationStatus__NS"),
            "Location__NS": obj.get("Location__NS"),
            "Subsidiary__NS": obj.get("Subsidiary__NS"),
            "SyncDate__NS": obj.get("SyncDate__NS"),
            "SynctoNetSuite__NS": obj.get("SynctoNetSuite__NS"),
            "accountNumber": obj.get("accountNumber"),
            "additionalEmailAddresses": obj.get("additionalEmailAddresses"),
            "applicationOrder": obj.get("applicationOrder"),
            "applyCredit": obj.get("applyCredit"),
            "applyCreditBalance": obj.get("applyCreditBalance"),
            "autoPay": obj.get("autoPay"),
            "batch": obj.get("batch"),
            "billCycleDay": obj.get("billCycleDay"),
            "billToContact": CreateAccountContact.from_dict(obj["billToContact"]) if obj.get("billToContact") is not None else None,
            "collect": obj.get("collect"),
            "communicationProfileId": obj.get("communicationProfileId"),
            "creditCard": CreateAccountCreditCard.from_dict(obj["creditCard"]) if obj.get("creditCard") is not None else None,
            "creditMemoReasonCode": obj.get("creditMemoReasonCode"),
            "creditMemoTemplateId": obj.get("creditMemoTemplateId"),
            "crmId": obj.get("crmId"),
            "currency": obj.get("currency"),
            "debitMemoTemplateId": obj.get("debitMemoTemplateId"),
            "documentDate": obj.get("documentDate"),
            "hpmCreditCardPaymentMethodId": obj.get("hpmCreditCardPaymentMethodId"),
            "invoice": obj.get("invoice"),
            "invoiceCollect": obj.get("invoiceCollect"),
            "invoiceDeliveryPrefsEmail": obj.get("invoiceDeliveryPrefsEmail") if obj.get("invoiceDeliveryPrefsEmail") is not None else False,
            "invoiceDeliveryPrefsPrint": obj.get("invoiceDeliveryPrefsPrint") if obj.get("invoiceDeliveryPrefsPrint") is not None else False,
            "invoiceTargetDate": obj.get("invoiceTargetDate"),
            "invoiceTemplateId": obj.get("invoiceTemplateId"),
            "name": obj.get("name"),
            "notes": obj.get("notes"),
            "parentId": obj.get("parentId"),
            "partnerAccount": obj.get("partnerAccount"),
            "paymentGateway": obj.get("paymentGateway"),
            "paymentMethod": CreateAccountPaymentMethod.from_dict(obj["paymentMethod"]) if obj.get("paymentMethod") is not None else None,
            "paymentTerm": obj.get("paymentTerm"),
            "profileNumber": obj.get("profileNumber"),
            "rollUpUsage": obj.get("rollUpUsage"),
            "runBilling": obj.get("runBilling"),
            "salesRep": obj.get("salesRep"),
            "sequenceSetId": obj.get("sequenceSetId"),
            "shipToContact": CreateAccountContact.from_dict(obj["shipToContact"]) if obj.get("shipToContact") is not None else None,
            "shipToSameAsBillTo": obj.get("shipToSameAsBillTo"),
            "soldToContact": CreateAccountContact.from_dict(obj["soldToContact"]) if obj.get("soldToContact") is not None else None,
            "soldToSameAsBillTo": obj.get("soldToSameAsBillTo"),
            "subscription": CreateAccountSubscription.from_dict(obj["subscription"]) if obj.get("subscription") is not None else None,
            "tagging": obj.get("tagging"),
            "targetDate": obj.get("targetDate"),
            "taxInfo": TaxInfo.from_dict(obj["taxInfo"]) if obj.get("taxInfo") is not None else None,
            "communicationProfileName": obj.get("communicationProfileName"),
            "paymentGatewayNumber": obj.get("paymentGatewayNumber"),
            "paymentGatewayName": obj.get("paymentGatewayName"),
            "organizationId": obj.get("organizationId"),
            "organizationName": obj.get("organizationName"),
            "gatewayId": obj.get("gatewayId"),
            "paymentMethodId": obj.get("paymentMethodId"),
            "parentAccountNumber": obj.get("parentAccountNumber"),
            "summaryStatementTemplateId": obj.get("summaryStatementTemplateId"),
            "sequenceSetName": obj.get("sequenceSetName"),
            "einvoiceProfile": AccountEInvoiceProfile.from_dict(obj["einvoiceProfile"]) if obj.get("einvoiceProfile") is not None else None,
            "organizationLabel": obj.get("organizationLabel"),
            "purchaseOrderNumber": obj.get("purchaseOrderNumber"),
            "customerServiceRepName": obj.get("customerServiceRepName")
        }
        return _obj


def convert_snake_dict_to_camel(_dict: dict, model_fields, properties):
    if not isinstance(_dict, dict):
        return _dict
    new_dict = {}
    for k, v in _dict.items():
        if k in model_fields:
            # model_fields: key is attribute name like bill_to_contact,
            alias = model_fields.get(k).alias or k
            new_dict[alias] = v
            pass
        else:
            new_key = snake_to_camel(k)
            if properties is not None and isinstance(properties, list) and new_key in properties:
                new_dict[new_key] = v
            else:
                new_dict[k] = v
    return new_dict
    pass


def snake_to_camel(name):
    if name is None or '_' not in name:
        return name
    components = name.split('_')
    return components[0] + ''.join(x.title() for x in components[1:])
