-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish adding NCCO actions and add tests
- Loading branch information
Showing
12 changed files
with
564 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
python_tests(dependencies=['messages', 'testutils']) | ||
|
||
python_sources( | ||
name="tests0", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python_sources() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from .common import AdvancedMachineDetection | ||
from .connect_endpoints import ( | ||
AppEndpoint, | ||
OnAnswer, | ||
PhoneEndpoint, | ||
SipEndpoint, | ||
VbcEndpoint, | ||
WebsocketEndpoint, | ||
) | ||
from .enums import Channel, ConnectEndpointType, NccoActionType | ||
from .input_types import Dtmf, Speech | ||
from .ncco import Connect, Conversation, Input, NccoAction, Notify, Record, Stream, Talk | ||
from .requests import Call, NccoAction, Phone, Sip, ToPhone, Vbc, Websocket | ||
from .responses import CallStatus, CreateCallResponse | ||
|
||
__all__ = [ | ||
'AdvancedMachineDetection', | ||
'Call', | ||
'ToPhone', | ||
'Sip', | ||
'Websocket', | ||
'Vbc', | ||
'Phone', | ||
'NccoAction', | ||
'Channel', | ||
'NccoActionType', | ||
'ConnectEndpointType', | ||
'OnAnswer', | ||
'PhoneEndpoint', | ||
'AppEndpoint', | ||
'WebsocketEndpoint', | ||
'SipEndpoint', | ||
'VbcEndpoint', | ||
'Dtmf', | ||
'Speech', | ||
'CreateCallResponse', | ||
'CallStatus', | ||
'Record', | ||
'Conversation', | ||
'Connect', | ||
'Talk', | ||
'Stream', | ||
'Input', | ||
'Notify', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,44 @@ | ||
from pydantic import BaseModel, AnyUrl, Field | ||
from typing import Optional | ||
from typing_extensions import Literal | ||
|
||
from .enums import ConnectEndpointType | ||
|
||
from pydantic import BaseModel, Field | ||
from typing_extensions import Literal | ||
from vonage_utils.types import Dtmf, PhoneNumber, SipUri | ||
|
||
|
||
class BaseEndpoint(BaseModel): | ||
"""Base Endpoint model for use with the NCCO Connect action.""" | ||
from .enums import ConnectEndpointType | ||
|
||
|
||
class OnAnswer(BaseModel): | ||
url: AnyUrl | ||
ringbackTone: Optional[AnyUrl] = None | ||
url: str | ||
ringbackTone: Optional[str] = None | ||
|
||
|
||
class PhoneEndpoint(BaseEndpoint): | ||
class PhoneEndpoint(BaseModel): | ||
number: PhoneNumber | ||
dtmfAnswer: Optional[Dtmf] = None | ||
onAnswer: Optional[OnAnswer] = None | ||
type: ConnectEndpointType = ConnectEndpointType.PHONE | ||
|
||
|
||
class AppEndpoint(BaseEndpoint): | ||
class AppEndpoint(BaseModel): | ||
user: str | ||
type: ConnectEndpointType = ConnectEndpointType.APP | ||
|
||
|
||
class WebsocketEndpoint(BaseEndpoint): | ||
uri: AnyUrl | ||
class WebsocketEndpoint(BaseModel): | ||
uri: str | ||
contentType: Literal['audio/l16;rate=16000', 'audio/l16;rate=8000'] = Field( | ||
'audio/l16;rate=16000', serialization_alias='content-type' | ||
None, serialization_alias='content-type' | ||
) | ||
headers: Optional[dict] = {} | ||
headers: Optional[dict] = None | ||
type: ConnectEndpointType = ConnectEndpointType.WEBSOCKET | ||
|
||
|
||
class SipEndpoint(BaseEndpoint): | ||
class SipEndpoint(BaseModel): | ||
uri: SipUri | ||
headers: Optional[dict] = {} | ||
headers: Optional[dict] = None | ||
type: ConnectEndpointType = ConnectEndpointType.SIP | ||
|
||
|
||
class VbcEndpoint(BaseEndpoint): | ||
class VbcEndpoint(BaseModel): | ||
extension: str | ||
type: ConnectEndpointType = ConnectEndpointType.VBC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
from pydantic import BaseModel, confloat, conint | ||
from typing import Optional, List | ||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class InputTypes: | ||
class Dtmf(BaseModel): | ||
timeOut: Optional[conint(ge=0, le=10)] | ||
maxDigits: Optional[conint(ge=1, le=20)] | ||
submitOnHash: Optional[bool] | ||
|
||
class Speech(BaseModel): | ||
uuid: Optional[str] | ||
endOnSilence: Optional[confloat(ge=0.4, le=10.0)] | ||
language: Optional[str] | ||
context: Optional[List[str]] | ||
startTimeout: Optional[conint(ge=1, le=60)] | ||
maxDuration: Optional[conint(ge=1, le=60)] | ||
saveAudio: Optional[bool] | ||
class Dtmf(BaseModel): | ||
timeOut: Optional[int] = Field(None, ge=0, le=10) | ||
maxDigits: Optional[int] = Field(None, ge=1, le=20) | ||
submitOnHash: Optional[bool] = None | ||
|
||
@classmethod | ||
def create_dtmf_model(cls, dict) -> Dtmf: | ||
return cls.Dtmf.parse_obj(dict) | ||
|
||
@classmethod | ||
def create_speech_model(cls, dict) -> Speech: | ||
return cls.Speech.parse_obj(dict) | ||
class Speech(BaseModel): | ||
uuid: Optional[List[str]] = None | ||
endOnSilence: Optional[float] = Field(None, ge=0.4, le=10.0) | ||
language: Optional[str] = None | ||
context: Optional[List[str]] = None | ||
startTimeout: Optional[int] = Field(None, ge=1, le=60) | ||
maxDuration: Optional[int] = Field(None, ge=1, le=60) | ||
saveAudio: Optional[bool] = False | ||
sensitivity: Optional[int] = Field(None, ge=0, le=100) |
Oops, something went wrong.