2023-05-04 00:58:06 -07:00
from typing import Any , Dict , List , Type , TypeVar , Union
2022-06-11 17:26:20 -07:00
import attr
2023-04-06 15:34:57 -07:00
from . . models . country_code import CountryCode
2022-06-11 17:26:20 -07:00
from . . types import UNSET , Unset
2023-05-04 00:58:06 -07:00
H = TypeVar ( " H " , bound = " NewAddress " )
2022-06-11 17:26:20 -07:00
@attr.s ( auto_attribs = True )
2022-07-28 15:18:50 +00:00
class NewAddress :
2023-05-04 00:58:06 -07:00
""" The struct that is used to create a new record. This is automatically generated and has all the same fields as the main struct only it is missing the `id`. """ # noqa: E501
2022-06-11 17:26:20 -07:00
city : Union [ Unset , str ] = UNSET
2023-04-06 15:34:57 -07:00
country : Union [ Unset , CountryCode ] = UNSET
2022-06-11 17:26:20 -07:00
state : Union [ Unset , str ] = UNSET
street1 : Union [ Unset , str ] = UNSET
street2 : Union [ Unset , str ] = UNSET
user_id : Union [ Unset , str ] = UNSET
zip : Union [ Unset , str ] = UNSET
additional_properties : Dict [ str , Any ] = attr . ib ( init = False , factory = dict )
def to_dict ( self ) - > Dict [ str , Any ] :
city = self . city
2023-04-06 15:34:57 -07:00
if not isinstance ( self . country , Unset ) :
2023-05-04 00:58:06 -07:00
country = self . country
2022-06-11 17:26:20 -07:00
state = self . state
street1 = self . street1
street2 = self . street2
user_id = self . user_id
zip = self . zip
field_dict : Dict [ str , Any ] = { }
field_dict . update ( self . additional_properties )
field_dict . update ( { } )
if city is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " city " ] = city
2022-06-11 17:26:20 -07:00
if country is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " country " ] = country
2022-06-11 17:26:20 -07:00
if state is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " state " ] = state
2022-06-11 17:26:20 -07:00
if street1 is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " street1 " ] = street1
2022-06-11 17:26:20 -07:00
if street2 is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " street2 " ] = street2
2022-06-11 17:26:20 -07:00
if user_id is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " user_id " ] = user_id
2022-06-11 17:26:20 -07:00
if zip is not UNSET :
2023-05-04 00:58:06 -07:00
field_dict [ " zip " ] = zip
2022-06-11 17:26:20 -07:00
return field_dict
@classmethod
2023-05-04 00:58:06 -07:00
def from_dict ( cls : Type [ H ] , src_dict : Dict [ str , Any ] ) - > H :
2022-06-11 17:26:20 -07:00
d = src_dict . copy ( )
city = d . pop ( " city " , UNSET )
2023-04-06 15:34:57 -07:00
_country = d . pop ( " country " , UNSET )
country : Union [ Unset , CountryCode ]
if isinstance ( _country , Unset ) :
country = UNSET
else :
country = CountryCode ( _country )
2022-06-11 17:26:20 -07:00
state = d . pop ( " state " , UNSET )
street1 = d . pop ( " street1 " , UNSET )
street2 = d . pop ( " street2 " , UNSET )
user_id = d . pop ( " user_id " , UNSET )
zip = d . pop ( " zip " , UNSET )
2022-07-28 15:18:50 +00:00
new_address = cls (
2022-06-11 17:26:20 -07:00
city = city ,
country = country ,
state = state ,
street1 = street1 ,
street2 = street2 ,
user_id = user_id ,
zip = zip ,
)
2022-07-28 15:18:50 +00:00
new_address . additional_properties = d
return new_address
2022-06-11 17:26:20 -07:00
@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