webhook endpoint
This commit is contained in:
3
api/webhook/__init__.py
Normal file
3
api/webhook/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""the webhook endpoint"""
|
||||
|
||||
from . import views
|
||||
22
api/webhook/views.py
Normal file
22
api/webhook/views.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user