From 38c3f2c54449c460463144f9bec19cf602bc99f2 Mon Sep 17 00:00:00 2001
From: SgastonBW <99285351+SgastonBW@users.noreply.github.com>
Date: Thu, 29 Aug 2024 13:20:37 -0400
Subject: [PATCH 1/5] Update tndetails.py to include messaging and location
details
Adding missing fields from current tnDetails response body
---
bandwidth_numbers/models/maps/tndetails.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/bandwidth_numbers/models/maps/tndetails.py b/bandwidth_numbers/models/maps/tndetails.py
index 7738c94..74805c6 100644
--- a/bandwidth_numbers/models/maps/tndetails.py
+++ b/bandwidth_numbers/models/maps/tndetails.py
@@ -16,3 +16,16 @@ class TndetailsMap(BaseMap):
tier = None
vendor_id = None
vendor_name = None
+ site_id = None
+ site_name = None
+ sip_peer_id = None
+ sip_peer_name = None
+ is_default_peer = None
+ service_types = []
+ sms_enabled = None
+ campaign_id = None
+ message_class = None
+ campaign_fully_provisioned = None
+ a2p_state = None
+ assigned_nn_route_id = None
+ assigned_nn_route_name = None
From 1930fda70ced3dbd802329e55adb1f5a96a11957 Mon Sep 17 00:00:00 2001
From: AJ Rice <53190766+ajrice6713@users.noreply.github.com>
Date: Thu, 29 Aug 2024 16:07:56 -0400
Subject: [PATCH 2/5] Stub out a test
---
bandwidth_numbers/models/maps/tndetails.py | 17 ++++-------------
tests/test_tns.py | 5 +++++
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/bandwidth_numbers/models/maps/tndetails.py b/bandwidth_numbers/models/maps/tndetails.py
index 74805c6..37abce7 100644
--- a/bandwidth_numbers/models/maps/tndetails.py
+++ b/bandwidth_numbers/models/maps/tndetails.py
@@ -16,16 +16,7 @@ class TndetailsMap(BaseMap):
tier = None
vendor_id = None
vendor_name = None
- site_id = None
- site_name = None
- sip_peer_id = None
- sip_peer_name = None
- is_default_peer = None
- service_types = []
- sms_enabled = None
- campaign_id = None
- message_class = None
- campaign_fully_provisioned = None
- a2p_state = None
- assigned_nn_route_id = None
- assigned_nn_route_name = None
+ site = None
+ sip_peer = None
+ service_types = None
+ messaging_settings = None
diff --git a/tests/test_tns.py b/tests/test_tns.py
index af21755..b9990f7 100644
--- a/tests/test_tns.py
+++ b/tests/test_tns.py
@@ -104,6 +104,10 @@
b"49Bandwidth CLEC"
b"JERSEYCITYInservice"
b"14"
+ b"135927PROD"
+ b"VoiceMessaging"
+ b"trueCU9B04MCampaign-Etrueoverridden103775BW A2P - SVR - E151 (103775)"
+ b"971438Uptravifalse"
b"2014-07-30T11:29:37.000Z"
b"Success"
b"Pending"
@@ -305,6 +309,7 @@ def test_tndetails(self):
self.assertEqual(tnd.account_id, "14")
self.assertEqual(tnd.last_modified, "2014-07-30T11:29:37.000Z")
self.assertEqual(tnd.features.lidb.status, "Pending")
+ self.assertEqual(tnd.sip_peer.peer_id, "971438")
def test_tnreservation(self):
From 4f91c5ddab632e8f7ae53ff694528e838e691771 Mon Sep 17 00:00:00 2001
From: SgastonBW <99285351+SgastonBW@users.noreply.github.com>
Date: Thu, 29 Aug 2024 16:35:15 -0400
Subject: [PATCH 3/5] Create messaging_settings.py
---
bandwidth_numbers/models/maps/messaging_settings.py | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 bandwidth_numbers/models/maps/messaging_settings.py
diff --git a/bandwidth_numbers/models/maps/messaging_settings.py b/bandwidth_numbers/models/maps/messaging_settings.py
new file mode 100644
index 0000000..97e1535
--- /dev/null
+++ b/bandwidth_numbers/models/maps/messaging_settings.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+from bandwidth_numbers.models.maps.base_map import BaseMap
+
+class MessagingSettingsMap(BaseMap):
+
+ sms_enabled = None
+ campaign_id = None
+ message_class = None
+ campaign_fully_provisioned = None
+ a2p_state = None
From 9fee2fc2b2fc7f317bf16ad637f98c70a96be7d5 Mon Sep 17 00:00:00 2001
From: SgastonBW <99285351+SgastonBW@users.noreply.github.com>
Date: Thu, 29 Aug 2024 16:46:22 -0400
Subject: [PATCH 4/5] Update tndetails.py
---
bandwidth_numbers/models/data/tndetails.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bandwidth_numbers/models/data/tndetails.py b/bandwidth_numbers/models/data/tndetails.py
index 3f76694..948532f 100644
--- a/bandwidth_numbers/models/data/tndetails.py
+++ b/bandwidth_numbers/models/data/tndetails.py
@@ -3,8 +3,12 @@
from bandwidth_numbers.models.base_resource import BaseData
from bandwidth_numbers.models.data.features import Features
from bandwidth_numbers.models.maps.tndetails import TndetailsMap
+from bandwidth_numbers.models.maps.site import SiteMap
+from bandwidth_numbers.models.maps.sip_peer import SipPeerMap
+from bandwidth_numbers.models.maps.messaging_settings import MessagingSettingsMap
-class TndetailsData(TndetailsMap, BaseData):
+
+class TndetailsData(TndetailsMap, SiteMap, SipPeerMap, MessagingSettingsMap, BaseData):
@property
def id(self):
From e2d8726e63fb4f1c00b311d09045cb02ab684711 Mon Sep 17 00:00:00 2001
From: AJ Rice <53190766+ajrice6713@users.noreply.github.com>
Date: Thu, 29 Aug 2024 18:05:53 -0400
Subject: [PATCH 5/5] Implement all of the properties
---
.../models/data/messaging_settings.py | 8 ++++
bandwidth_numbers/models/data/tndetails.py | 38 +++++++++++++++++--
.../models/maps/messaging_settings.py | 1 -
bandwidth_numbers/models/maps/tndetails.py | 1 +
.../models/messaging_settings.py | 11 ++++++
bandwidth_numbers/models/tndetails.py | 28 ++++++++++++++
tests/test_tns.py | 8 +++-
7 files changed, 89 insertions(+), 6 deletions(-)
create mode 100644 bandwidth_numbers/models/data/messaging_settings.py
create mode 100644 bandwidth_numbers/models/messaging_settings.py
diff --git a/bandwidth_numbers/models/data/messaging_settings.py b/bandwidth_numbers/models/data/messaging_settings.py
new file mode 100644
index 0000000..ab9437c
--- /dev/null
+++ b/bandwidth_numbers/models/data/messaging_settings.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+from bandwidth_numbers.models.base_resource import BaseData
+from bandwidth_numbers.models.maps.messaging_settings import MessagingSettingsMap
+
+
+class MessagingSettingsData(MessagingSettingsMap, BaseData):
+ pass
diff --git a/bandwidth_numbers/models/data/tndetails.py b/bandwidth_numbers/models/data/tndetails.py
index 948532f..58c172d 100644
--- a/bandwidth_numbers/models/data/tndetails.py
+++ b/bandwidth_numbers/models/data/tndetails.py
@@ -1,14 +1,15 @@
#!/usr/bin/env python
+from traceback import print_last
from bandwidth_numbers.models.base_resource import BaseData
from bandwidth_numbers.models.data.features import Features
+from bandwidth_numbers.models.data.site import SiteData
+from bandwidth_numbers.models.data.sip_peer import SipPeerData
from bandwidth_numbers.models.maps.tndetails import TndetailsMap
-from bandwidth_numbers.models.maps.site import SiteMap
-from bandwidth_numbers.models.maps.sip_peer import SipPeerMap
-from bandwidth_numbers.models.maps.messaging_settings import MessagingSettingsMap
+from bandwidth_numbers.models.data.messaging_settings import MessagingSettingsData
-class TndetailsData(TndetailsMap, SiteMap, SipPeerMap, MessagingSettingsMap, BaseData):
+class TndetailsData(TndetailsMap, BaseData):
@property
def id(self):
@@ -17,6 +18,28 @@ def id(self):
def id(self, id):
self.full_number = id
+ @property
+ def site(self):
+ return self.site
+ @site.setter
+ def site(self, site):
+ self.site = site
+
+ @property
+ def sip_peer(self):
+ return self._sip_peer
+ @sip_peer.setter
+ def sip_peer(self, sip_peer):
+ self._sip_peer = sip_peer
+
+
+ @property
+ def messaging_settings(self):
+ return self.messaging_settings
+ @messaging_settings.setter
+ def messaging_settings(self, messaging_settings):
+ self.messaging_settings = messaging_settings
+
@property
def last_modified_date(self):
return self.last_modified
@@ -26,3 +49,10 @@ def last_modified_date(self, last_modified_date):
def __init__(self):
self.features = Features()
+ self.site = SiteData()
+ self.sip_peer = SipPeerData()
+ self.messaging_settings = MessagingSettingsData()
+
+ @messaging_settings.setter
+ def messaging_settings(self, value):
+ self._messaging_settings = value
diff --git a/bandwidth_numbers/models/maps/messaging_settings.py b/bandwidth_numbers/models/maps/messaging_settings.py
index 97e1535..24750cd 100644
--- a/bandwidth_numbers/models/maps/messaging_settings.py
+++ b/bandwidth_numbers/models/maps/messaging_settings.py
@@ -3,7 +3,6 @@
from bandwidth_numbers.models.maps.base_map import BaseMap
class MessagingSettingsMap(BaseMap):
-
sms_enabled = None
campaign_id = None
message_class = None
diff --git a/bandwidth_numbers/models/maps/tndetails.py b/bandwidth_numbers/models/maps/tndetails.py
index 37abce7..ede3473 100644
--- a/bandwidth_numbers/models/maps/tndetails.py
+++ b/bandwidth_numbers/models/maps/tndetails.py
@@ -2,6 +2,7 @@
from bandwidth_numbers.models.maps.base_map import BaseMap
+
class TndetailsMap(BaseMap):
account_id = None
diff --git a/bandwidth_numbers/models/messaging_settings.py b/bandwidth_numbers/models/messaging_settings.py
new file mode 100644
index 0000000..d2bace0
--- /dev/null
+++ b/bandwidth_numbers/models/messaging_settings.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+from __future__ import division, absolute_import, print_function
+
+from bandwidth_numbers.models.base_resource import BaseResource
+from bandwidth_numbers.models.data.messaging_settings import MessagingSettingsData
+
+XML_NAME_MESSAGING_SETTINGS = "MessagingSettings"
+
+class MessagingSettings(BaseResource, MessagingSettingsData):
+ pass
diff --git a/bandwidth_numbers/models/tndetails.py b/bandwidth_numbers/models/tndetails.py
index 742623e..62faf1d 100644
--- a/bandwidth_numbers/models/tndetails.py
+++ b/bandwidth_numbers/models/tndetails.py
@@ -5,6 +5,9 @@
from bandwidth_numbers.models.base_resource import BaseResource
from bandwidth_numbers.models.data.tndetails import TndetailsData
+from bandwidth_numbers.models.messaging_settings import MessagingSettings
+from bandwidth_numbers.models.site import Site
+from bandwidth_numbers.models.sip_peer import SipPeer
XML_NAME_TNDETAILS = "TelephoneNumberDetails"
XPATH_TNDETAILS = "/tndetails"
@@ -16,9 +19,34 @@ class Tndetails(BaseResource, TndetailsData):
_node_name = XML_NAME_TNDETAILS
_xpath = XPATH_TNDETAILS
+ @property
+ def site(self):
+ return self._site
+ @site.setter
+ def site(self, site):
+ self._site = site
+
+ @property
+ def sip_peer(self):
+ return self._sip_peer
+ @sip_peer.setter
+ def sip_peer(self, sip_peer):
+ self._sip_peer = sip_peer
+
+ @property
+ def messaging_settings(self):
+ return self._messaging_settings
+ @messaging_settings.setter
+ def messaging_settings(self, messaging_settings):
+ self._messaging_settings = messaging_settings
+
def __init__(self, parent=None, client=None):
super().__init__(parent, client)
TndetailsData.__init__(self)
+ self._site = Site(self, client)
+ self._sip_peer = SipPeer(self, client)
+ self._messaging_settings = MessagingSettings(self, client)
+
def get(self):
return self._get_data()
diff --git a/tests/test_tns.py b/tests/test_tns.py
index b9990f7..f6c3c18 100644
--- a/tests/test_tns.py
+++ b/tests/test_tns.py
@@ -309,7 +309,13 @@ def test_tndetails(self):
self.assertEqual(tnd.account_id, "14")
self.assertEqual(tnd.last_modified, "2014-07-30T11:29:37.000Z")
self.assertEqual(tnd.features.lidb.status, "Pending")
- self.assertEqual(tnd.sip_peer.peer_id, "971438")
+ self.assertEqual(tnd.messaging_settings.sms_enabled, 'true')
+ self.assertEqual(tnd.messaging_settings.campaign_id, 'CU9B04M')
+ self.assertEqual(tnd.messaging_settings.message_class, 'Campaign-E')
+ self.assertEqual(tnd.site.id, '135927')
+ self.assertEqual(tnd.site.name, 'PROD')
+ self.assertEqual(tnd.sip_peer.peer_id, '971438')
+ self.assertEqual(tnd.sip_peer.peer_name, 'Uptravi')
def test_tnreservation(self):