from __future__ import annotations

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

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

from ..models.finchgo_connect_session_new_params_integration_auth_method import (
    FinchgoConnectSessionNewParamsIntegrationAuthMethod,
)
from ..models.finchgo_connect_session_new_params_product import FinchgoConnectSessionNewParamsProduct
from ..models.finchgo_connect_session_reauthenticate_params_product import (
    FinchgoConnectSessionReauthenticateParamsProduct,
)
from ..types import UNSET, Unset

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


@_attrs_define
class TypesPayrollProvider:
    """
    Attributes:
        field_id (str | Unset):
        auth_method (FinchgoConnectSessionNewParamsIntegrationAuthMethod | Unset):
        available_new_scopes (list[FinchgoConnectSessionNewParamsProduct] | Unset):
        available_reauth_scopes (list[FinchgoConnectSessionReauthenticateParamsProduct] | Unset):
        beta (bool | Unset):
        color (str | Unset):
        created_at (str | Unset):
        docs_url (str | Unset):
        enabled (bool | Unset):
        icon (str | Unset):
        is_assisted (bool | Unset):
        logo (str | Unset):
        manual (bool | Unset):
        mfa_required (bool | Unset):
        name (str | Unset):
        provider (str | Unset):
        remote_id (str | Unset):
        updated_at (str | Unset):
    """

    field_id: str | Unset = UNSET
    auth_method: FinchgoConnectSessionNewParamsIntegrationAuthMethod | Unset = UNSET
    available_new_scopes: list[FinchgoConnectSessionNewParamsProduct] | Unset = UNSET
    available_reauth_scopes: list[FinchgoConnectSessionReauthenticateParamsProduct] | Unset = UNSET
    beta: bool | Unset = UNSET
    color: str | Unset = UNSET
    created_at: str | Unset = UNSET
    docs_url: str | Unset = UNSET
    enabled: bool | Unset = UNSET
    icon: str | Unset = UNSET
    is_assisted: bool | Unset = UNSET
    logo: str | Unset = UNSET
    manual: bool | Unset = UNSET
    mfa_required: bool | Unset = UNSET
    name: str | Unset = UNSET
    provider: str | Unset = UNSET
    remote_id: str | Unset = UNSET
    updated_at: 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

        auth_method: str | Unset = UNSET
        if not isinstance(self.auth_method, Unset):
            auth_method = self.auth_method.value

        available_new_scopes: list[str] | Unset = UNSET
        if not isinstance(self.available_new_scopes, Unset):
            available_new_scopes = []
            for available_new_scopes_item_data in self.available_new_scopes:
                available_new_scopes_item = available_new_scopes_item_data.value
                available_new_scopes.append(available_new_scopes_item)

        available_reauth_scopes: list[str] | Unset = UNSET
        if not isinstance(self.available_reauth_scopes, Unset):
            available_reauth_scopes = []
            for available_reauth_scopes_item_data in self.available_reauth_scopes:
                available_reauth_scopes_item = available_reauth_scopes_item_data.value
                available_reauth_scopes.append(available_reauth_scopes_item)

        beta = self.beta

        color = self.color

        created_at = self.created_at

        docs_url = self.docs_url

        enabled = self.enabled

        icon = self.icon

        is_assisted = self.is_assisted

        logo = self.logo

        manual = self.manual

        mfa_required = self.mfa_required

        name = self.name

        provider = self.provider

        remote_id = self.remote_id

        updated_at = self.updated_at

        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 auth_method is not UNSET:
            field_dict["auth_method"] = auth_method
        if available_new_scopes is not UNSET:
            field_dict["available_new_scopes"] = available_new_scopes
        if available_reauth_scopes is not UNSET:
            field_dict["available_reauth_scopes"] = available_reauth_scopes
        if beta is not UNSET:
            field_dict["beta"] = beta
        if color is not UNSET:
            field_dict["color"] = color
        if created_at is not UNSET:
            field_dict["created_at"] = created_at
        if docs_url is not UNSET:
            field_dict["docs_url"] = docs_url
        if enabled is not UNSET:
            field_dict["enabled"] = enabled
        if icon is not UNSET:
            field_dict["icon"] = icon
        if is_assisted is not UNSET:
            field_dict["is_assisted"] = is_assisted
        if logo is not UNSET:
            field_dict["logo"] = logo
        if manual is not UNSET:
            field_dict["manual"] = manual
        if mfa_required is not UNSET:
            field_dict["mfa_required"] = mfa_required
        if name is not UNSET:
            field_dict["name"] = name
        if provider is not UNSET:
            field_dict["provider"] = provider
        if remote_id is not UNSET:
            field_dict["remote_id"] = remote_id
        if updated_at is not UNSET:
            field_dict["updated_at"] = updated_at

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        field_id = d.pop("_id", UNSET)

        _auth_method = d.pop("auth_method", UNSET)
        auth_method: FinchgoConnectSessionNewParamsIntegrationAuthMethod | Unset
        if isinstance(_auth_method, Unset):
            auth_method = UNSET
        else:
            auth_method = FinchgoConnectSessionNewParamsIntegrationAuthMethod(_auth_method)

        _available_new_scopes = d.pop("available_new_scopes", UNSET)
        available_new_scopes: list[FinchgoConnectSessionNewParamsProduct] | Unset = UNSET
        if _available_new_scopes is not UNSET:
            available_new_scopes = []
            for available_new_scopes_item_data in _available_new_scopes:
                available_new_scopes_item = FinchgoConnectSessionNewParamsProduct(available_new_scopes_item_data)

                available_new_scopes.append(available_new_scopes_item)

        _available_reauth_scopes = d.pop("available_reauth_scopes", UNSET)
        available_reauth_scopes: list[FinchgoConnectSessionReauthenticateParamsProduct] | Unset = UNSET
        if _available_reauth_scopes is not UNSET:
            available_reauth_scopes = []
            for available_reauth_scopes_item_data in _available_reauth_scopes:
                available_reauth_scopes_item = FinchgoConnectSessionReauthenticateParamsProduct(
                    available_reauth_scopes_item_data
                )

                available_reauth_scopes.append(available_reauth_scopes_item)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        types_payroll_provider = cls(
            field_id=field_id,
            auth_method=auth_method,
            available_new_scopes=available_new_scopes,
            available_reauth_scopes=available_reauth_scopes,
            beta=beta,
            color=color,
            created_at=created_at,
            docs_url=docs_url,
            enabled=enabled,
            icon=icon,
            is_assisted=is_assisted,
            logo=logo,
            manual=manual,
            mfa_required=mfa_required,
            name=name,
            provider=provider,
            remote_id=remote_id,
            updated_at=updated_at,
        )

        types_payroll_provider.additional_properties = d
        return types_payroll_provider

    @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
