from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, cast

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.legacytypes_brand_config import LegacytypesBrandConfig
    from ..models.legacytypes_client_follow_up_config import LegacytypesClientFollowUpConfig
    from ..models.legacytypes_retirement_config import LegacytypesRetirementConfig
    from ..models.legacytypes_role import LegacytypesRole
    from ..models.legacytypes_smtp_configuration import LegacytypesSMTPConfiguration
    from ..models.legacytypes_stripe_config import LegacytypesStripeConfig
    from ..models.legacytypes_team_feature_flags import LegacytypesTeamFeatureFlags
    from ..models.legacytypes_usage_limits import LegacytypesUsageLimits


T = TypeVar("T", bound="LegacytypesTeam")


@_attrs_define
class LegacytypesTeam:
    """
    Attributes:
        field_id (str | Unset):
        about (str | Unset):
        api_key (str | Unset):
        brand (LegacytypesBrandConfig | Unset):
        client_directory (str | Unset):
        client_directory_template (str | Unset):
        client_invite_follow_up (LegacytypesClientFollowUpConfig | Unset):
        client_roles (list[LegacytypesRole] | Unset):
        client_task_follow_up (LegacytypesClientFollowUpConfig | Unset):
        created_on (str | Unset):
        default_send_role (str | Unset):
        deleted_at (str | Unset):
        email (str | Unset):
        fallback_email (str | Unset):
        feature_flags (LegacytypesTeamFeatureFlags | Unset): Temporary feature flag
        is_disabled (bool | Unset):
        limits (LegacytypesUsageLimits | Unset):
        login (str | Unset):
        name (str | Unset):
        page (str | Unset):
        phone (str | Unset):
        plan_tier (str | Unset): Plan Tiers
             - TPA: Charged by active plan sponsor + active additional plan [Default value if not set]
             - Free: Meant for collaborators - only have access to files, companies, plans, and participants
             - Pro: Full access - charged by user count, no payroll or client portal
             - Enterprise: Full access - custom contract for collaborators
        plan_year_questionnaires (list[str] | Unset):
        retirement (LegacytypesRetirementConfig | Unset):
        scopes (list[str] | Unset):
        sla (int | Unset):
        smtp (LegacytypesSMTPConfiguration | Unset):
        stripe (LegacytypesStripeConfig | Unset):
        website (str | Unset):
    """

    field_id: str | Unset = UNSET
    about: str | Unset = UNSET
    api_key: str | Unset = UNSET
    brand: LegacytypesBrandConfig | Unset = UNSET
    client_directory: str | Unset = UNSET
    client_directory_template: str | Unset = UNSET
    client_invite_follow_up: LegacytypesClientFollowUpConfig | Unset = UNSET
    client_roles: list[LegacytypesRole] | Unset = UNSET
    client_task_follow_up: LegacytypesClientFollowUpConfig | Unset = UNSET
    created_on: str | Unset = UNSET
    default_send_role: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    email: str | Unset = UNSET
    fallback_email: str | Unset = UNSET
    feature_flags: LegacytypesTeamFeatureFlags | Unset = UNSET
    is_disabled: bool | Unset = UNSET
    limits: LegacytypesUsageLimits | Unset = UNSET
    login: str | Unset = UNSET
    name: str | Unset = UNSET
    page: str | Unset = UNSET
    phone: str | Unset = UNSET
    plan_tier: str | Unset = UNSET
    plan_year_questionnaires: list[str] | Unset = UNSET
    retirement: LegacytypesRetirementConfig | Unset = UNSET
    scopes: list[str] | Unset = UNSET
    sla: int | Unset = UNSET
    smtp: LegacytypesSMTPConfiguration | Unset = UNSET
    stripe: LegacytypesStripeConfig | Unset = UNSET
    website: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        field_id = self.field_id

        about = self.about

        api_key = self.api_key

        brand: dict[str, Any] | Unset = UNSET
        if not isinstance(self.brand, Unset):
            brand = self.brand.to_dict()

        client_directory = self.client_directory

        client_directory_template = self.client_directory_template

        client_invite_follow_up: dict[str, Any] | Unset = UNSET
        if not isinstance(self.client_invite_follow_up, Unset):
            client_invite_follow_up = self.client_invite_follow_up.to_dict()

        client_roles: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.client_roles, Unset):
            client_roles = []
            for client_roles_item_data in self.client_roles:
                client_roles_item = client_roles_item_data.to_dict()
                client_roles.append(client_roles_item)

        client_task_follow_up: dict[str, Any] | Unset = UNSET
        if not isinstance(self.client_task_follow_up, Unset):
            client_task_follow_up = self.client_task_follow_up.to_dict()

        created_on = self.created_on

        default_send_role = self.default_send_role

        deleted_at = self.deleted_at

        email = self.email

        fallback_email = self.fallback_email

        feature_flags: dict[str, Any] | Unset = UNSET
        if not isinstance(self.feature_flags, Unset):
            feature_flags = self.feature_flags.to_dict()

        is_disabled = self.is_disabled

        limits: dict[str, Any] | Unset = UNSET
        if not isinstance(self.limits, Unset):
            limits = self.limits.to_dict()

        login = self.login

        name = self.name

        page = self.page

        phone = self.phone

        plan_tier = self.plan_tier

        plan_year_questionnaires: list[str] | Unset = UNSET
        if not isinstance(self.plan_year_questionnaires, Unset):
            plan_year_questionnaires = self.plan_year_questionnaires

        retirement: dict[str, Any] | Unset = UNSET
        if not isinstance(self.retirement, Unset):
            retirement = self.retirement.to_dict()

        scopes: list[str] | Unset = UNSET
        if not isinstance(self.scopes, Unset):
            scopes = self.scopes

        sla = self.sla

        smtp: dict[str, Any] | Unset = UNSET
        if not isinstance(self.smtp, Unset):
            smtp = self.smtp.to_dict()

        stripe: dict[str, Any] | Unset = UNSET
        if not isinstance(self.stripe, Unset):
            stripe = self.stripe.to_dict()

        website = self.website

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if field_id is not UNSET:
            field_dict["_id"] = field_id
        if about is not UNSET:
            field_dict["about"] = about
        if api_key is not UNSET:
            field_dict["api_key"] = api_key
        if brand is not UNSET:
            field_dict["brand"] = brand
        if client_directory is not UNSET:
            field_dict["client_directory"] = client_directory
        if client_directory_template is not UNSET:
            field_dict["client_directory_template"] = client_directory_template
        if client_invite_follow_up is not UNSET:
            field_dict["client_invite_follow_up"] = client_invite_follow_up
        if client_roles is not UNSET:
            field_dict["client_roles"] = client_roles
        if client_task_follow_up is not UNSET:
            field_dict["client_task_follow_up"] = client_task_follow_up
        if created_on is not UNSET:
            field_dict["created_on"] = created_on
        if default_send_role is not UNSET:
            field_dict["default_send_role"] = default_send_role
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if email is not UNSET:
            field_dict["email"] = email
        if fallback_email is not UNSET:
            field_dict["fallback_email"] = fallback_email
        if feature_flags is not UNSET:
            field_dict["feature_flags"] = feature_flags
        if is_disabled is not UNSET:
            field_dict["is_disabled"] = is_disabled
        if limits is not UNSET:
            field_dict["limits"] = limits
        if login is not UNSET:
            field_dict["login"] = login
        if name is not UNSET:
            field_dict["name"] = name
        if page is not UNSET:
            field_dict["page"] = page
        if phone is not UNSET:
            field_dict["phone"] = phone
        if plan_tier is not UNSET:
            field_dict["plan_tier"] = plan_tier
        if plan_year_questionnaires is not UNSET:
            field_dict["plan_year_questionnaires"] = plan_year_questionnaires
        if retirement is not UNSET:
            field_dict["retirement"] = retirement
        if scopes is not UNSET:
            field_dict["scopes"] = scopes
        if sla is not UNSET:
            field_dict["sla"] = sla
        if smtp is not UNSET:
            field_dict["smtp"] = smtp
        if stripe is not UNSET:
            field_dict["stripe"] = stripe
        if website is not UNSET:
            field_dict["website"] = website

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.legacytypes_brand_config import LegacytypesBrandConfig
        from ..models.legacytypes_client_follow_up_config import LegacytypesClientFollowUpConfig
        from ..models.legacytypes_retirement_config import LegacytypesRetirementConfig
        from ..models.legacytypes_role import LegacytypesRole
        from ..models.legacytypes_smtp_configuration import LegacytypesSMTPConfiguration
        from ..models.legacytypes_stripe_config import LegacytypesStripeConfig
        from ..models.legacytypes_team_feature_flags import LegacytypesTeamFeatureFlags
        from ..models.legacytypes_usage_limits import LegacytypesUsageLimits

        d = dict(src_dict)
        field_id = d.pop("_id", UNSET)

        about = d.pop("about", UNSET)

        api_key = d.pop("api_key", UNSET)

        _brand = d.pop("brand", UNSET)
        brand: LegacytypesBrandConfig | Unset
        if isinstance(_brand, Unset):
            brand = UNSET
        else:
            brand = LegacytypesBrandConfig.from_dict(_brand)

        client_directory = d.pop("client_directory", UNSET)

        client_directory_template = d.pop("client_directory_template", UNSET)

        _client_invite_follow_up = d.pop("client_invite_follow_up", UNSET)
        client_invite_follow_up: LegacytypesClientFollowUpConfig | Unset
        if isinstance(_client_invite_follow_up, Unset):
            client_invite_follow_up = UNSET
        else:
            client_invite_follow_up = LegacytypesClientFollowUpConfig.from_dict(_client_invite_follow_up)

        _client_roles = d.pop("client_roles", UNSET)
        client_roles: list[LegacytypesRole] | Unset = UNSET
        if _client_roles is not UNSET:
            client_roles = []
            for client_roles_item_data in _client_roles:
                client_roles_item = LegacytypesRole.from_dict(client_roles_item_data)

                client_roles.append(client_roles_item)

        _client_task_follow_up = d.pop("client_task_follow_up", UNSET)
        client_task_follow_up: LegacytypesClientFollowUpConfig | Unset
        if isinstance(_client_task_follow_up, Unset):
            client_task_follow_up = UNSET
        else:
            client_task_follow_up = LegacytypesClientFollowUpConfig.from_dict(_client_task_follow_up)

        created_on = d.pop("created_on", UNSET)

        default_send_role = d.pop("default_send_role", UNSET)

        deleted_at = d.pop("deleted_at", UNSET)

        email = d.pop("email", UNSET)

        fallback_email = d.pop("fallback_email", UNSET)

        _feature_flags = d.pop("feature_flags", UNSET)
        feature_flags: LegacytypesTeamFeatureFlags | Unset
        if isinstance(_feature_flags, Unset):
            feature_flags = UNSET
        else:
            feature_flags = LegacytypesTeamFeatureFlags.from_dict(_feature_flags)

        is_disabled = d.pop("is_disabled", UNSET)

        _limits = d.pop("limits", UNSET)
        limits: LegacytypesUsageLimits | Unset
        if isinstance(_limits, Unset):
            limits = UNSET
        else:
            limits = LegacytypesUsageLimits.from_dict(_limits)

        login = d.pop("login", UNSET)

        name = d.pop("name", UNSET)

        page = d.pop("page", UNSET)

        phone = d.pop("phone", UNSET)

        plan_tier = d.pop("plan_tier", UNSET)

        plan_year_questionnaires = cast(list[str], d.pop("plan_year_questionnaires", UNSET))

        _retirement = d.pop("retirement", UNSET)
        retirement: LegacytypesRetirementConfig | Unset
        if isinstance(_retirement, Unset):
            retirement = UNSET
        else:
            retirement = LegacytypesRetirementConfig.from_dict(_retirement)

        scopes = cast(list[str], d.pop("scopes", UNSET))

        sla = d.pop("sla", UNSET)

        _smtp = d.pop("smtp", UNSET)
        smtp: LegacytypesSMTPConfiguration | Unset
        if isinstance(_smtp, Unset):
            smtp = UNSET
        else:
            smtp = LegacytypesSMTPConfiguration.from_dict(_smtp)

        _stripe = d.pop("stripe", UNSET)
        stripe: LegacytypesStripeConfig | Unset
        if isinstance(_stripe, Unset):
            stripe = UNSET
        else:
            stripe = LegacytypesStripeConfig.from_dict(_stripe)

        website = d.pop("website", UNSET)

        legacytypes_team = cls(
            field_id=field_id,
            about=about,
            api_key=api_key,
            brand=brand,
            client_directory=client_directory,
            client_directory_template=client_directory_template,
            client_invite_follow_up=client_invite_follow_up,
            client_roles=client_roles,
            client_task_follow_up=client_task_follow_up,
            created_on=created_on,
            default_send_role=default_send_role,
            deleted_at=deleted_at,
            email=email,
            fallback_email=fallback_email,
            feature_flags=feature_flags,
            is_disabled=is_disabled,
            limits=limits,
            login=login,
            name=name,
            page=page,
            phone=phone,
            plan_tier=plan_tier,
            plan_year_questionnaires=plan_year_questionnaires,
            retirement=retirement,
            scopes=scopes,
            sla=sla,
            smtp=smtp,
            stripe=stripe,
            website=website,
        )

        legacytypes_team.additional_properties = d
        return legacytypes_team

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
