113 lines
3 KiB
Python
113 lines
3 KiB
Python
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
|
|
|
|
if TYPE_CHECKING:
|
|
from ..models.user_recipient import UserRecipient
|
|
|
|
|
|
T = TypeVar("T", bound="UserPlan")
|
|
|
|
|
|
@_attrs_define
|
|
class UserPlan:
|
|
"""
|
|
Attributes:
|
|
title (str):
|
|
banner (None | str):
|
|
description (str):
|
|
description_details (Any):
|
|
recipients (list[UserRecipient]):
|
|
"""
|
|
|
|
title: str
|
|
banner: None | str
|
|
description: str
|
|
description_details: Any
|
|
recipients: list[UserRecipient]
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
title = self.title
|
|
|
|
banner: None | str
|
|
banner = self.banner
|
|
|
|
description = self.description
|
|
|
|
description_details = self.description_details
|
|
|
|
recipients = []
|
|
for recipients_item_data in self.recipients:
|
|
recipients_item = recipients_item_data.to_dict()
|
|
recipients.append(recipients_item)
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"title": title,
|
|
"banner": banner,
|
|
"description": description,
|
|
"description_details": description_details,
|
|
"recipients": recipients,
|
|
}
|
|
)
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from ..models.user_recipient import UserRecipient
|
|
|
|
d = dict(src_dict)
|
|
title = d.pop("title")
|
|
|
|
def _parse_banner(data: object) -> None | str:
|
|
if data is None:
|
|
return data
|
|
return cast(None | str, data)
|
|
|
|
banner = _parse_banner(d.pop("banner"))
|
|
|
|
description = d.pop("description")
|
|
|
|
description_details = d.pop("description_details")
|
|
|
|
recipients = []
|
|
_recipients = d.pop("recipients")
|
|
for recipients_item_data in _recipients:
|
|
recipients_item = UserRecipient.from_dict(recipients_item_data)
|
|
|
|
recipients.append(recipients_item)
|
|
|
|
user_plan = cls(
|
|
title=title,
|
|
banner=banner,
|
|
description=description,
|
|
description_details=description_details,
|
|
recipients=recipients,
|
|
)
|
|
|
|
user_plan.additional_properties = d
|
|
return user_plan
|
|
|
|
@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
|