mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-07 07:18:26 -04:00
Refactor user/<user_id>/code into two endpoints.
- Created new endpoint user/<user_id>/sms-code to send the sms verification code to the user. - Create new endpoirtn user/<user_id>/email-code to send the email verifcation code to the user. - Marked the old methods, schema, tests with a TODO to be deleted when the admin app is no longer sending messages to /user/<user_id>/code - Added error handlers for DataError and NoResultFound. Data error catches invalid input errors. - Added error handler for SqlAlchemyError which catches any other database errors. - Removed the need for the try catches around the db calls in the user endpoints with the addition of the db error handlers. - We may want to wrap db excpetions in the dao, if we want the No results found message to be more specific and say no result found for user.
This commit is contained in:
@@ -62,7 +62,8 @@ class JobSchema(BaseSchema):
|
||||
model = models.Job
|
||||
|
||||
|
||||
class RequestVerifyCodeSchema(ma.Schema):
|
||||
# TODO: Remove this schema once the admin app has stopped using the /user/<user_id>code endpoint
|
||||
class OldRequestVerifyCodeSchema(ma.Schema):
|
||||
|
||||
code_type = fields.Str(required=True)
|
||||
to = fields.Str(required=False)
|
||||
@@ -73,6 +74,10 @@ class RequestVerifyCodeSchema(ma.Schema):
|
||||
raise ValidationError('Invalid code type')
|
||||
|
||||
|
||||
class RequestVerifyCodeSchema(ma.Schema):
|
||||
to = fields.Str(required=False)
|
||||
|
||||
|
||||
# TODO main purpose to be added later
|
||||
# when processing templates, template will be
|
||||
# common for all notifications.
|
||||
@@ -154,6 +159,8 @@ api_keys_schema = ApiKeySchema(many=True)
|
||||
job_schema = JobSchema()
|
||||
job_schema_load_json = JobSchema(load_json=True)
|
||||
jobs_schema = JobSchema(many=True)
|
||||
# TODO: Remove this schema once the admin app has stopped using the /user/<user_id>code endpoint
|
||||
old_request_verify_code_schema = OldRequestVerifyCodeSchema()
|
||||
request_verify_code_schema = RequestVerifyCodeSchema()
|
||||
sms_admin_notification_schema = SmsAdminNotificationSchema()
|
||||
sms_template_notification_schema = SmsTemplateNotificationSchema()
|
||||
|
||||
Reference in New Issue
Block a user