363 lines
14 KiB
Python
363 lines
14 KiB
Python
import datetime
|
|
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 dateutil.parser import isoparse
|
|
|
|
from .. import types
|
|
from ..models.category_enum import CategoryEnum
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="PatchedNodeConfiguration")
|
|
|
|
|
|
@_attrs_define
|
|
class PatchedNodeConfiguration:
|
|
"""Serializer (read/write) for NodeConfiguration model
|
|
|
|
Attributes:
|
|
id (Union[Unset, int]):
|
|
description (Union[Unset, str]): description for the node. Some restricted HTML markup is allowed, everything
|
|
else is filtered out automatically.
|
|
title (Union[Unset, str]):
|
|
category (Union[Unset, CategoryEnum]): * `ticket` - Ticket
|
|
* `item` - Item
|
|
* `activity` - Activity
|
|
* `accomodation` - Accomodation
|
|
* `type` - Type
|
|
* `group` - Group
|
|
image (Union[None, Unset, int]):
|
|
image_style (Union[Unset, Any]):
|
|
item_style (Union[Unset, Any]):
|
|
display_price_difference (Union[Unset, bool]):
|
|
display_limits_difference (Union[Unset, bool]):
|
|
is_title_displayable (Union[Unset, bool]):
|
|
is_image_displayable (Union[Unset, bool]):
|
|
is_description_displayable (Union[Unset, bool]):
|
|
is_tags_displayable (Union[Unset, bool]):
|
|
starts_at (Union[None, Unset, datetime.datetime]): Optional start datetime for this node. For display only.
|
|
ends_at (Union[None, Unset, datetime.datetime]): Optional end datetime for this node. For display only.
|
|
is_subject_to_lausanne_tax (Union[Unset, bool]):
|
|
event (Union[Unset, int]):
|
|
event_id (Union[Unset, int]):
|
|
"""
|
|
|
|
id: Union[Unset, int] = UNSET
|
|
description: Union[Unset, str] = UNSET
|
|
title: Union[Unset, str] = UNSET
|
|
category: Union[Unset, CategoryEnum] = UNSET
|
|
image: Union[None, Unset, int] = UNSET
|
|
image_style: Union[Unset, Any] = UNSET
|
|
item_style: Union[Unset, Any] = UNSET
|
|
display_price_difference: Union[Unset, bool] = UNSET
|
|
display_limits_difference: Union[Unset, bool] = UNSET
|
|
is_title_displayable: Union[Unset, bool] = UNSET
|
|
is_image_displayable: Union[Unset, bool] = UNSET
|
|
is_description_displayable: Union[Unset, bool] = UNSET
|
|
is_tags_displayable: Union[Unset, bool] = UNSET
|
|
starts_at: Union[None, Unset, datetime.datetime] = UNSET
|
|
ends_at: Union[None, Unset, datetime.datetime] = UNSET
|
|
is_subject_to_lausanne_tax: Union[Unset, bool] = 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
|
|
|
|
description = self.description
|
|
|
|
title = self.title
|
|
|
|
category: Union[Unset, str] = UNSET
|
|
if not isinstance(self.category, Unset):
|
|
category = self.category.value
|
|
|
|
image: Union[None, Unset, int]
|
|
if isinstance(self.image, Unset):
|
|
image = UNSET
|
|
else:
|
|
image = self.image
|
|
|
|
image_style = self.image_style
|
|
|
|
item_style = self.item_style
|
|
|
|
display_price_difference = self.display_price_difference
|
|
|
|
display_limits_difference = self.display_limits_difference
|
|
|
|
is_title_displayable = self.is_title_displayable
|
|
|
|
is_image_displayable = self.is_image_displayable
|
|
|
|
is_description_displayable = self.is_description_displayable
|
|
|
|
is_tags_displayable = self.is_tags_displayable
|
|
|
|
starts_at: Union[None, Unset, str]
|
|
if isinstance(self.starts_at, Unset):
|
|
starts_at = UNSET
|
|
elif isinstance(self.starts_at, datetime.datetime):
|
|
starts_at = self.starts_at.isoformat()
|
|
else:
|
|
starts_at = self.starts_at
|
|
|
|
ends_at: Union[None, Unset, str]
|
|
if isinstance(self.ends_at, Unset):
|
|
ends_at = UNSET
|
|
elif isinstance(self.ends_at, datetime.datetime):
|
|
ends_at = self.ends_at.isoformat()
|
|
else:
|
|
ends_at = self.ends_at
|
|
|
|
is_subject_to_lausanne_tax = self.is_subject_to_lausanne_tax
|
|
|
|
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 description is not UNSET:
|
|
field_dict["description"] = description
|
|
if title is not UNSET:
|
|
field_dict["title"] = title
|
|
if category is not UNSET:
|
|
field_dict["category"] = category
|
|
if image is not UNSET:
|
|
field_dict["image"] = image
|
|
if image_style is not UNSET:
|
|
field_dict["image_style"] = image_style
|
|
if item_style is not UNSET:
|
|
field_dict["item_style"] = item_style
|
|
if display_price_difference is not UNSET:
|
|
field_dict["display_price_difference"] = display_price_difference
|
|
if display_limits_difference is not UNSET:
|
|
field_dict["display_limits_difference"] = display_limits_difference
|
|
if is_title_displayable is not UNSET:
|
|
field_dict["is_title_displayable"] = is_title_displayable
|
|
if is_image_displayable is not UNSET:
|
|
field_dict["is_image_displayable"] = is_image_displayable
|
|
if is_description_displayable is not UNSET:
|
|
field_dict["is_description_displayable"] = is_description_displayable
|
|
if is_tags_displayable is not UNSET:
|
|
field_dict["is_tags_displayable"] = is_tags_displayable
|
|
if starts_at is not UNSET:
|
|
field_dict["starts_at"] = starts_at
|
|
if ends_at is not UNSET:
|
|
field_dict["ends_at"] = ends_at
|
|
if is_subject_to_lausanne_tax is not UNSET:
|
|
field_dict["is_subject_to_lausanne_tax"] = is_subject_to_lausanne_tax
|
|
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.description, Unset):
|
|
files.append(("description", (None, str(self.description).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.title, Unset):
|
|
files.append(("title", (None, str(self.title).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.category, Unset):
|
|
files.append(("category", (None, str(self.category.value).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.image, Unset):
|
|
if isinstance(self.image, int):
|
|
files.append(("image", (None, str(self.image).encode(), "text/plain")))
|
|
else:
|
|
files.append(("image", (None, str(self.image).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.image_style, Unset):
|
|
files.append(("image_style", (None, str(self.image_style).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.item_style, Unset):
|
|
files.append(("item_style", (None, str(self.item_style).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.display_price_difference, Unset):
|
|
files.append(
|
|
("display_price_difference", (None, str(self.display_price_difference).encode(), "text/plain"))
|
|
)
|
|
|
|
if not isinstance(self.display_limits_difference, Unset):
|
|
files.append(
|
|
("display_limits_difference", (None, str(self.display_limits_difference).encode(), "text/plain"))
|
|
)
|
|
|
|
if not isinstance(self.is_title_displayable, Unset):
|
|
files.append(("is_title_displayable", (None, str(self.is_title_displayable).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.is_image_displayable, Unset):
|
|
files.append(("is_image_displayable", (None, str(self.is_image_displayable).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.is_description_displayable, Unset):
|
|
files.append(
|
|
("is_description_displayable", (None, str(self.is_description_displayable).encode(), "text/plain"))
|
|
)
|
|
|
|
if not isinstance(self.is_tags_displayable, Unset):
|
|
files.append(("is_tags_displayable", (None, str(self.is_tags_displayable).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.starts_at, Unset):
|
|
if isinstance(self.starts_at, datetime.datetime):
|
|
files.append(("starts_at", (None, self.starts_at.isoformat().encode(), "text/plain")))
|
|
else:
|
|
files.append(("starts_at", (None, str(self.starts_at).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.ends_at, Unset):
|
|
if isinstance(self.ends_at, datetime.datetime):
|
|
files.append(("ends_at", (None, self.ends_at.isoformat().encode(), "text/plain")))
|
|
else:
|
|
files.append(("ends_at", (None, str(self.ends_at).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.is_subject_to_lausanne_tax, Unset):
|
|
files.append(
|
|
("is_subject_to_lausanne_tax", (None, str(self.is_subject_to_lausanne_tax).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)
|
|
|
|
description = d.pop("description", UNSET)
|
|
|
|
title = d.pop("title", UNSET)
|
|
|
|
_category = d.pop("category", UNSET)
|
|
category: Union[Unset, CategoryEnum]
|
|
if isinstance(_category, Unset):
|
|
category = UNSET
|
|
else:
|
|
category = CategoryEnum(_category)
|
|
|
|
def _parse_image(data: object) -> Union[None, Unset, int]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, int], data)
|
|
|
|
image = _parse_image(d.pop("image", UNSET))
|
|
|
|
image_style = d.pop("image_style", UNSET)
|
|
|
|
item_style = d.pop("item_style", UNSET)
|
|
|
|
display_price_difference = d.pop("display_price_difference", UNSET)
|
|
|
|
display_limits_difference = d.pop("display_limits_difference", UNSET)
|
|
|
|
is_title_displayable = d.pop("is_title_displayable", UNSET)
|
|
|
|
is_image_displayable = d.pop("is_image_displayable", UNSET)
|
|
|
|
is_description_displayable = d.pop("is_description_displayable", UNSET)
|
|
|
|
is_tags_displayable = d.pop("is_tags_displayable", UNSET)
|
|
|
|
def _parse_starts_at(data: object) -> Union[None, Unset, datetime.datetime]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
try:
|
|
if not isinstance(data, str):
|
|
raise TypeError()
|
|
starts_at_type_0 = isoparse(data)
|
|
|
|
return starts_at_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union[None, Unset, datetime.datetime], data)
|
|
|
|
starts_at = _parse_starts_at(d.pop("starts_at", UNSET))
|
|
|
|
def _parse_ends_at(data: object) -> Union[None, Unset, datetime.datetime]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
try:
|
|
if not isinstance(data, str):
|
|
raise TypeError()
|
|
ends_at_type_0 = isoparse(data)
|
|
|
|
return ends_at_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union[None, Unset, datetime.datetime], data)
|
|
|
|
ends_at = _parse_ends_at(d.pop("ends_at", UNSET))
|
|
|
|
is_subject_to_lausanne_tax = d.pop("is_subject_to_lausanne_tax", UNSET)
|
|
|
|
event = d.pop("event", UNSET)
|
|
|
|
event_id = d.pop("event_id", UNSET)
|
|
|
|
patched_node_configuration = cls(
|
|
id=id,
|
|
description=description,
|
|
title=title,
|
|
category=category,
|
|
image=image,
|
|
image_style=image_style,
|
|
item_style=item_style,
|
|
display_price_difference=display_price_difference,
|
|
display_limits_difference=display_limits_difference,
|
|
is_title_displayable=is_title_displayable,
|
|
is_image_displayable=is_image_displayable,
|
|
is_description_displayable=is_description_displayable,
|
|
is_tags_displayable=is_tags_displayable,
|
|
starts_at=starts_at,
|
|
ends_at=ends_at,
|
|
is_subject_to_lausanne_tax=is_subject_to_lausanne_tax,
|
|
event=event,
|
|
event_id=event_id,
|
|
)
|
|
|
|
patched_node_configuration.additional_properties = d
|
|
return patched_node_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
|