"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from gusto_embedded.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class FederalTaxDetailsTypedDict(TypedDict):
    r"""Example response"""

    version: NotRequired[str]
    r"""The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/idempotency) for information on how to use this field."""
    tax_payer_type: NotRequired[Nullable[str]]
    r"""What type of tax entity the company is. One of:
    - C-Corporation
    - S-Corporation
    - Sole proprietor
    - LLC
    - LLP
    - Limited partnership
    - Co-ownership
    - Association
    - Trusteeship
    - General partnership
    - Joint venture
    - Non-Profit
    """
    taxable_as_scorp: NotRequired[bool]
    r"""Whether the company is taxed as an S-Corporation. Tax payer types that may be taxed as an S-Corporation include:
    - S-Corporation
    - C-Corporation
    - LLC
    """
    filing_form: NotRequired[str]
    r"""The form used by the company for federal tax filing. One of:
    - 941 (Quarterly federal tax return form)
    - 944 (Annual federal tax return form)
    """
    has_ein: NotRequired[bool]
    r"""Whether company's Employer Identification Number (EIN) is present"""
    ein_verified: NotRequired[bool]
    r"""Whether the EIN was able to be verified as a valid EIN with the IRS."""
    legal_name: NotRequired[str]
    r"""The legal name of the company"""
    effective_date: NotRequired[str]
    r"""The date that these details took effect."""
    deposit_schedule: NotRequired[str]
    r"""How often the company sends money to the IRS. One of:
    - Semiweekly
    - Monthly
    """


class FederalTaxDetails(BaseModel):
    r"""Example response"""

    version: Optional[str] = None
    r"""The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/idempotency) for information on how to use this field."""

    tax_payer_type: OptionalNullable[str] = UNSET
    r"""What type of tax entity the company is. One of:
    - C-Corporation
    - S-Corporation
    - Sole proprietor
    - LLC
    - LLP
    - Limited partnership
    - Co-ownership
    - Association
    - Trusteeship
    - General partnership
    - Joint venture
    - Non-Profit
    """

    taxable_as_scorp: Optional[bool] = None
    r"""Whether the company is taxed as an S-Corporation. Tax payer types that may be taxed as an S-Corporation include:
    - S-Corporation
    - C-Corporation
    - LLC
    """

    filing_form: Optional[str] = None
    r"""The form used by the company for federal tax filing. One of:
    - 941 (Quarterly federal tax return form)
    - 944 (Annual federal tax return form)
    """

    has_ein: Optional[bool] = None
    r"""Whether company's Employer Identification Number (EIN) is present"""

    ein_verified: Optional[bool] = None
    r"""Whether the EIN was able to be verified as a valid EIN with the IRS."""

    legal_name: Optional[str] = None
    r"""The legal name of the company"""

    effective_date: Optional[str] = None
    r"""The date that these details took effect."""

    deposit_schedule: Optional[str] = None
    r"""How often the company sends money to the IRS. One of:
    - Semiweekly
    - Monthly
    """

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "version",
            "tax_payer_type",
            "taxable_as_scorp",
            "filing_form",
            "has_ein",
            "ein_verified",
            "legal_name",
            "effective_date",
            "deposit_schedule",
        ]
        nullable_fields = ["tax_payer_type"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
