diff --git a/telnyx/api_resources/__init__.py b/telnyx/api_resources/__init__.py index 984a809..9a6b7b1 100644 --- a/telnyx/api_resources/__init__.py +++ b/telnyx/api_resources/__init__.py @@ -12,6 +12,8 @@ from telnyx.api_resources.credential_connection import CredentialConnection from telnyx.api_resources.detail_records_report import DetailRecordsReport from telnyx.api_resources.event import Event +from telnyx.api_resources.fax_application import FaxApplication +from telnyx.api_resources.faxes import Faxes from telnyx.api_resources.fqdn import FQDN from telnyx.api_resources.fqdn_connection import FQDNConnection from telnyx.api_resources.inbound_channel import InboundChannel @@ -57,6 +59,8 @@ "CredentialConnection", "DetailRecordsReport", "Event", + "Faxes", + "FaxApplication", "FQDN", "FQDNConnection", "InboundChannel", diff --git a/telnyx/api_resources/fax_application.py b/telnyx/api_resources/fax_application.py new file mode 100644 index 0000000..176dcab --- /dev/null +++ b/telnyx/api_resources/fax_application.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class FaxApplication( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "fax_application" diff --git a/telnyx/api_resources/faxes.py b/telnyx/api_resources/faxes.py new file mode 100644 index 0000000..32ff5da --- /dev/null +++ b/telnyx/api_resources/faxes.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function + +from telnyx.api_resources.abstract import ( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +) + + +class Faxes( + CreateableAPIResource, + DeletableAPIResource, + ListableAPIResource, + UpdateableAPIResource, +): + OBJECT_NAME = "Faxes" diff --git a/telnyx/util.py b/telnyx/util.py index 489b149..7696f0f 100644 --- a/telnyx/util.py +++ b/telnyx/util.py @@ -116,6 +116,8 @@ def load_object_classes(): api_resources.Connection.OBJECT_NAME: api_resources.Connection, api_resources.CredentialConnection.OBJECT_NAME: api_resources.CredentialConnection, api_resources.DetailRecordsReport.OBJECT_NAME: api_resources.DetailRecordsReport, + api_resources.Faxes.OBJECT_NAME: api_resources.Faxes, + api_resources.FaxApplication.OBJECT_NAME: api_resources.FaxApplication, api_resources.FQDN.OBJECT_NAME: api_resources.FQDN, api_resources.FQDNConnection.OBJECT_NAME: api_resources.FQDNConnection, api_resources.InboundChannel.OBJECT_NAME: api_resources.InboundChannel, diff --git a/tests/api_resources/test_fax_applications.py b/tests/api_resources/test_fax_applications.py new file mode 100644 index 0000000..b13aa12 --- /dev/null +++ b/tests/api_resources/test_fax_applications.py @@ -0,0 +1,60 @@ +from __future__ import absolute_import, division, print_function + +import telnyx + +TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58" + + +class TestFaxApplication(object): + def test_is_listable(self, request_mock): + resources = telnyx.FaxApplication.list() + request_mock.assert_requested("get", "/v2/fax_applications") + assert isinstance(resources.data, list) + assert isinstance(resources.data[0], telnyx.FaxApplication) + + def test_is_retrievable(self, request_mock): + resource = telnyx.FaxApplication.retrieve(TEST_RESOURCE_ID) + request_mock.assert_requested( + "get", "/v2/fax_applications/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.FaxApplication) + + def test_is_creatable(self, request_mock): + resource = telnyx.FaxApplication.create( + active=True, + application_name="Test Name", + webhook_event_url="https://test.com", + ) + request_mock.assert_requested("post", "/v2/fax_applications") + assert isinstance(resource, telnyx.FaxApplication) + + def test_is_saveable(self, request_mock): + fax_application = telnyx.FaxApplication.retrieve(TEST_RESOURCE_ID) + fax_application.active = False + fax_application.webhook_event_url = "https://update.com" + fax_application.application_name = "updated name" + resource = fax_application.save() + request_mock.assert_requested( + "patch", "/v2/fax_applications/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.FaxApplication) + assert resource is fax_application + + def test_is_modifiable(self, request_mock): + resource = telnyx.FaxApplication.modify( + TEST_RESOURCE_ID, + active=False, + webhook_event_url="https://update.com", + application_name="updated name", + ) + request_mock.assert_requested( + "patch", "/v2/fax_applications/%s" % TEST_RESOURCE_ID + ) + assert isinstance(resource, telnyx.FaxApplication) + + def test_is_deletable(self, request_mock): + resource = telnyx.FaxApplication.retrieve(TEST_RESOURCE_ID) + resource.delete() + request_mock.assert_requested( + "delete", "/v2/fax_applications/%s" % TEST_RESOURCE_ID + ) diff --git a/tests/api_resources/test_outbound_voice_profile.py b/tests/api_resources/test_outbound_voice_profile.py index e851b86..aace591 100644 --- a/tests/api_resources/test_outbound_voice_profile.py +++ b/tests/api_resources/test_outbound_voice_profile.py @@ -27,6 +27,7 @@ def test_is_creatable(self, request_mock): def test_is_saveable(self, request_mock): outbound_voice_profile = telnyx.OutboundVoiceProfile.retrieve(TEST_RESOURCE_ID) outbound_voice_profile.concurrent_call_limit = 10 + outbound_voice_profile.name = "Dan" resource = outbound_voice_profile.save() request_mock.assert_requested( "patch", "/v2/outbound_voice_profiles/%s" % TEST_RESOURCE_ID @@ -36,7 +37,7 @@ def test_is_saveable(self, request_mock): def test_is_modifiable(self, request_mock): resource = telnyx.OutboundVoiceProfile.modify( - TEST_RESOURCE_ID, concurrent_call_limit=10 + TEST_RESOURCE_ID, concurrent_call_limit=10, name="Dan" ) request_mock.assert_requested( "patch", "/v2/outbound_voice_profiles/%s" % TEST_RESOURCE_ID