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

from __future__ import annotations
from enum import Enum
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 IdentityVerificationStatus(str, Enum):
    r"""|   |   |
    |---|---|
    |__Status__| __Description__ |
    | Pass | Signatory can sign all forms |
    | Fail | Signatory cannot sign forms |
    | Skipped | Signatory cannot sign Form 8655 until the form is manually uploaded as wet-signed |
    | null | Identity verification process has not been completed |
    """

    PASS = "Pass"
    FAIL = "Fail"
    SKIPPED = "Skipped"


class HomeAddressTypedDict(TypedDict):
    street_1: NotRequired[str]
    street_2: NotRequired[str]
    city: NotRequired[str]
    state: NotRequired[str]
    zip: NotRequired[str]
    country: NotRequired[str]


class HomeAddress(BaseModel):
    street_1: Optional[str] = None

    street_2: Optional[str] = None

    city: Optional[str] = None

    state: Optional[str] = None

    zip: Optional[str] = None

    country: Optional[str] = "USA"


class SignatoryTypedDict(TypedDict):
    r"""The representation of a company's signatory"""

    uuid: str
    first_name: NotRequired[Nullable[str]]
    last_name: NotRequired[Nullable[str]]
    title: NotRequired[Nullable[str]]
    phone: NotRequired[Nullable[str]]
    email: NotRequired[str]
    birthday: NotRequired[Nullable[str]]
    is_admin: NotRequired[bool]
    r"""Whether or not the signatory is also the payroll admin of the company."""
    has_ssn: NotRequired[bool]
    r"""Indicates whether the signatory has an SSN in Gusto."""
    version: NotRequired[str]
    r"""The current version of the signatory. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/idempotency) for information on how to use this field."""
    identity_verification_status: NotRequired[Nullable[IdentityVerificationStatus]]
    r"""|   |   |
    |---|---|
    |__Status__| __Description__ |
    | Pass | Signatory can sign all forms |
    | Fail | Signatory cannot sign forms |
    | Skipped | Signatory cannot sign Form 8655 until the form is manually uploaded as wet-signed |
    | null | Identity verification process has not been completed |
    """
    home_address: NotRequired[Nullable[HomeAddressTypedDict]]


class Signatory(BaseModel):
    r"""The representation of a company's signatory"""

    uuid: str

    first_name: OptionalNullable[str] = UNSET

    last_name: OptionalNullable[str] = UNSET

    title: OptionalNullable[str] = UNSET

    phone: OptionalNullable[str] = UNSET

    email: Optional[str] = None

    birthday: OptionalNullable[str] = UNSET

    is_admin: Optional[bool] = None
    r"""Whether or not the signatory is also the payroll admin of the company."""

    has_ssn: Optional[bool] = None
    r"""Indicates whether the signatory has an SSN in Gusto."""

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

    identity_verification_status: OptionalNullable[IdentityVerificationStatus] = UNSET
    r"""|   |   |
    |---|---|
    |__Status__| __Description__ |
    | Pass | Signatory can sign all forms |
    | Fail | Signatory cannot sign forms |
    | Skipped | Signatory cannot sign Form 8655 until the form is manually uploaded as wet-signed |
    | null | Identity verification process has not been completed |
    """

    home_address: OptionalNullable[HomeAddress] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "first_name",
            "last_name",
            "title",
            "phone",
            "email",
            "birthday",
            "is_admin",
            "has_ssn",
            "version",
            "identity_verification_status",
            "home_address",
        ]
        nullable_fields = [
            "first_name",
            "last_name",
            "title",
            "phone",
            "birthday",
            "identity_verification_status",
            "home_address",
        ]
        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
