|
| 1 | +from typing import Any, Dict, List, Type, TypeVar, Union |
| 2 | + |
| 3 | +import attr |
| 4 | + |
| 5 | +from ..types import UNSET, Unset |
| 6 | + |
| 7 | +T = TypeVar("T", bound="AFormData") |
| 8 | + |
| 9 | + |
| 10 | +@attr.s(auto_attribs=True) |
| 11 | +class AFormData: |
| 12 | + """ """ |
| 13 | + |
| 14 | + an_required_field: str |
| 15 | + an_optional_field: Union[Unset, str] = UNSET |
| 16 | + additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) |
| 17 | + |
| 18 | + def to_dict(self) -> Dict[str, Any]: |
| 19 | + an_required_field = self.an_required_field |
| 20 | + an_optional_field = self.an_optional_field |
| 21 | + |
| 22 | + field_dict: Dict[str, Any] = {} |
| 23 | + field_dict.update(self.additional_properties) |
| 24 | + field_dict.update( |
| 25 | + { |
| 26 | + "an_required_field": an_required_field, |
| 27 | + } |
| 28 | + ) |
| 29 | + if an_optional_field is not UNSET: |
| 30 | + field_dict["an_optional_field"] = an_optional_field |
| 31 | + |
| 32 | + return field_dict |
| 33 | + |
| 34 | + @classmethod |
| 35 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 36 | + d = src_dict.copy() |
| 37 | + an_required_field = d.pop("an_required_field") |
| 38 | + |
| 39 | + an_optional_field = d.pop("an_optional_field", UNSET) |
| 40 | + |
| 41 | + a_form_data = cls( |
| 42 | + an_required_field=an_required_field, |
| 43 | + an_optional_field=an_optional_field, |
| 44 | + ) |
| 45 | + |
| 46 | + a_form_data.additional_properties = d |
| 47 | + return a_form_data |
| 48 | + |
| 49 | + @property |
| 50 | + def additional_keys(self) -> List[str]: |
| 51 | + return list(self.additional_properties.keys()) |
| 52 | + |
| 53 | + def __getitem__(self, key: str) -> Any: |
| 54 | + return self.additional_properties[key] |
| 55 | + |
| 56 | + def __setitem__(self, key: str, value: Any) -> None: |
| 57 | + self.additional_properties[key] = value |
| 58 | + |
| 59 | + def __delitem__(self, key: str) -> None: |
| 60 | + del self.additional_properties[key] |
| 61 | + |
| 62 | + def __contains__(self, key: str) -> bool: |
| 63 | + return key in self.additional_properties |
0 commit comments