Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWI-6056 Update tndetails.py to include messaging and location details #7

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bandwidth_numbers/models/data/messaging_settings.py
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions bandwidth_numbers/models/data/tndetails.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/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.data.messaging_settings import MessagingSettingsData


class TndetailsData(TndetailsMap, BaseData):

Expand All @@ -13,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
Expand All @@ -22,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
10 changes: 10 additions & 0 deletions bandwidth_numbers/models/maps/messaging_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/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
5 changes: 5 additions & 0 deletions bandwidth_numbers/models/maps/tndetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from bandwidth_numbers.models.maps.base_map import BaseMap


class TndetailsMap(BaseMap):

account_id = None
Expand All @@ -16,3 +17,7 @@ class TndetailsMap(BaseMap):
tier = None
vendor_id = None
vendor_name = None
site = None
sip_peer = None
service_types = None
messaging_settings = None
11 changes: 11 additions & 0 deletions bandwidth_numbers/models/messaging_settings.py
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions bandwidth_numbers/models/tndetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
11 changes: 11 additions & 0 deletions tests/test_tns.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
b"<VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName>"
b"<RateCenter>JERSEYCITY</RateCenter><Status>Inservice</Status>"
b"<AccountId>14</AccountId>"
b"<Site><Id>135927</Id><Name>PROD</Name></Site>"
b"<ServiceTypes><ServiceType>Voice</ServiceType><ServiceType>Messaging</ServiceType></ServiceTypes>"
b"<MessagingSettings><SmsEnabled>true</SmsEnabled><CampaignId>CU9B04M</CampaignId><MessageClass>Campaign-E</MessageClass><CampaignFullyProvisioned>true</CampaignFullyProvisioned><A2pState>overridden</A2pState><AssignedNnRoute><Nnid>103775</Nnid><Name>BW A2P - SVR - E151 (103775)</Name></AssignedNnRoute></MessagingSettings>"
b"<SipPeer><PeerId>971438</PeerId><PeerName>Uptravi</PeerName><IsDefaultPeer>false</IsDefaultPeer></SipPeer>"
b"<LastModified>2014-07-30T11:29:37.000Z</LastModified><Features>"
b"<E911><Status>Success</Status></E911><Lidb>"
b"<Status>Pending</Status>"
Expand Down Expand Up @@ -305,6 +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.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):

Expand Down