from collections.abc import Mapping
from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator

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

from ..types import UNSET, Unset

from ..types import UNSET, Unset
from typing import cast
from typing import cast, Union
from typing import Union

if TYPE_CHECKING:
  from ..models.get_current_profiles_in_saved_search_response_200_output_profiles_item import GetCurrentProfilesInSavedSearchResponse200OutputProfilesItem





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



@_attrs_define
class GetCurrentProfilesInSavedSearchResponse200Output:
    """ 
        Attributes:
            profiles (list['GetCurrentProfilesInSavedSearchResponse200OutputProfilesItem']): The profiles found for the
                saved search by movement type
            next_cursor (Union[None, Unset, str]): The next cursor
            last_run_completed_at (Union[None, Unset, str]): The date and time the last run completed
     """

    profiles: list['GetCurrentProfilesInSavedSearchResponse200OutputProfilesItem']
    next_cursor: Union[None, Unset, str] = UNSET
    last_run_completed_at: Union[None, Unset, str] = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)





    def to_dict(self) -> dict[str, Any]:
        from ..models.get_current_profiles_in_saved_search_response_200_output_profiles_item import GetCurrentProfilesInSavedSearchResponse200OutputProfilesItem
        profiles = []
        for profiles_item_data in self.profiles:
            profiles_item = profiles_item_data.to_dict()
            profiles.append(profiles_item)



        next_cursor: Union[None, Unset, str]
        if isinstance(self.next_cursor, Unset):
            next_cursor = UNSET
        else:
            next_cursor = self.next_cursor

        last_run_completed_at: Union[None, Unset, str]
        if isinstance(self.last_run_completed_at, Unset):
            last_run_completed_at = UNSET
        else:
            last_run_completed_at = self.last_run_completed_at


        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({
            "profiles": profiles,
        })
        if next_cursor is not UNSET:
            field_dict["nextCursor"] = next_cursor
        if last_run_completed_at is not UNSET:
            field_dict["lastRunCompletedAt"] = last_run_completed_at

        return field_dict



    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.get_current_profiles_in_saved_search_response_200_output_profiles_item import GetCurrentProfilesInSavedSearchResponse200OutputProfilesItem
        d = dict(src_dict)
        profiles = []
        _profiles = d.pop("profiles")
        for profiles_item_data in (_profiles):
            profiles_item = GetCurrentProfilesInSavedSearchResponse200OutputProfilesItem.from_dict(profiles_item_data)



            profiles.append(profiles_item)


        def _parse_next_cursor(data: object) -> Union[None, Unset, str]:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(Union[None, Unset, str], data)

        next_cursor = _parse_next_cursor(d.pop("nextCursor", UNSET))


        def _parse_last_run_completed_at(data: object) -> Union[None, Unset, str]:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(Union[None, Unset, str], data)

        last_run_completed_at = _parse_last_run_completed_at(d.pop("lastRunCompletedAt", UNSET))


        get_current_profiles_in_saved_search_response_200_output = cls(
            profiles=profiles,
            next_cursor=next_cursor,
            last_run_completed_at=last_run_completed_at,
        )


        get_current_profiles_in_saved_search_response_200_output.additional_properties = d
        return get_current_profiles_in_saved_search_response_200_output

    @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
