Skip to content

Commit

Permalink
add support for transcriptions (#50)
Browse files Browse the repository at this point in the history
* add support for transcriptions

* bump version for transcriptions
  • Loading branch information
d-telnyx authored Apr 30, 2021
1 parent ddc668b commit 0579975
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run_tests(self):

setup(
name="telnyx",
version="1.3.0",
version="1.4.0",
description="Python bindings for the Telnyx API",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion telnyx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
log = None


__version__ = "1.3.0"
__version__ = "1.4.0"


# Sets some basic information about the running application that's sent along
Expand Down
12 changes: 12 additions & 0 deletions telnyx/api_resources/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
@nested_resource_class_methods(
"send_dtmf", path="actions/send_dtmf", operations=["create"]
)
@nested_resource_class_methods(
"transcription_start", path="actions/transcription_start", operations=["create"]
)
@nested_resource_class_methods(
"transcription_stop", path="actions/transcription_stop", operations=["create"]
)
@nested_resource_class_methods(
"transfer", path="actions/transfer", operations=["create"]
)
Expand Down Expand Up @@ -86,5 +92,11 @@ def send_dtmf(self, **params):
def speak(self, **params):
return Call.create_speak(self.call_control_id, **params)

def transcription_start(self, **params):
return Call.create_transcription_start(self.call_control_id, **params)

def transcription_stop(self, **params):
return Call.create_transcription_stop(self.call_control_id, **params)

def transfer(self, **params):
return Call.create_transfer(self.call_control_id, **params)
2 changes: 1 addition & 1 deletion telnyx/api_resources/phone_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def all_voice(cls, **params):
return PhoneNumber.list_voice(None, **params)

def voice(self, **params):
""" Returns the voice settings for the instantiated phone number. """
"""Returns the voice settings for the instantiated phone number."""

return PhoneNumber.list_voice(self.id, **params)

Expand Down
42 changes: 36 additions & 6 deletions tests/api_resources/test_call.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

CALL_CONTROL_ID = "AgDIxmoRX6QMuaIj_uXRXnPAXP0QlNfXczRrZvZakpWxBlpw48KyZQ=="
Expand All @@ -19,20 +17,18 @@ def test_is_creatable(self, request_mock):
request_mock.assert_requested("post", "/v2/calls")
assert isinstance(resource, telnyx.Call)

@pytest.mark.skip(reason="OpenAPI specs needs review")
def test_can_call_reject(self, request_mock):
resource = create_dial()
resource.call_control_id = CALL_CONTROL_ID
resource.reject()
resource.reject(cause="USER_BUSY")
request_mock.assert_requested(
"post", "/v2/calls/%s/actions/reject" % CALL_CONTROL_ID
)
assert isinstance(resource, telnyx.Call)

@pytest.mark.skip(reason="OpenAPI specs needs review")
def test_can_call_calls_reject(self, request_mock):
resource = create_dial()
resource.create_reject(CALL_CONTROL_ID)
resource.create_reject(CALL_CONTROL_ID, cause="USER_BUSY")
request_mock.assert_requested(
"post", "/v2/calls/%s/actions/reject" % CALL_CONTROL_ID
)
Expand Down Expand Up @@ -277,6 +273,40 @@ def test_can_call_calls_speak(self, request_mock):
)
assert isinstance(resource, telnyx.Call)

def test_can_call_transcription_start(self, request_mock):
resource = telnyx.Call()
resource.call_control_id = CALL_CONTROL_ID
resource.transcription_start(language="en")
request_mock.assert_requested(
"post", "/v2/calls/%s/actions/transcription_start" % CALL_CONTROL_ID
)
assert isinstance(resource, telnyx.Call)

def test_can_call_calls_transcription_start(self, request_mock):
resource = telnyx.Call.create_transcription_start(
CALL_CONTROL_ID, language="en"
)
request_mock.assert_requested(
"post", "/v2/calls/%s/actions/transcription_start" % CALL_CONTROL_ID
)
assert isinstance(resource, telnyx.telnyx_object.TelnyxObject)

def test_can_call_transcription_stop(self, request_mock):
resource = telnyx.Call()
resource.call_control_id = CALL_CONTROL_ID
resource.transcription_stop()
request_mock.assert_requested(
"post", "/v2/calls/%s/actions/transcription_stop" % CALL_CONTROL_ID
)
assert isinstance(resource, telnyx.Call)

def test_can_call_calls_transcription_stop(self, request_mock):
resource = telnyx.Call.create_transcription_stop(CALL_CONTROL_ID)
request_mock.assert_requested(
"post", "/v2/calls/%s/actions/transcription_stop" % CALL_CONTROL_ID
)
assert isinstance(resource, telnyx.telnyx_object.TelnyxObject)

def test_can_call_transfer(self, request_mock):
resource = create_dial()
resource.call_control_id = CALL_CONTROL_ID
Expand Down
2 changes: 1 addition & 1 deletion tests/api_resources/test_sim_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ def test_disable(self, request_mock):
)

def test_register(self, request_mock):
telnyx.SIMCard.register()
telnyx.SIMCard.register(registration_codes=["foo", "bar"])
request_mock.assert_requested("post", "/v2/actions/register/sim_cards")

0 comments on commit 0579975

Please sign in to comment.