mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Added get provider by id
This commit is contained in:
@@ -91,9 +91,7 @@ def init_app(app):
|
||||
url_for('notifications.process_ses_response'),
|
||||
url_for('notifications.process_firetext_response'),
|
||||
url_for('notifications.process_mmg_response'),
|
||||
url_for('status.show_delivery_status'),
|
||||
url_for('provider_details.get_providers'),
|
||||
"/provider-details/41ade136-33bc-4151-be23-a04084cde50b"
|
||||
url_for('status.show_delivery_status')
|
||||
]
|
||||
if request.path not in no_auth_req:
|
||||
from app.authentication import auth
|
||||
|
||||
@@ -5,7 +5,7 @@ from app import db
|
||||
|
||||
|
||||
def get_provider_details():
|
||||
return ProviderDetails.query.order_by(asc(ProviderDetails.priority)).all()
|
||||
return ProviderDetails.query.order_by(asc(ProviderDetails.priority), asc(ProviderDetails.notification_type)).all()
|
||||
|
||||
|
||||
def get_provider_details_by_id(provider_details_id):
|
||||
|
||||
@@ -4,6 +4,7 @@ from app.schemas import provider_details_schema
|
||||
from app.dao.provider_details_dao import (
|
||||
get_provider_details,
|
||||
get_provider_details_by_id,
|
||||
get_provider_details_by_id,
|
||||
dao_update_provider_details
|
||||
)
|
||||
|
||||
@@ -16,6 +17,12 @@ def get_providers():
|
||||
return jsonify(provider_details=data)
|
||||
|
||||
|
||||
@provider_details.route('/<uuid:provider_details_id>', methods=['GET'])
|
||||
def get_provider_by_id(provider_details_id):
|
||||
data, errors = provider_details_schema.dump(get_provider_details_by_id(provider_details_id))
|
||||
return jsonify(provider_details=data)
|
||||
|
||||
|
||||
@provider_details.route('/<uuid:provider_details_id>', methods=['POST'])
|
||||
def update_provider_details(provider_details_id):
|
||||
fetched_provider_details = get_provider_details_by_id(provider_details_id)
|
||||
@@ -25,5 +32,11 @@ def update_provider_details(provider_details_id):
|
||||
update_dict, errors = provider_details_schema.load(current_data)
|
||||
if errors:
|
||||
return jsonify(result="error", message=errors), 400
|
||||
|
||||
if "identifier" in request.get_json().keys():
|
||||
return jsonify(message={
|
||||
"identifier": ["Not permitted to be updated"]
|
||||
}, result='error'), 400
|
||||
|
||||
dao_update_provider_details(update_dict)
|
||||
return jsonify(data=provider_details_schema.dump(fetched_provider_details).data), 200
|
||||
return jsonify(provider_details=provider_details_schema.dump(fetched_provider_details).data), 200
|
||||
|
||||
Reference in New Issue
Block a user