# coding: utf-8

"""
    CustomerManagementService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    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 datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.customer.account_financial_status import AccountFinancialStatus
from openapi_client.models.customer.account_life_cycle_status import AccountLifeCycleStatus
from openapi_client.models.customer.account_tax_certificate import AccountTaxCertificate
from openapi_client.models.customer.address import Address
from openapi_client.models.customer.auto_tag_type import AutoTagType
from openapi_client.models.customer.currency_code import CurrencyCode
from openapi_client.models.customer.customer_info import CustomerInfo
from openapi_client.models.customer.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from openapi_client.models.customer.language_type import LanguageType
from openapi_client.models.customer.payment_method_type import PaymentMethodType
from openapi_client.models.customer.time_zone_type import TimeZoneType
from typing_extensions import Self

class AdvertiserAccount(BaseModel):
    """
    AdvertiserAccount
    """ # noqa: E501
    bill_to_customer_id: Optional[StrictStr] = Field(default=None, alias="BillToCustomerId")
    currency_code: Optional[CurrencyCode] = Field(default=None, alias="CurrencyCode")
    account_financial_status: Optional[AccountFinancialStatus] = Field(default=None, alias="AccountFinancialStatus")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    language: Optional[LanguageType] = Field(default=None, alias="Language")
    last_modified_by_user_id: Optional[StrictStr] = Field(default=None, alias="LastModifiedByUserId")
    last_modified_time: Optional[datetime] = Field(default=None, alias="LastModifiedTime")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    number: Optional[StrictStr] = Field(default=None, alias="Number")
    parent_customer_id: Optional[StrictStr] = Field(default=None, alias="ParentCustomerId")
    payment_method_id: Optional[StrictStr] = Field(default=None, alias="PaymentMethodId")
    payment_method_type: Optional[PaymentMethodType] = Field(default=None, alias="PaymentMethodType")
    primary_user_id: Optional[StrictStr] = Field(default=None, alias="PrimaryUserId")
    account_life_cycle_status: Optional[AccountLifeCycleStatus] = Field(default=None, alias="AccountLifeCycleStatus")
    time_stamp: Optional[StrictStr] = Field(default=None, alias="TimeStamp")
    time_zone: Optional[TimeZoneType] = Field(default=None, alias="TimeZone")
    pause_reason: Optional[StrictInt] = Field(default=None, alias="PauseReason")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    linked_agencies: Optional[List[Optional[CustomerInfo]]] = Field(default=None, alias="LinkedAgencies")
    sales_house_customer_id: Optional[StrictStr] = Field(default=None, alias="SalesHouseCustomerId")
    tax_information: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="TaxInformation")
    back_up_payment_instrument_id: Optional[StrictStr] = Field(default=None, alias="BackUpPaymentInstrumentId")
    billing_threshold_amount: Optional[StrictFloat] = Field(default=None, alias="BillingThresholdAmount")
    business_address: Optional[Address] = Field(default=None, alias="BusinessAddress")
    auto_tag_type: Optional[AutoTagType] = Field(default=None, alias="AutoTagType")
    sold_to_payment_instrument_id: Optional[StrictStr] = Field(default=None, alias="SoldToPaymentInstrumentId")
    tax_certificate: Optional[AccountTaxCertificate] = Field(default=None, alias="TaxCertificate")
    account_mode: Optional[StrictStr] = Field(default=None, alias="AccountMode")
    __properties: ClassVar[List[str]] = ["BillToCustomerId", "CurrencyCode", "AccountFinancialStatus", "Id", "Language", "LastModifiedByUserId", "LastModifiedTime", "Name", "Number", "ParentCustomerId", "PaymentMethodId", "PaymentMethodType", "PrimaryUserId", "AccountLifeCycleStatus", "TimeStamp", "TimeZone", "PauseReason", "ForwardCompatibilityMap", "LinkedAgencies", "SalesHouseCustomerId", "TaxInformation", "BackUpPaymentInstrumentId", "BillingThresholdAmount", "BusinessAddress", "AutoTagType", "SoldToPaymentInstrumentId", "TaxCertificate", "AccountMode"]

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

    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.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in forward_compatibility_map (list)
        _items = []
        if self.forward_compatibility_map:
            for _item_forward_compatibility_map in self.forward_compatibility_map:
                if _item_forward_compatibility_map:
                    _items.append(_item_forward_compatibility_map.to_dict())
            _dict['ForwardCompatibilityMap'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in linked_agencies (list)
        _items = []
        if self.linked_agencies:
            for _item_linked_agencies in self.linked_agencies:
                if _item_linked_agencies:
                    _items.append(_item_linked_agencies.to_dict())
            _dict['LinkedAgencies'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in tax_information (list)
        _items = []
        if self.tax_information:
            for _item_tax_information in self.tax_information:
                if _item_tax_information:
                    _items.append(_item_tax_information.to_dict())
            _dict['TaxInformation'] = _items
        # override the default output from pydantic by calling `to_dict()` of business_address
        if self.business_address:
            _dict['BusinessAddress'] = self.business_address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tax_certificate
        if self.tax_certificate:
            _dict['TaxCertificate'] = self.tax_certificate.to_dict()
        # set to None if bill_to_customer_id (nullable) is None
        # and model_fields_set contains the field
        if self.bill_to_customer_id is None and "bill_to_customer_id" in self.model_fields_set:
            _dict['BillToCustomerId'] = None

        # set to None if currency_code (nullable) is None
        # and model_fields_set contains the field
        if self.currency_code is None and "currency_code" in self.model_fields_set:
            _dict['CurrencyCode'] = None

        # set to None if account_financial_status (nullable) is None
        # and model_fields_set contains the field
        if self.account_financial_status is None and "account_financial_status" in self.model_fields_set:
            _dict['AccountFinancialStatus'] = None

        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['Id'] = None

        # set to None if language (nullable) is None
        # and model_fields_set contains the field
        if self.language is None and "language" in self.model_fields_set:
            _dict['Language'] = None

        # set to None if last_modified_by_user_id (nullable) is None
        # and model_fields_set contains the field
        if self.last_modified_by_user_id is None and "last_modified_by_user_id" in self.model_fields_set:
            _dict['LastModifiedByUserId'] = None

        # set to None if last_modified_time (nullable) is None
        # and model_fields_set contains the field
        if self.last_modified_time is None and "last_modified_time" in self.model_fields_set:
            _dict['LastModifiedTime'] = None

        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['Name'] = None

        # set to None if number (nullable) is None
        # and model_fields_set contains the field
        if self.number is None and "number" in self.model_fields_set:
            _dict['Number'] = None

        # set to None if parent_customer_id (nullable) is None
        # and model_fields_set contains the field
        if self.parent_customer_id is None and "parent_customer_id" in self.model_fields_set:
            _dict['ParentCustomerId'] = None

        # set to None if payment_method_id (nullable) is None
        # and model_fields_set contains the field
        if self.payment_method_id is None and "payment_method_id" in self.model_fields_set:
            _dict['PaymentMethodId'] = None

        # set to None if payment_method_type (nullable) is None
        # and model_fields_set contains the field
        if self.payment_method_type is None and "payment_method_type" in self.model_fields_set:
            _dict['PaymentMethodType'] = None

        # set to None if primary_user_id (nullable) is None
        # and model_fields_set contains the field
        if self.primary_user_id is None and "primary_user_id" in self.model_fields_set:
            _dict['PrimaryUserId'] = None

        # set to None if account_life_cycle_status (nullable) is None
        # and model_fields_set contains the field
        if self.account_life_cycle_status is None and "account_life_cycle_status" in self.model_fields_set:
            _dict['AccountLifeCycleStatus'] = None

        # set to None if time_stamp (nullable) is None
        # and model_fields_set contains the field
        if self.time_stamp is None and "time_stamp" in self.model_fields_set:
            _dict['TimeStamp'] = None

        # set to None if time_zone (nullable) is None
        # and model_fields_set contains the field
        if self.time_zone is None and "time_zone" in self.model_fields_set:
            _dict['TimeZone'] = None

        # set to None if pause_reason (nullable) is None
        # and model_fields_set contains the field
        if self.pause_reason is None and "pause_reason" in self.model_fields_set:
            _dict['PauseReason'] = None

        # set to None if forward_compatibility_map (nullable) is None
        # and model_fields_set contains the field
        if self.forward_compatibility_map is None and "forward_compatibility_map" in self.model_fields_set:
            _dict['ForwardCompatibilityMap'] = None

        # set to None if linked_agencies (nullable) is None
        # and model_fields_set contains the field
        if self.linked_agencies is None and "linked_agencies" in self.model_fields_set:
            _dict['LinkedAgencies'] = None

        # set to None if sales_house_customer_id (nullable) is None
        # and model_fields_set contains the field
        if self.sales_house_customer_id is None and "sales_house_customer_id" in self.model_fields_set:
            _dict['SalesHouseCustomerId'] = None

        # set to None if tax_information (nullable) is None
        # and model_fields_set contains the field
        if self.tax_information is None and "tax_information" in self.model_fields_set:
            _dict['TaxInformation'] = None

        # set to None if back_up_payment_instrument_id (nullable) is None
        # and model_fields_set contains the field
        if self.back_up_payment_instrument_id is None and "back_up_payment_instrument_id" in self.model_fields_set:
            _dict['BackUpPaymentInstrumentId'] = None

        # set to None if billing_threshold_amount (nullable) is None
        # and model_fields_set contains the field
        if self.billing_threshold_amount is None and "billing_threshold_amount" in self.model_fields_set:
            _dict['BillingThresholdAmount'] = None

        # set to None if business_address (nullable) is None
        # and model_fields_set contains the field
        if self.business_address is None and "business_address" in self.model_fields_set:
            _dict['BusinessAddress'] = None

        # set to None if auto_tag_type (nullable) is None
        # and model_fields_set contains the field
        if self.auto_tag_type is None and "auto_tag_type" in self.model_fields_set:
            _dict['AutoTagType'] = None

        # set to None if sold_to_payment_instrument_id (nullable) is None
        # and model_fields_set contains the field
        if self.sold_to_payment_instrument_id is None and "sold_to_payment_instrument_id" in self.model_fields_set:
            _dict['SoldToPaymentInstrumentId'] = None

        # set to None if tax_certificate (nullable) is None
        # and model_fields_set contains the field
        if self.tax_certificate is None and "tax_certificate" in self.model_fields_set:
            _dict['TaxCertificate'] = None

        # set to None if account_mode (nullable) is None
        # and model_fields_set contains the field
        if self.account_mode is None and "account_mode" in self.model_fields_set:
            _dict['AccountMode'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "BillToCustomerId": obj.get("BillToCustomerId") if obj.get("BillToCustomerId") is not None else None,
                        "CurrencyCode": obj.get("CurrencyCode") if obj.get("CurrencyCode") is not None else None,
                        "AccountFinancialStatus": obj.get("AccountFinancialStatus") if obj.get("AccountFinancialStatus") is not None else None,
                        "Id": obj.get("Id") if obj.get("Id") is not None else None,
                        "Language": obj.get("Language") if obj.get("Language") is not None else None,
                        "LastModifiedByUserId": obj.get("LastModifiedByUserId") if obj.get("LastModifiedByUserId") is not None else None,
                        "LastModifiedTime": obj.get("LastModifiedTime") if obj.get("LastModifiedTime") is not None else None,
                        "Name": obj.get("Name") if obj.get("Name") is not None else None,
                        "Number": obj.get("Number") if obj.get("Number") is not None else None,
                        "ParentCustomerId": obj.get("ParentCustomerId") if obj.get("ParentCustomerId") is not None else None,
                        "PaymentMethodId": obj.get("PaymentMethodId") if obj.get("PaymentMethodId") is not None else None,
                        "PaymentMethodType": obj.get("PaymentMethodType") if obj.get("PaymentMethodType") is not None else None,
                        "PrimaryUserId": obj.get("PrimaryUserId") if obj.get("PrimaryUserId") is not None else None,
                        "AccountLifeCycleStatus": obj.get("AccountLifeCycleStatus") if obj.get("AccountLifeCycleStatus") is not None else None,
                        "TimeStamp": obj.get("TimeStamp") if obj.get("TimeStamp") is not None else None,
                        "TimeZone": obj.get("TimeZone") if obj.get("TimeZone") is not None else None,
                        "PauseReason": obj.get("PauseReason") if obj.get("PauseReason") is not None else None,
                        "ForwardCompatibilityMap": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["ForwardCompatibilityMap"]] if obj.get("ForwardCompatibilityMap") is not None else None,
                        "LinkedAgencies": [CustomerInfo.from_dict(_item) for _item in obj["LinkedAgencies"]] if obj.get("LinkedAgencies") is not None else None,
                        "SalesHouseCustomerId": obj.get("SalesHouseCustomerId") if obj.get("SalesHouseCustomerId") is not None else None,
                        "TaxInformation": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["TaxInformation"]] if obj.get("TaxInformation") is not None else None,
                        "BackUpPaymentInstrumentId": obj.get("BackUpPaymentInstrumentId") if obj.get("BackUpPaymentInstrumentId") is not None else None,
                        "BillingThresholdAmount": obj.get("BillingThresholdAmount") if obj.get("BillingThresholdAmount") is not None else None,
                        "BusinessAddress": Address.from_dict(obj["BusinessAddress"]) if obj.get("BusinessAddress") is not None else None,
                        "AutoTagType": obj.get("AutoTagType") if obj.get("AutoTagType") is not None else None,
                        "SoldToPaymentInstrumentId": obj.get("SoldToPaymentInstrumentId") if obj.get("SoldToPaymentInstrumentId") is not None else None,
                        "TaxCertificate": AccountTaxCertificate.from_dict(obj["TaxCertificate"]) if obj.get("TaxCertificate") is not None else None,
                        "AccountMode": obj.get("AccountMode") if obj.get("AccountMode") is not None else None
        })
        return _obj
