File tree Expand file tree Collapse file tree 5 files changed +120
-3
lines changed
bandwidth/model/bxml/verbs Expand file tree Collapse file tree 5 files changed +120
-3
lines changed Original file line number Diff line number Diff line change 66from .phone_number import PhoneNumber
77from .play_audio import PlayAudio
88from .record import Record
9- from .start_recording import StartRecording
9+ from .send_dtmf import SendDtmf
1010from .sip_uri import SipUri
11+ from .speak_sentence import SpeakSentence
12+ from .start_recording import StartRecording
1113from .start_stream import StartStream
14+ from .stop_gather import StopGather
1215from .stop_stream import StopStream
13- from .stream_param import StreamParam
1416from .stop_recording import StopRecording
15- from .speak_sentence import SpeakSentence
17+ from .stream_param import StreamParam
1618from .tag import Tag
1719from .transfer import Transfer
Original file line number Diff line number Diff line change 1+ """
2+ send_dtmf.py
3+
4+ Bandwidth's SendDtmf BXML verb
5+
6+ @copyright Bandwidth INC
7+ """
8+ from ..terminal_verb import TerminalVerb
9+
10+
11+ class SendDtmf (TerminalVerb ):
12+
13+ def __init__ (
14+ self , digits : str ,
15+ tone_duration : str = None ,
16+ tone_interval : str = None ,
17+ ):
18+ """Initialize a <SendDtmf> verb
19+
20+ Args:
21+ digits (str): String containing the DTMF characters to be sent in a call. Allows a maximum of 50 characters. The digits will be sent one-by-one with a marginal delay.
22+ tone_duration (str, optional): The length (in milliseconds) of each DTMF tone. Default value is 200. Range: decimal values between 50 - 5000.
23+ tone_interval (str, optional): The duration of silence (in milliseconds) following each DTMF tone. Default value is 400. Range: decimal values between 50 - 5000.
24+ """
25+ self .digits = digits
26+ self .tone_duration = tone_duration
27+ self .tone_interval = tone_interval
28+ super ().__init__ (
29+ tag = "SendDtmf" ,
30+ content = self .digits
31+ )
32+
33+ @property
34+ def _attributes (self ):
35+ return {
36+ "toneDuration" : self .tone_duration ,
37+ "toneInterval" : self .tone_interval
38+ }
Original file line number Diff line number Diff line change 1+ """
2+ stop_gather.py
3+
4+ Bandwidth's StopGather BXML verb
5+
6+ @copyright Bandwidth INC
7+ """
8+ from ..terminal_verb import TerminalVerb
9+
10+
11+ class StopGather (TerminalVerb ):
12+
13+ def __init__ (self ):
14+ """Initialize a <StopGather> verb
15+ """
16+ super ().__init__ (tag = "StopGather" , content = None )
Original file line number Diff line number Diff line change 1+ """
2+ test_send_dtmf.py
3+
4+ Unit tests for the <SendDtmf> BXML verb
5+
6+ @copyright Bandwidth Inc.
7+ """
8+ import pytest
9+ import unittest
10+
11+ from bandwidth .model .bxml .verb import Verb
12+ from bandwidth .model .bxml .verbs .send_dtmf import SendDtmf
13+
14+
15+ class TestSendDtmf (unittest .TestCase ):
16+
17+ def setUp (self ):
18+ self .send_dtmf = SendDtmf (
19+ digits = "1234" ,
20+ tone_duration = "3" ,
21+ tone_interval = "5"
22+ )
23+ self .test_verb = Verb (tag = "test" )
24+
25+ def test_to_bxml (self ):
26+ expected = '<SendDtmf toneDuration="3" toneInterval="5">1234</SendDtmf>'
27+ assert (expected == self .send_dtmf .to_bxml ())
28+
29+
30+ def test_add_verb (self ):
31+ with pytest .raises (AttributeError ):
32+ self .send_dtmf .add_verb (self .test_verb )
33+
Original file line number Diff line number Diff line change 1+ """
2+ test_stop_gather.py
3+
4+ Unit tests for the <StopGather> BXML verb
5+
6+ @copyright Bandwidth Inc.
7+ """
8+ import pytest
9+ import unittest
10+
11+ from bandwidth .model .bxml .verb import Verb
12+ from bandwidth .model .bxml .verbs .stop_gather import StopGather
13+
14+
15+ class TestTag (unittest .TestCase ):
16+
17+ def setUp (self ):
18+ self .stop_gather = StopGather ()
19+ self .test_verb = Verb (tag = "test" )
20+
21+ def test_to_bxml (self ):
22+ expected = '<StopGather />'
23+ assert (expected == self .stop_gather .to_bxml ())
24+
25+ def test_add_verb (self ):
26+ with pytest .raises (AttributeError ):
27+ self .stop_gather .add_verb (self .test_verb )
28+
You can’t perform that action at this time.
0 commit comments