|
1 | 1 | from typing import Any, Optional, Union |
2 | 2 |
|
3 | | -from pydantic import BaseModel, ConfigDict, Field |
| 3 | +from pydantic import BaseModel, ConfigDict, Field, field_validator |
4 | 4 | from pydantic.alias_generators import to_camel |
5 | 5 |
|
6 | 6 | from solapi.model import KakaoOption |
7 | 7 | from solapi.model.message_type import MessageType |
8 | 8 | from solapi.model.rcs.rcs_options import RcsOption |
| 9 | +from solapi.model.request.voice.voice_option import VoiceOption |
9 | 10 |
|
10 | 11 |
|
11 | 12 | class FileIdsType(BaseModel): |
@@ -52,6 +53,29 @@ class Message(BaseModel): |
52 | 53 | fax_options: Optional[FileIdsType] = Field( |
53 | 54 | default=None, serialization_alias="faxOptions", validation_alias="faxOptions" |
54 | 55 | ) |
| 56 | + voice_options: Optional[VoiceOption] = Field( |
| 57 | + default=None, |
| 58 | + serialization_alias="voiceOptions", |
| 59 | + validation_alias="voiceOptions", |
| 60 | + ) |
| 61 | + |
| 62 | + @field_validator("from_", mode="before") |
| 63 | + @classmethod |
| 64 | + def normalize_from_phone_number(cls, v: Optional[str]) -> Optional[str]: |
| 65 | + if v is None: |
| 66 | + return v |
| 67 | + return v.replace("-", "") |
| 68 | + |
| 69 | + @field_validator("to", mode="before") |
| 70 | + @classmethod |
| 71 | + def normalize_to_phone_number( |
| 72 | + cls, v: Union[str, list[str]] |
| 73 | + ) -> Union[str, list[str]]: |
| 74 | + if isinstance(v, str): |
| 75 | + return v.replace("-", "") |
| 76 | + elif isinstance(v, list): |
| 77 | + return [phone.replace("-", "") for phone in v] |
| 78 | + return v |
55 | 79 |
|
56 | 80 | model_config = ConfigDict( |
57 | 81 | extra="ignore", |
|
0 commit comments