add openapi-python-client generator + client
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
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
|
||||
|
||||
T = TypeVar("T", bound="SelectedPromotionCode")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class SelectedPromotionCode:
|
||||
"""Serializer for SelectedPromotionCode model
|
||||
|
||||
Attributes:
|
||||
id (int):
|
||||
basket (int):
|
||||
promotion_code (str): value of the code that users will have to enter to get the promotion
|
||||
promotion_code_id (Union[None, int]):
|
||||
name (str): name of the promotion that will be shown
|
||||
value (str): value of the code that users will have to enter to get the promotion
|
||||
"""
|
||||
|
||||
id: int
|
||||
basket: int
|
||||
promotion_code: str
|
||||
promotion_code_id: Union[None, int]
|
||||
name: str
|
||||
value: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
id = self.id
|
||||
|
||||
basket = self.basket
|
||||
|
||||
promotion_code = self.promotion_code
|
||||
|
||||
promotion_code_id: Union[None, int]
|
||||
promotion_code_id = self.promotion_code_id
|
||||
|
||||
name = self.name
|
||||
|
||||
value = self.value
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"id": id,
|
||||
"basket": basket,
|
||||
"promotion_code": promotion_code,
|
||||
"promotion_code_id": promotion_code_id,
|
||||
"name": name,
|
||||
"value": value,
|
||||
}
|
||||
)
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
||||
|
||||
files.append(("basket", (None, str(self.basket).encode(), "text/plain")))
|
||||
|
||||
files.append(("promotion_code", (None, str(self.promotion_code).encode(), "text/plain")))
|
||||
|
||||
if isinstance(self.promotion_code_id, int):
|
||||
files.append(("promotion_code_id", (None, str(self.promotion_code_id).encode(), "text/plain")))
|
||||
else:
|
||||
files.append(("promotion_code_id", (None, str(self.promotion_code_id).encode(), "text/plain")))
|
||||
|
||||
files.append(("name", (None, str(self.name).encode(), "text/plain")))
|
||||
|
||||
files.append(("value", (None, str(self.value).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")
|
||||
|
||||
basket = d.pop("basket")
|
||||
|
||||
promotion_code = d.pop("promotion_code")
|
||||
|
||||
def _parse_promotion_code_id(data: object) -> Union[None, int]:
|
||||
if data is None:
|
||||
return data
|
||||
return cast(Union[None, int], data)
|
||||
|
||||
promotion_code_id = _parse_promotion_code_id(d.pop("promotion_code_id"))
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
value = d.pop("value")
|
||||
|
||||
selected_promotion_code = cls(
|
||||
id=id,
|
||||
basket=basket,
|
||||
promotion_code=promotion_code,
|
||||
promotion_code_id=promotion_code_id,
|
||||
name=name,
|
||||
value=value,
|
||||
)
|
||||
|
||||
selected_promotion_code.additional_properties = d
|
||||
return selected_promotion_code
|
||||
|
||||
@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