from __future__ import annotations

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

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

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.pkg_routes_webhooks_finch_webhook_data import PkgRoutesWebhooksFinchWebhookData


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


@_attrs_define
class PkgRoutesWebhooksFinchWebhookRequest:
    """
    Attributes:
        account_id (str | Unset):
        company_id (str | Unset):
        connection_id (str | Unset):
        data (PkgRoutesWebhooksFinchWebhookData | Unset):
        event_type (str | Unset):
    """

    account_id: str | Unset = UNSET
    company_id: str | Unset = UNSET
    connection_id: str | Unset = UNSET
    data: PkgRoutesWebhooksFinchWebhookData | Unset = UNSET
    event_type: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        company_id = self.company_id

        connection_id = self.connection_id

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

        event_type = self.event_type

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if account_id is not UNSET:
            field_dict["account_id"] = account_id
        if company_id is not UNSET:
            field_dict["company_id"] = company_id
        if connection_id is not UNSET:
            field_dict["connection_id"] = connection_id
        if data is not UNSET:
            field_dict["data"] = data
        if event_type is not UNSET:
            field_dict["event_type"] = event_type

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.pkg_routes_webhooks_finch_webhook_data import PkgRoutesWebhooksFinchWebhookData

        d = dict(src_dict)
        account_id = d.pop("account_id", UNSET)

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

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

        _data = d.pop("data", UNSET)
        data: PkgRoutesWebhooksFinchWebhookData | Unset
        if isinstance(_data, Unset):
            data = UNSET
        else:
            data = PkgRoutesWebhooksFinchWebhookData.from_dict(_data)

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

        pkg_routes_webhooks_finch_webhook_request = cls(
            account_id=account_id,
            company_id=company_id,
            connection_id=connection_id,
            data=data,
            event_type=event_type,
        )

        pkg_routes_webhooks_finch_webhook_request.additional_properties = d
        return pkg_routes_webhooks_finch_webhook_request

    @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
