|
1 | | -from pydantic import BaseModel, AnyUrl, Field |
2 | 1 | from typing import Optional |
3 | | -from typing_extensions import Literal |
4 | | - |
5 | | -from .enums import ConnectEndpointType |
6 | 2 |
|
| 3 | +from pydantic import BaseModel, Field |
| 4 | +from typing_extensions import Literal |
7 | 5 | from vonage_utils.types import Dtmf, PhoneNumber, SipUri |
8 | 6 |
|
9 | | - |
10 | | -class BaseEndpoint(BaseModel): |
11 | | - """Base Endpoint model for use with the NCCO Connect action.""" |
| 7 | +from .enums import ConnectEndpointType |
12 | 8 |
|
13 | 9 |
|
14 | 10 | class OnAnswer(BaseModel): |
15 | | - url: AnyUrl |
16 | | - ringbackTone: Optional[AnyUrl] = None |
| 11 | + url: str |
| 12 | + ringbackTone: Optional[str] = None |
17 | 13 |
|
18 | 14 |
|
19 | | -class PhoneEndpoint(BaseEndpoint): |
| 15 | +class PhoneEndpoint(BaseModel): |
20 | 16 | number: PhoneNumber |
21 | 17 | dtmfAnswer: Optional[Dtmf] = None |
22 | 18 | onAnswer: Optional[OnAnswer] = None |
23 | 19 | type: ConnectEndpointType = ConnectEndpointType.PHONE |
24 | 20 |
|
25 | 21 |
|
26 | | -class AppEndpoint(BaseEndpoint): |
| 22 | +class AppEndpoint(BaseModel): |
27 | 23 | user: str |
28 | 24 | type: ConnectEndpointType = ConnectEndpointType.APP |
29 | 25 |
|
30 | 26 |
|
31 | | -class WebsocketEndpoint(BaseEndpoint): |
32 | | - uri: AnyUrl |
| 27 | +class WebsocketEndpoint(BaseModel): |
| 28 | + uri: str |
33 | 29 | contentType: Literal['audio/l16;rate=16000', 'audio/l16;rate=8000'] = Field( |
34 | | - 'audio/l16;rate=16000', serialization_alias='content-type' |
| 30 | + None, serialization_alias='content-type' |
35 | 31 | ) |
36 | | - headers: Optional[dict] = {} |
| 32 | + headers: Optional[dict] = None |
37 | 33 | type: ConnectEndpointType = ConnectEndpointType.WEBSOCKET |
38 | 34 |
|
39 | 35 |
|
40 | | -class SipEndpoint(BaseEndpoint): |
| 36 | +class SipEndpoint(BaseModel): |
41 | 37 | uri: SipUri |
42 | | - headers: Optional[dict] = {} |
| 38 | + headers: Optional[dict] = None |
43 | 39 | type: ConnectEndpointType = ConnectEndpointType.SIP |
44 | 40 |
|
45 | 41 |
|
46 | | -class VbcEndpoint(BaseEndpoint): |
| 42 | +class VbcEndpoint(BaseModel): |
47 | 43 | extension: str |
48 | 44 | type: ConnectEndpointType = ConnectEndpointType.VBC |
0 commit comments