mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Add get letter contact by id endpoint
Added the GET /<uuid:service_id>/letter-contact/<uuid:letter_contact_id> endpoint for returning a letter contact for a service with the letter contact id Added the DAO for returning a letter contact by id
This commit is contained in:
@@ -19,6 +19,16 @@ def dao_get_letter_contacts_by_service_id(service_id):
|
||||
return letter_contacts
|
||||
|
||||
|
||||
def dao_get_letter_contact_by_id(service_id, letter_contact_id):
|
||||
letter_contact = db.session.query(
|
||||
ServiceLetterContact
|
||||
).filter(
|
||||
ServiceLetterContact.service_id == service_id,
|
||||
ServiceLetterContact.id == letter_contact_id
|
||||
).one()
|
||||
return letter_contact
|
||||
|
||||
|
||||
def create_or_update_letter_contact(service_id, contact_block):
|
||||
letter_contacts = dao_get_letter_contacts_by_service_id(service_id)
|
||||
if len(letter_contacts) == 0:
|
||||
|
||||
@@ -53,7 +53,11 @@ from app.dao.service_email_reply_to_dao import (
|
||||
dao_get_reply_to_by_service_id,
|
||||
update_reply_to_email_address
|
||||
)
|
||||
from app.dao.service_letter_contact_dao import dao_get_letter_contacts_by_service_id, create_or_update_letter_contact
|
||||
from app.dao.service_letter_contact_dao import (
|
||||
dao_get_letter_contacts_by_service_id,
|
||||
create_or_update_letter_contact,
|
||||
dao_get_letter_contact_by_id
|
||||
)
|
||||
from app.dao.provider_statistics_dao import get_fragment_count
|
||||
from app.dao.users_dao import get_user_by_id
|
||||
from app.errors import (
|
||||
@@ -577,6 +581,12 @@ def get_letter_contacts(service_id):
|
||||
return jsonify([i.serialize() for i in result]), 200
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/letter-contact/<uuid:letter_contact_id>', methods=["GET"])
|
||||
def get_letter_contact_by_id(service_id, letter_contact_id):
|
||||
result = dao_get_letter_contact_by_id(service_id=service_id, letter_contact_id=letter_contact_id)
|
||||
return jsonify(result.serialize()), 200
|
||||
|
||||
|
||||
@service_blueprint.route('/unique', methods=["GET"])
|
||||
def is_service_name_unique():
|
||||
name, email_from = check_request_args(request)
|
||||
|
||||
Reference in New Issue
Block a user