258 lines
7.9 KiB
Python
258 lines
7.9 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 ..models.model_form_line_type import ModelFormLineType
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="NodeExtraInfo")
|
|
|
|
|
|
@_attrs_define
|
|
class NodeExtraInfo:
|
|
"""Serializer (read/write) for `NodeExtraInfo` model
|
|
|
|
Attributes:
|
|
id (int):
|
|
group_id (int):
|
|
order (int):
|
|
type_ (ModelFormLineType): * `text` - Simple text
|
|
* `email` - Email
|
|
* `phone` - Phone
|
|
* `country` - Country
|
|
* `numerical` - Numerical
|
|
* `textarea` - Multi-line text input
|
|
* `boolean` - Boolean
|
|
* `datetime` - Datetime
|
|
* `date` - Date
|
|
* `date_major` - Birthdate with majority required
|
|
* `choice` - Choice
|
|
* `file` - File
|
|
name (str):
|
|
text (str):
|
|
event (int):
|
|
event_id (int):
|
|
help_text (Union[Unset, str]):
|
|
is_required (Union[Unset, bool]):
|
|
choices_json (Union[None, Unset, str]):
|
|
major_json (Union[None, Unset, str]):
|
|
range_json (Union[None, Unset, str]):
|
|
"""
|
|
|
|
id: int
|
|
group_id: int
|
|
order: int
|
|
type_: ModelFormLineType
|
|
name: str
|
|
text: str
|
|
event: int
|
|
event_id: int
|
|
help_text: Union[Unset, str] = UNSET
|
|
is_required: Union[Unset, bool] = UNSET
|
|
choices_json: Union[None, Unset, str] = UNSET
|
|
major_json: Union[None, Unset, str] = UNSET
|
|
range_json: Union[None, Unset, str] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
id = self.id
|
|
|
|
group_id = self.group_id
|
|
|
|
order = self.order
|
|
|
|
type_ = self.type_.value
|
|
|
|
name = self.name
|
|
|
|
text = self.text
|
|
|
|
event = self.event
|
|
|
|
event_id = self.event_id
|
|
|
|
help_text = self.help_text
|
|
|
|
is_required = self.is_required
|
|
|
|
choices_json: Union[None, Unset, str]
|
|
if isinstance(self.choices_json, Unset):
|
|
choices_json = UNSET
|
|
else:
|
|
choices_json = self.choices_json
|
|
|
|
major_json: Union[None, Unset, str]
|
|
if isinstance(self.major_json, Unset):
|
|
major_json = UNSET
|
|
else:
|
|
major_json = self.major_json
|
|
|
|
range_json: Union[None, Unset, str]
|
|
if isinstance(self.range_json, Unset):
|
|
range_json = UNSET
|
|
else:
|
|
range_json = self.range_json
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"id": id,
|
|
"group_id": group_id,
|
|
"order": order,
|
|
"type": type_,
|
|
"name": name,
|
|
"text": text,
|
|
"event": event,
|
|
"event_id": event_id,
|
|
}
|
|
)
|
|
if help_text is not UNSET:
|
|
field_dict["help_text"] = help_text
|
|
if is_required is not UNSET:
|
|
field_dict["is_required"] = is_required
|
|
if choices_json is not UNSET:
|
|
field_dict["choices_json"] = choices_json
|
|
if major_json is not UNSET:
|
|
field_dict["major_json"] = major_json
|
|
if range_json is not UNSET:
|
|
field_dict["range_json"] = range_json
|
|
|
|
return field_dict
|
|
|
|
def to_multipart(self) -> types.RequestFiles:
|
|
files: types.RequestFiles = []
|
|
|
|
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
|
|
|
files.append(("group_id", (None, str(self.group_id).encode(), "text/plain")))
|
|
|
|
files.append(("order", (None, str(self.order).encode(), "text/plain")))
|
|
|
|
files.append(("type", (None, str(self.type_.value).encode(), "text/plain")))
|
|
|
|
files.append(("name", (None, str(self.name).encode(), "text/plain")))
|
|
|
|
files.append(("text", (None, str(self.text).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.help_text, Unset):
|
|
files.append(("help_text", (None, str(self.help_text).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.is_required, Unset):
|
|
files.append(("is_required", (None, str(self.is_required).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.choices_json, Unset):
|
|
if isinstance(self.choices_json, str):
|
|
files.append(("choices_json", (None, str(self.choices_json).encode(), "text/plain")))
|
|
else:
|
|
files.append(("choices_json", (None, str(self.choices_json).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.major_json, Unset):
|
|
if isinstance(self.major_json, str):
|
|
files.append(("major_json", (None, str(self.major_json).encode(), "text/plain")))
|
|
else:
|
|
files.append(("major_json", (None, str(self.major_json).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.range_json, Unset):
|
|
if isinstance(self.range_json, str):
|
|
files.append(("range_json", (None, str(self.range_json).encode(), "text/plain")))
|
|
else:
|
|
files.append(("range_json", (None, str(self.range_json).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")
|
|
|
|
group_id = d.pop("group_id")
|
|
|
|
order = d.pop("order")
|
|
|
|
type_ = ModelFormLineType(d.pop("type"))
|
|
|
|
name = d.pop("name")
|
|
|
|
text = d.pop("text")
|
|
|
|
event = d.pop("event")
|
|
|
|
event_id = d.pop("event_id")
|
|
|
|
help_text = d.pop("help_text", UNSET)
|
|
|
|
is_required = d.pop("is_required", UNSET)
|
|
|
|
def _parse_choices_json(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
choices_json = _parse_choices_json(d.pop("choices_json", UNSET))
|
|
|
|
def _parse_major_json(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
major_json = _parse_major_json(d.pop("major_json", UNSET))
|
|
|
|
def _parse_range_json(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
range_json = _parse_range_json(d.pop("range_json", UNSET))
|
|
|
|
node_extra_info = cls(
|
|
id=id,
|
|
group_id=group_id,
|
|
order=order,
|
|
type_=type_,
|
|
name=name,
|
|
text=text,
|
|
event=event,
|
|
event_id=event_id,
|
|
help_text=help_text,
|
|
is_required=is_required,
|
|
choices_json=choices_json,
|
|
major_json=major_json,
|
|
range_json=range_json,
|
|
)
|
|
|
|
node_extra_info.additional_properties = d
|
|
return node_extra_info
|
|
|
|
@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
|