172 lines
5.7 KiB
Python
172 lines
5.7 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, Union, cast
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from .. import types
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="PatchedNode")
|
|
|
|
|
|
@_attrs_define
|
|
class PatchedNode:
|
|
"""Serializer for Node model
|
|
|
|
Attributes:
|
|
id (Union[Unset, int]):
|
|
order (Union[Unset, int]): Local order between nodes that share the same parent
|
|
parent_id (Union[Unset, int]):
|
|
internal_key (Union[Unset, str]):
|
|
configuration_id (Union[Unset, int]):
|
|
cart_configuration_id (Union[Unset, int]):
|
|
children_ids (Union[Unset, list[int]]):
|
|
event (Union[Unset, int]):
|
|
event_id (Union[Unset, int]):
|
|
"""
|
|
|
|
id: Union[Unset, int] = UNSET
|
|
order: Union[Unset, int] = UNSET
|
|
parent_id: Union[Unset, int] = UNSET
|
|
internal_key: Union[Unset, str] = UNSET
|
|
configuration_id: Union[Unset, int] = UNSET
|
|
cart_configuration_id: Union[Unset, int] = UNSET
|
|
children_ids: Union[Unset, list[int]] = UNSET
|
|
event: Union[Unset, int] = UNSET
|
|
event_id: Union[Unset, int] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
id = self.id
|
|
|
|
order = self.order
|
|
|
|
parent_id = self.parent_id
|
|
|
|
internal_key = self.internal_key
|
|
|
|
configuration_id = self.configuration_id
|
|
|
|
cart_configuration_id = self.cart_configuration_id
|
|
|
|
children_ids: Union[Unset, list[int]] = UNSET
|
|
if not isinstance(self.children_ids, Unset):
|
|
children_ids = self.children_ids
|
|
|
|
event = self.event
|
|
|
|
event_id = self.event_id
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update({})
|
|
if id is not UNSET:
|
|
field_dict["id"] = id
|
|
if order is not UNSET:
|
|
field_dict["order"] = order
|
|
if parent_id is not UNSET:
|
|
field_dict["parent_id"] = parent_id
|
|
if internal_key is not UNSET:
|
|
field_dict["internal_key"] = internal_key
|
|
if configuration_id is not UNSET:
|
|
field_dict["configuration_id"] = configuration_id
|
|
if cart_configuration_id is not UNSET:
|
|
field_dict["cart_configuration_id"] = cart_configuration_id
|
|
if children_ids is not UNSET:
|
|
field_dict["children_ids"] = children_ids
|
|
if event is not UNSET:
|
|
field_dict["event"] = event
|
|
if event_id is not UNSET:
|
|
field_dict["event_id"] = event_id
|
|
|
|
return field_dict
|
|
|
|
def to_multipart(self) -> types.RequestFiles:
|
|
files: types.RequestFiles = []
|
|
|
|
if not isinstance(self.id, Unset):
|
|
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.order, Unset):
|
|
files.append(("order", (None, str(self.order).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.parent_id, Unset):
|
|
files.append(("parent_id", (None, str(self.parent_id).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.internal_key, Unset):
|
|
files.append(("internal_key", (None, str(self.internal_key).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.configuration_id, Unset):
|
|
files.append(("configuration_id", (None, str(self.configuration_id).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.cart_configuration_id, Unset):
|
|
files.append(("cart_configuration_id", (None, str(self.cart_configuration_id).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.children_ids, Unset):
|
|
for children_ids_item_element in self.children_ids:
|
|
files.append(("children_ids", (None, str(children_ids_item_element).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.event, Unset):
|
|
files.append(("event", (None, str(self.event).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.event_id, Unset):
|
|
files.append(("event_id", (None, str(self.event_id).encode(), "text/plain")))
|
|
|
|
for prop_name, prop in self.additional_properties.items():
|
|
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
|
|
|
return files
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
d = dict(src_dict)
|
|
id = d.pop("id", UNSET)
|
|
|
|
order = d.pop("order", UNSET)
|
|
|
|
parent_id = d.pop("parent_id", UNSET)
|
|
|
|
internal_key = d.pop("internal_key", UNSET)
|
|
|
|
configuration_id = d.pop("configuration_id", UNSET)
|
|
|
|
cart_configuration_id = d.pop("cart_configuration_id", UNSET)
|
|
|
|
children_ids = cast(list[int], d.pop("children_ids", UNSET))
|
|
|
|
event = d.pop("event", UNSET)
|
|
|
|
event_id = d.pop("event_id", UNSET)
|
|
|
|
patched_node = cls(
|
|
id=id,
|
|
order=order,
|
|
parent_id=parent_id,
|
|
internal_key=internal_key,
|
|
configuration_id=configuration_id,
|
|
cart_configuration_id=cart_configuration_id,
|
|
children_ids=children_ids,
|
|
event=event,
|
|
event_id=event_id,
|
|
)
|
|
|
|
patched_node.additional_properties = d
|
|
return patched_node
|
|
|
|
@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
|