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 ..types import UNSET, Unset

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


@_attrs_define
class TypesDemoSession:
    """
    Attributes:
        field_id (str | Unset):
        accessed_at (str | Unset):
        campaign_id (str | Unset):
        campaign_type (str | Unset):
        company (str | Unset):
        converted_at (str | Unset):
        email (str | Unset):
        ip (str | Unset):
        name (str | Unset):
        url (str | Unset):
    """

    field_id: str | Unset = UNSET
    accessed_at: str | Unset = UNSET
    campaign_id: str | Unset = UNSET
    campaign_type: str | Unset = UNSET
    company: str | Unset = UNSET
    converted_at: str | Unset = UNSET
    email: str | Unset = UNSET
    ip: str | Unset = UNSET
    name: str | Unset = UNSET
    url: 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

        accessed_at = self.accessed_at

        campaign_id = self.campaign_id

        campaign_type = self.campaign_type

        company = self.company

        converted_at = self.converted_at

        email = self.email

        ip = self.ip

        name = self.name

        url = self.url

        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 accessed_at is not UNSET:
            field_dict["accessed_at"] = accessed_at
        if campaign_id is not UNSET:
            field_dict["campaign_id"] = campaign_id
        if campaign_type is not UNSET:
            field_dict["campaign_type"] = campaign_type
        if company is not UNSET:
            field_dict["company"] = company
        if converted_at is not UNSET:
            field_dict["converted_at"] = converted_at
        if email is not UNSET:
            field_dict["email"] = email
        if ip is not UNSET:
            field_dict["ip"] = ip
        if name is not UNSET:
            field_dict["name"] = name
        if url is not UNSET:
            field_dict["url"] = url

        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)

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

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

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

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

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

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

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

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

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

        types_demo_session = cls(
            field_id=field_id,
            accessed_at=accessed_at,
            campaign_id=campaign_id,
            campaign_type=campaign_type,
            company=company,
            converted_at=converted_at,
            email=email,
            ip=ip,
            name=name,
            url=url,
        )

        types_demo_session.additional_properties = d
        return types_demo_session

    @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
