# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

from ....core.datetime_utils import serialize_datetime
from .account_type import AccountType
from .profile_request import ProfileRequest

try:
    import pydantic.v1 as pydantic  # type: ignore
except ImportError:
    import pydantic  # type: ignore


class EntityRequest(pydantic.BaseModel):
    """
    from mercoa import (
        AccountType,
        Address,
        BusinessProfileRequest,
        BusinessType,
        Ein,
        EntityRequest,
        PhoneNumber,
        ProfileRequest,
        TaxId,
    )

    EntityRequest(
        is_customer=True,
        is_payor=True,
        is_payee=False,
        account_type=AccountType.BUSINESS,
        profile=ProfileRequest(
            business=BusinessProfileRequest(
                email="customer@acme.com",
                legal_business_name="Acme Inc.",
                website="http://www.acme.com",
                business_type=BusinessType.LLC,
                phone=PhoneNumber(
                    country_code="1",
                    number="4155551234",
                ),
                address=Address(
                    address_line_1="123 Main St",
                    city="San Francisco",
                    state_or_province="CA",
                    postal_code="94105",
                    country="US",
                ),
                tax_id=TaxId(
                    ein=Ein(
                        number="12-3456789",
                    ),
                ),
            ),
        ),
    )
    """

    foreign_id: typing.Optional[str] = pydantic.Field(
        alias="foreignId",
        description="The ID used to identify this entity in your system. This ID must be unique across all entities in your system.",
    )
    email_to: typing.Optional[str] = pydantic.Field(
        alias="emailTo",
        description="Sets the email address to which to send invoices to be added to the Invoice Inbox. Only provide the local-part/username of the email address, do not include the @domain.com",
    )
    email_to_alias: typing.Optional[typing.List[str]] = pydantic.Field(
        alias="emailToAlias",
        description="Email inbox alias addresses. Used when forwarding emails to the emailTo address from an alias. Include the full email address.",
    )
    is_customer: bool = pydantic.Field(
        alias="isCustomer",
        description="If this entity has a direct relationship with your organization (e.g your direct customer or client), set this to true. Otherwise, set to false (e.g your customer's vendors).",
    )
    account_type: AccountType = pydantic.Field(alias="accountType")
    profile: ProfileRequest
    is_payor: bool = pydantic.Field(
        alias="isPayor", description="If this entity will be paying invoices, set this to true."
    )
    is_payee: bool = pydantic.Field(
        alias="isPayee", description="If this entity will be receiving payments, set this to true."
    )
    logo: typing.Optional[str] = pydantic.Field(description="Base64 encoded PNG image data for the entity logo.")

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        allow_population_by_field_name = True
        json_encoders = {dt.datetime: serialize_datetime}
