Add new endpoint to get available inbound number.

Add new endpoint to allocate a specific number to a given service.

This will allow the platform admin user to choose a number when setting the inbound_sms permission for a service.
This commit is contained in:
Rebecca Law
2017-09-21 15:18:52 +01:00
parent e6d6b6f985
commit 18581c754a
5 changed files with 112 additions and 4 deletions

View File

@@ -31,3 +31,17 @@ def dao_set_inbound_number_active_flag(service_id, active):
inbound_number.active = active
db.session.add(inbound_number)
@transactional
def dao_allocate_number_for_service(service_id, inbound_number_id):
updated = InboundNumber.query.filter_by(
id=inbound_number_id,
active=True,
service_id=None
).update(
{"service_id": service_id}
)
if not updated:
raise Exception("Inbound number: {} is not available".format(inbound_number_id))
return InboundNumber.query.get(inbound_number_id)