23 lines
637 B
Python
23 lines
637 B
Python
from flask import Blueprint, jsonify
|
|
from flask_apispec import use_kwargs
|
|
from marshmallow import fields
|
|
|
|
from api.exceptions import NotFoundException
|
|
from api.registration.models import Registration
|
|
from api.utils import docwrap
|
|
|
|
blueprint = Blueprint('webhook', __name__)
|
|
|
|
|
|
@docwrap('webhook', 'api_key')
|
|
@blueprint.route('/webhook', methods=['GET'])
|
|
@use_kwargs({'apikey': fields.String(required=True)}, location='query')
|
|
def webhook(apikey):
|
|
reg = Registration.query.filter_by(token=apikey).first()
|
|
|
|
if reg is None:
|
|
raise NotFoundException(Registration.__name__)
|
|
|
|
return jsonify({'response': repr(reg)})
|
|
pass
|