Skip to content

Commit

Permalink
fax and faxapp additions (#43)
Browse files Browse the repository at this point in the history
* fax and faxapp additions

* update tests to fit required parameters

Co-authored-by: Quagser <quagmilion@gmail.com>
  • Loading branch information
d-telnyx and Quagbot committed Feb 3, 2021
1 parent 3532f5b commit 958fa7e
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 1 deletion.
4 changes: 4 additions & 0 deletions telnyx/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,6 +59,8 @@
"CredentialConnection",
"DetailRecordsReport",
"Event",
"Faxes",
"FaxApplication",
"FQDN",
"FQDNConnection",
"InboundChannel",
Expand Down
17 changes: 17 additions & 0 deletions telnyx/api_resources/fax_application.py
Original file line number Diff line number Diff line change
@@ -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"
17 changes: 17 additions & 0 deletions telnyx/api_resources/faxes.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions telnyx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
60 changes: 60 additions & 0 deletions tests/api_resources/test_fax_applications.py
Original file line number Diff line number Diff line change
@@ -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
)
3 changes: 2 additions & 1 deletion tests/api_resources/test_outbound_voice_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 958fa7e

Please sign in to comment.