2017-04-25 14:56:16 +01:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
from flask import (
|
|
|
|
|
Blueprint,
|
|
|
|
|
jsonify,
|
|
|
|
|
request,
|
|
|
|
|
current_app,
|
|
|
|
|
json
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from app import statsd_client
|
|
|
|
|
from app.clients.email.aws_ses import get_aws_responses
|
2017-05-12 17:21:07 +01:00
|
|
|
from app.dao import (
|
|
|
|
|
notifications_dao
|
|
|
|
|
)
|
2017-05-09 14:20:56 +01:00
|
|
|
|
2017-05-12 17:21:07 +01:00
|
|
|
from app.notifications.process_client_response import validate_callback_data
|
2017-04-25 14:56:16 +01:00
|
|
|
|
|
|
|
|
letter_callback_blueprint = Blueprint('notifications_letter_callback', __name__)
|
2017-05-09 14:20:56 +01:00
|
|
|
|
2017-05-12 17:21:07 +01:00
|
|
|
from app.errors import (
|
|
|
|
|
register_errors,
|
|
|
|
|
InvalidRequest
|
|
|
|
|
)
|
2017-05-09 14:20:56 +01:00
|
|
|
|
2017-05-12 17:21:07 +01:00
|
|
|
register_errors(letter_callback_blueprint)
|
2017-04-25 14:56:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@letter_callback_blueprint.route('/notifications/letter/dvla', methods=['POST'])
|
|
|
|
|
def process_letter_response():
|
2017-05-12 17:21:07 +01:00
|
|
|
try:
|
|
|
|
|
dvla_request = json.loads(request.data)
|
|
|
|
|
current_app.logger.info(dvla_request)
|
|
|
|
|
return jsonify(
|
|
|
|
|
result="success", message="DVLA callback succeeded"
|
|
|
|
|
), 200
|
|
|
|
|
except ValueError:
|
|
|
|
|
error = "DVLA callback failed: invalid json"
|
|
|
|
|
raise InvalidRequest(error, status_code=400)
|