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

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


class FipsCodesTypedDict(TypedDict):
    code: NotRequired[str]
    r"""FIPS code for state or county"""
    county: NotRequired[Nullable[str]]
    r"""Name of county in the state for the corresponding FIPS code. When `null` the FIPS code applies state wide."""


class FipsCodes(BaseModel):
    code: Optional[str] = None
    r"""FIPS code for state or county"""

    county: OptionalNullable[str] = UNSET
    r"""Name of county in the state for the corresponding FIPS code. When `null` the FIPS code applies state wide."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["code", "county"]
        nullable_fields = ["county"]
        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


class Key(str, Enum):
    r"""A required attribute when creating a garnishment for this state agency. The current values are listed as an enum; though unlikely, values could be added if state agency requirements change in the future."""

    CASE_NUMBER = "case_number"
    ORDER_NUMBER = "order_number"
    REMITTANCE_NUMBER = "remittance_number"


class RequiredAttributesTypedDict(TypedDict):
    key: NotRequired[Key]
    r"""A required attribute when creating a garnishment for this state agency. The current values are listed as an enum; though unlikely, values could be added if state agency requirements change in the future."""
    label: NotRequired[str]
    r"""A human readable name of the attribute, e.g. CSE Case Number"""


class RequiredAttributes(BaseModel):
    key: Optional[Key] = None
    r"""A required attribute when creating a garnishment for this state agency. The current values are listed as an enum; though unlikely, values could be added if state agency requirements change in the future."""

    label: Optional[str] = None
    r"""A human readable name of the attribute, e.g. CSE Case Number"""


class AgenciesTypedDict(TypedDict):
    state: NotRequired[str]
    r"""Two letter state abbreviation"""
    name: NotRequired[str]
    r"""Name of state child support agency"""
    manual_payment_required: NotRequired[bool]
    r"""Specifies if remitting payment to the agency is required outside of Gusto. If true, Gusto includes garnishment amounts for this agency in payroll calculation, but does not debit for or remit payment to the agency automatically. As of September 2024, only garnishments for South Carolina Integrated Child Support Services require manual payment.

    """
    fips_codes: NotRequired[List[FipsCodesTypedDict]]
    r"""FIPS codes for state or county child support orders"""
    required_attributes: NotRequired[List[RequiredAttributesTypedDict]]
    r"""Describes which child support case identifying attributes are required for this agency. While most agencies only require a single identifier, some (e.g. OH) require multiple identifiers."""


class Agencies(BaseModel):
    state: Optional[str] = None
    r"""Two letter state abbreviation"""

    name: Optional[str] = None
    r"""Name of state child support agency"""

    manual_payment_required: Optional[bool] = None
    r"""Specifies if remitting payment to the agency is required outside of Gusto. If true, Gusto includes garnishment amounts for this agency in payroll calculation, but does not debit for or remit payment to the agency automatically. As of September 2024, only garnishments for South Carolina Integrated Child Support Services require manual payment.

    """

    fips_codes: Optional[List[FipsCodes]] = None
    r"""FIPS codes for state or county child support orders"""

    required_attributes: Optional[List[RequiredAttributes]] = None
    r"""Describes which child support case identifying attributes are required for this agency. While most agencies only require a single identifier, some (e.g. OH) require multiple identifiers."""


class ChildSupportDataTypedDict(TypedDict):
    r"""Child Support agency data"""

    agencies: NotRequired[List[AgenciesTypedDict]]
    r"""State child support agencies"""


class ChildSupportData(BaseModel):
    r"""Child Support agency data"""

    agencies: Optional[List[Agencies]] = None
    r"""State child support agencies"""
