add openapi-python-client generator + client
This commit is contained in:
@@ -0,0 +1,212 @@
|
||||
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 ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="BillingInformation")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class BillingInformation:
|
||||
"""Serializer for BillingInformation model
|
||||
Requires to be logged in as a user or to provide a frontend login associated with your request
|
||||
|
||||
Attributes:
|
||||
id (int):
|
||||
email (str):
|
||||
user (Union[None, int]):
|
||||
frontendbasket_set (list[int]):
|
||||
first_name (Union[Unset, str]):
|
||||
last_name (Union[Unset, str]):
|
||||
address (Union[Unset, str]):
|
||||
postal_code (Union[Unset, str]):
|
||||
city (Union[Unset, str]):
|
||||
country (Union[Unset, str]):
|
||||
created_by (Union[None, Unset, int]):
|
||||
"""
|
||||
|
||||
id: int
|
||||
email: str
|
||||
user: Union[None, int]
|
||||
frontendbasket_set: list[int]
|
||||
first_name: Union[Unset, str] = UNSET
|
||||
last_name: Union[Unset, str] = UNSET
|
||||
address: Union[Unset, str] = UNSET
|
||||
postal_code: Union[Unset, str] = UNSET
|
||||
city: Union[Unset, str] = UNSET
|
||||
country: Union[Unset, str] = UNSET
|
||||
created_by: Union[None, Unset, int] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
id = self.id
|
||||
|
||||
email = self.email
|
||||
|
||||
user: Union[None, int]
|
||||
user = self.user
|
||||
|
||||
frontendbasket_set = self.frontendbasket_set
|
||||
|
||||
first_name = self.first_name
|
||||
|
||||
last_name = self.last_name
|
||||
|
||||
address = self.address
|
||||
|
||||
postal_code = self.postal_code
|
||||
|
||||
city = self.city
|
||||
|
||||
country = self.country
|
||||
|
||||
created_by: Union[None, Unset, int]
|
||||
if isinstance(self.created_by, Unset):
|
||||
created_by = UNSET
|
||||
else:
|
||||
created_by = self.created_by
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"id": id,
|
||||
"email": email,
|
||||
"user": user,
|
||||
"frontendbasket_set": frontendbasket_set,
|
||||
}
|
||||
)
|
||||
if first_name is not UNSET:
|
||||
field_dict["first_name"] = first_name
|
||||
if last_name is not UNSET:
|
||||
field_dict["last_name"] = last_name
|
||||
if address is not UNSET:
|
||||
field_dict["address"] = address
|
||||
if postal_code is not UNSET:
|
||||
field_dict["postal_code"] = postal_code
|
||||
if city is not UNSET:
|
||||
field_dict["city"] = city
|
||||
if country is not UNSET:
|
||||
field_dict["country"] = country
|
||||
if created_by is not UNSET:
|
||||
field_dict["created_by"] = created_by
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
||||
|
||||
files.append(("email", (None, str(self.email).encode(), "text/plain")))
|
||||
|
||||
if isinstance(self.user, int):
|
||||
files.append(("user", (None, str(self.user).encode(), "text/plain")))
|
||||
else:
|
||||
files.append(("user", (None, str(self.user).encode(), "text/plain")))
|
||||
|
||||
for frontendbasket_set_item_element in self.frontendbasket_set:
|
||||
files.append(("frontendbasket_set", (None, str(frontendbasket_set_item_element).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.first_name, Unset):
|
||||
files.append(("first_name", (None, str(self.first_name).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.last_name, Unset):
|
||||
files.append(("last_name", (None, str(self.last_name).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.address, Unset):
|
||||
files.append(("address", (None, str(self.address).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.postal_code, Unset):
|
||||
files.append(("postal_code", (None, str(self.postal_code).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.city, Unset):
|
||||
files.append(("city", (None, str(self.city).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.country, Unset):
|
||||
files.append(("country", (None, str(self.country).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.created_by, Unset):
|
||||
if isinstance(self.created_by, int):
|
||||
files.append(("created_by", (None, str(self.created_by).encode(), "text/plain")))
|
||||
else:
|
||||
files.append(("created_by", (None, str(self.created_by).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")
|
||||
|
||||
email = d.pop("email")
|
||||
|
||||
def _parse_user(data: object) -> Union[None, int]:
|
||||
if data is None:
|
||||
return data
|
||||
return cast(Union[None, int], data)
|
||||
|
||||
user = _parse_user(d.pop("user"))
|
||||
|
||||
frontendbasket_set = cast(list[int], d.pop("frontendbasket_set"))
|
||||
|
||||
first_name = d.pop("first_name", UNSET)
|
||||
|
||||
last_name = d.pop("last_name", UNSET)
|
||||
|
||||
address = d.pop("address", UNSET)
|
||||
|
||||
postal_code = d.pop("postal_code", UNSET)
|
||||
|
||||
city = d.pop("city", UNSET)
|
||||
|
||||
country = d.pop("country", UNSET)
|
||||
|
||||
def _parse_created_by(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)
|
||||
|
||||
created_by = _parse_created_by(d.pop("created_by", UNSET))
|
||||
|
||||
billing_information = cls(
|
||||
id=id,
|
||||
email=email,
|
||||
user=user,
|
||||
frontendbasket_set=frontendbasket_set,
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
address=address,
|
||||
postal_code=postal_code,
|
||||
city=city,
|
||||
country=country,
|
||||
created_by=created_by,
|
||||
)
|
||||
|
||||
billing_information.additional_properties = d
|
||||
return billing_information
|
||||
|
||||
@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