2020
2121from pydantic import BaseModel , ConfigDict , Field , StrictInt , StrictStr
2222from typing import Any , ClassVar , Dict , List , Optional
23+ from bandwidth .models .error_source import ErrorSource
2324from bandwidth .models .telephone_number import TelephoneNumber
2425from typing import Optional , Set
2526from typing_extensions import Self
@@ -28,11 +29,14 @@ class Error(BaseModel):
2829 """
2930 Error
3031 """ # noqa: E501
32+ id : Optional [StrictStr ] = Field (default = None , description = "A unique identifier for the error." )
33+ type : Optional [StrictStr ] = Field (default = None , description = "The type of error." )
3134 code : Optional [StrictInt ] = None
3235 description : Optional [StrictStr ] = None
3336 telephone_numbers : Optional [List [TelephoneNumber ]] = Field (default = None , alias = "telephoneNumbers" )
37+ source : Optional [ErrorSource ] = None
3438 additional_properties : Dict [str , Any ] = {}
35- __properties : ClassVar [List [str ]] = ["code" , "description" , "telephoneNumbers" ]
39+ __properties : ClassVar [List [str ]] = ["id" , "type" , " code" , "description" , "telephoneNumbers" , "source " ]
3640
3741 model_config = ConfigDict (
3842 populate_by_name = True ,
@@ -82,6 +86,9 @@ def to_dict(self) -> Dict[str, Any]:
8286 if _item_telephone_numbers :
8387 _items .append (_item_telephone_numbers .to_dict ())
8488 _dict ['telephoneNumbers' ] = _items
89+ # override the default output from pydantic by calling `to_dict()` of source
90+ if self .source :
91+ _dict ['source' ] = self .source .to_dict ()
8592 # puts key-value pairs in additional_properties in the top level
8693 if self .additional_properties is not None :
8794 for _key , _value in self .additional_properties .items ():
@@ -99,9 +106,12 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
99106 return cls .model_validate (obj )
100107
101108 _obj = cls .model_validate ({
109+ "id" : obj .get ("id" ),
110+ "type" : obj .get ("type" ),
102111 "code" : obj .get ("code" ),
103112 "description" : obj .get ("description" ),
104- "telephoneNumbers" : [TelephoneNumber .from_dict (_item ) for _item in obj ["telephoneNumbers" ]] if obj .get ("telephoneNumbers" ) is not None else None
113+ "telephoneNumbers" : [TelephoneNumber .from_dict (_item ) for _item in obj ["telephoneNumbers" ]] if obj .get ("telephoneNumbers" ) is not None else None ,
114+ "source" : ErrorSource .from_dict (obj ["source" ]) if obj .get ("source" ) is not None else None
105115 })
106116 # store additional fields in additional_properties
107117 for _key in obj .keys ():
0 commit comments