switch to pydantic

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2023-11-28 23:50:50 -08:00
parent d9d73522fd
commit bc3d698539
230 changed files with 4467 additions and 25280 deletions

View File

@ -1,80 +1,16 @@
from typing import Any, Dict, List, Type, TypeVar, Union, cast
from typing import Optional
import attr
from pydantic import BaseModel
from pydantic_extra_types.phone_number import PhoneNumber
from ..models.new_address import NewAddress
from ..types import UNSET, Unset
LT = TypeVar("LT", bound="BillingInfo")
@attr.s(auto_attribs=True)
class BillingInfo:
"""The billing information for payments.""" # noqa: E501
class BillingInfo(BaseModel):
"""The billing information for payments."""
address: Union[Unset, NewAddress] = UNSET
name: Union[Unset, str] = UNSET
phone: Union[Unset, str] = UNSET
address: Optional[NewAddress] = None
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
name: Optional[str] = None
def to_dict(self) -> Dict[str, Any]:
address: Union[Unset, NewAddress] = UNSET
if not isinstance(self.address, Unset):
address = self.address
name = self.name
phone = self.phone
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if address is not UNSET:
_address: NewAddress = cast(NewAddress, address)
field_dict["address"] = _address.to_dict()
if name is not UNSET:
field_dict["name"] = name
if phone is not UNSET:
field_dict["phone"] = phone
return field_dict
@classmethod
def from_dict(cls: Type[LT], src_dict: Dict[str, Any]) -> LT:
d = src_dict.copy()
_address = d.pop("address", UNSET)
address: Union[Unset, NewAddress]
if isinstance(_address, Unset):
address = UNSET
if _address is None:
address = UNSET
else:
address = NewAddress.from_dict(_address)
name = d.pop("name", UNSET)
phone = d.pop("phone", UNSET)
billing_info = cls(
address=address,
name=name,
phone=phone,
)
billing_info.additional_properties = d
return billing_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
phone: Optional[PhoneNumber] = None