add openapi-python-client generator + client
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
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
|
||||
|
||||
T = TypeVar("T", bound="EventPublicInfos")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class EventPublicInfos:
|
||||
"""Serializer for the public infos endpoint
|
||||
|
||||
Attributes:
|
||||
id (int):
|
||||
are_registrations_allowed (bool):
|
||||
are_payments_allowed (bool):
|
||||
welcome_text (str): Welcome text displayed on the Ticket Office event page
|
||||
frontend_url (str): External url provided by the organizer. I.e. their website or social media page
|
||||
frontend_title (str): Main name of the event shown to end users. I.e. shown on the Ticket Office webpage
|
||||
frontend_organizers (str): Name of the organizer, displayed on the Ticket Office event page
|
||||
description_header_image (Union[None, int]):
|
||||
start_date (Union[None, datetime.datetime]):
|
||||
end_date (Union[None, datetime.datetime]):
|
||||
location_text (str):
|
||||
location (Union[None, str]):
|
||||
location_address (str):
|
||||
is_basket_item_modification_allowed (bool): This field informs the front end on what actions should be allowed
|
||||
or prevented, in the front end only.
|
||||
is_status_public (bool):
|
||||
"""
|
||||
|
||||
id: int
|
||||
are_registrations_allowed: bool
|
||||
are_payments_allowed: bool
|
||||
welcome_text: str
|
||||
frontend_url: str
|
||||
frontend_title: str
|
||||
frontend_organizers: str
|
||||
description_header_image: Union[None, int]
|
||||
start_date: Union[None, datetime.datetime]
|
||||
end_date: Union[None, datetime.datetime]
|
||||
location_text: str
|
||||
location: Union[None, str]
|
||||
location_address: str
|
||||
is_basket_item_modification_allowed: bool
|
||||
is_status_public: bool
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
id = self.id
|
||||
|
||||
are_registrations_allowed = self.are_registrations_allowed
|
||||
|
||||
are_payments_allowed = self.are_payments_allowed
|
||||
|
||||
welcome_text = self.welcome_text
|
||||
|
||||
frontend_url = self.frontend_url
|
||||
|
||||
frontend_title = self.frontend_title
|
||||
|
||||
frontend_organizers = self.frontend_organizers
|
||||
|
||||
description_header_image: Union[None, int]
|
||||
description_header_image = self.description_header_image
|
||||
|
||||
start_date: Union[None, str]
|
||||
if isinstance(self.start_date, datetime.datetime):
|
||||
start_date = self.start_date.isoformat()
|
||||
else:
|
||||
start_date = self.start_date
|
||||
|
||||
end_date: Union[None, str]
|
||||
if isinstance(self.end_date, datetime.datetime):
|
||||
end_date = self.end_date.isoformat()
|
||||
else:
|
||||
end_date = self.end_date
|
||||
|
||||
location_text = self.location_text
|
||||
|
||||
location: Union[None, str]
|
||||
location = self.location
|
||||
|
||||
location_address = self.location_address
|
||||
|
||||
is_basket_item_modification_allowed = self.is_basket_item_modification_allowed
|
||||
|
||||
is_status_public = self.is_status_public
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"id": id,
|
||||
"are_registrations_allowed": are_registrations_allowed,
|
||||
"are_payments_allowed": are_payments_allowed,
|
||||
"welcome_text": welcome_text,
|
||||
"frontend_url": frontend_url,
|
||||
"frontend_title": frontend_title,
|
||||
"frontend_organizers": frontend_organizers,
|
||||
"description_header_image": description_header_image,
|
||||
"start_date": start_date,
|
||||
"end_date": end_date,
|
||||
"location_text": location_text,
|
||||
"location": location,
|
||||
"location_address": location_address,
|
||||
"is_basket_item_modification_allowed": is_basket_item_modification_allowed,
|
||||
"is_status_public": is_status_public,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
id = d.pop("id")
|
||||
|
||||
are_registrations_allowed = d.pop("are_registrations_allowed")
|
||||
|
||||
are_payments_allowed = d.pop("are_payments_allowed")
|
||||
|
||||
welcome_text = d.pop("welcome_text")
|
||||
|
||||
frontend_url = d.pop("frontend_url")
|
||||
|
||||
frontend_title = d.pop("frontend_title")
|
||||
|
||||
frontend_organizers = d.pop("frontend_organizers")
|
||||
|
||||
def _parse_description_header_image(data: object) -> Union[None, int]:
|
||||
if data is None:
|
||||
return data
|
||||
return cast(Union[None, int], data)
|
||||
|
||||
description_header_image = _parse_description_header_image(d.pop("description_header_image"))
|
||||
|
||||
def _parse_start_date(data: object) -> Union[None, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
start_date_type_0 = isoparse(data)
|
||||
|
||||
return start_date_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, datetime.datetime], data)
|
||||
|
||||
start_date = _parse_start_date(d.pop("start_date"))
|
||||
|
||||
def _parse_end_date(data: object) -> Union[None, datetime.datetime]:
|
||||
if data is None:
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
end_date_type_0 = isoparse(data)
|
||||
|
||||
return end_date_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, datetime.datetime], data)
|
||||
|
||||
end_date = _parse_end_date(d.pop("end_date"))
|
||||
|
||||
location_text = d.pop("location_text")
|
||||
|
||||
def _parse_location(data: object) -> Union[None, str]:
|
||||
if data is None:
|
||||
return data
|
||||
return cast(Union[None, str], data)
|
||||
|
||||
location = _parse_location(d.pop("location"))
|
||||
|
||||
location_address = d.pop("location_address")
|
||||
|
||||
is_basket_item_modification_allowed = d.pop("is_basket_item_modification_allowed")
|
||||
|
||||
is_status_public = d.pop("is_status_public")
|
||||
|
||||
event_public_infos = cls(
|
||||
id=id,
|
||||
are_registrations_allowed=are_registrations_allowed,
|
||||
are_payments_allowed=are_payments_allowed,
|
||||
welcome_text=welcome_text,
|
||||
frontend_url=frontend_url,
|
||||
frontend_title=frontend_title,
|
||||
frontend_organizers=frontend_organizers,
|
||||
description_header_image=description_header_image,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
location_text=location_text,
|
||||
location=location,
|
||||
location_address=location_address,
|
||||
is_basket_item_modification_allowed=is_basket_item_modification_allowed,
|
||||
is_status_public=is_status_public,
|
||||
)
|
||||
|
||||
event_public_infos.additional_properties = d
|
||||
return event_public_infos
|
||||
|
||||
@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
|
||||
Reference in New Issue
Block a user