mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-09 23:02:13 -05:00
Add endpoint to get inbound by id
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
import uuid
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
jsonify,
|
||||
request
|
||||
)
|
||||
from werkzeug.exceptions import abort
|
||||
|
||||
from notifications_utils.recipients import validate_and_format_phone_number
|
||||
|
||||
from app.dao.inbound_sms_dao import dao_get_inbound_sms_for_service, dao_count_inbound_sms_for_service
|
||||
from app.dao.inbound_sms_dao import (
|
||||
dao_get_inbound_sms_for_service,
|
||||
dao_count_inbound_sms_for_service,
|
||||
dao_get_inbound_sms_by_id
|
||||
)
|
||||
from app.errors import register_errors
|
||||
|
||||
inbound_sms = Blueprint(
|
||||
@@ -40,3 +48,16 @@ def get_inbound_sms_summary_for_service(service_id):
|
||||
count=count,
|
||||
most_recent=most_recent[0].created_at.isoformat() if most_recent else None
|
||||
)
|
||||
|
||||
|
||||
@inbound_sms.route('/<inbound_sms_id>', methods=['GET'])
|
||||
def get_inbound_by_id(service_id, inbound_sms_id):
|
||||
# TODO: Add JSON Schema here
|
||||
try:
|
||||
validated_uuid = uuid.UUID(inbound_sms_id)
|
||||
except (ValueError, AttributeError):
|
||||
abort(400)
|
||||
|
||||
inbound_sms = dao_get_inbound_sms_by_id(validated_uuid)
|
||||
|
||||
return jsonify(inbound_sms.serialize()), 200
|
||||
|
||||
Reference in New Issue
Block a user