polyticket-api/poly-ticket-api-client/poly_ticket_api_client/models/node_cart_configuration.py

130 lines
3.6 KiB
Python

from collections.abc import Mapping
from typing import Any, TypeVar, Union
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="NodeCartConfiguration")
@_attrs_define
class NodeCartConfiguration:
"""Serializer (read/write) for NodeCartConfiguration model
Attributes:
id (int):
event (int):
event_id (int):
weight (Union[Unset, int]):
range_min (Union[Unset, int]):
range_max (Union[Unset, int]):
"""
id: int
event: int
event_id: int
weight: Union[Unset, int] = UNSET
range_min: Union[Unset, int] = UNSET
range_max: 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
event = self.event
event_id = self.event_id
weight = self.weight
range_min = self.range_min
range_max = self.range_max
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"id": id,
"event": event,
"event_id": event_id,
}
)
if weight is not UNSET:
field_dict["weight"] = weight
if range_min is not UNSET:
field_dict["range_min"] = range_min
if range_max is not UNSET:
field_dict["range_max"] = range_max
return field_dict
def to_multipart(self) -> types.RequestFiles:
files: types.RequestFiles = []
files.append(("id", (None, str(self.id).encode(), "text/plain")))
files.append(("event", (None, str(self.event).encode(), "text/plain")))
files.append(("event_id", (None, str(self.event_id).encode(), "text/plain")))
if not isinstance(self.weight, Unset):
files.append(("weight", (None, str(self.weight).encode(), "text/plain")))
if not isinstance(self.range_min, Unset):
files.append(("range_min", (None, str(self.range_min).encode(), "text/plain")))
if not isinstance(self.range_max, Unset):
files.append(("range_max", (None, str(self.range_max).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")
event = d.pop("event")
event_id = d.pop("event_id")
weight = d.pop("weight", UNSET)
range_min = d.pop("range_min", UNSET)
range_max = d.pop("range_max", UNSET)
node_cart_configuration = cls(
id=id,
event=event,
event_id=event_id,
weight=weight,
range_min=range_min,
range_max=range_max,
)
node_cart_configuration.additional_properties = d
return node_cart_configuration
@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