webhook endpoint

This commit is contained in:
Gardient
2021-09-30 23:01:16 +03:00
parent 04d70ba424
commit a0dbdc4ddf
7 changed files with 35 additions and 3 deletions

22
api/webhook/views.py Normal file
View 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