mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 08:25:15 -05:00
Add endpoint to get the email reply to addresses for a service
- Changed the dao_get_reply_to_by_service_id method to return a list of results. - Added a GET /service/<service_id>/email-reply-to endpoint
This commit is contained in:
@@ -5,12 +5,17 @@ from app.models import ServiceEmailReplyTo
|
||||
|
||||
def create_or_update_email_reply_to(service_id, email_address):
|
||||
reply_to = dao_get_reply_to_by_service_id(service_id)
|
||||
if reply_to:
|
||||
reply_to.email_address = email_address
|
||||
dao_update_reply_to_email(reply_to)
|
||||
else:
|
||||
if len(reply_to) == 0:
|
||||
reply_to = ServiceEmailReplyTo(service_id=service_id, email_address=email_address)
|
||||
dao_create_reply_to_email_address(reply_to)
|
||||
elif len(reply_to) == 1:
|
||||
reply_to[0].email_address = email_address
|
||||
dao_update_reply_to_email(reply_to[0])
|
||||
else:
|
||||
raise InvalidRequest(
|
||||
"Multiple reply to email addresses were found, this method should not be used.",
|
||||
status_code=500
|
||||
)
|
||||
|
||||
|
||||
@transactional
|
||||
@@ -23,7 +28,7 @@ def dao_get_reply_to_by_service_id(service_id):
|
||||
ServiceEmailReplyTo
|
||||
).filter(
|
||||
ServiceEmailReplyTo.service_id == service_id
|
||||
).first()
|
||||
).all()
|
||||
return reply_to
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user