mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
Endpoint for recording events in api.
An event has an id, a type and a blob of json attached.
This commit is contained in:
22
app/events/rest.py
Normal file
22
app/events/rest.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from flask import (
|
||||
Blueprint,
|
||||
jsonify,
|
||||
request
|
||||
)
|
||||
|
||||
from app.errors import register_errors
|
||||
from app.schemas import event_schema
|
||||
from app.dao.events_dao import dao_create_event
|
||||
|
||||
events = Blueprint('events', __name__, url_prefix='/events')
|
||||
register_errors(events)
|
||||
|
||||
|
||||
@events.route('', methods=['POST'])
|
||||
def create_event():
|
||||
data = request.get_json()
|
||||
event, errors = event_schema.load(data)
|
||||
if errors:
|
||||
return jsonify(result="error", message=errors), 400
|
||||
dao_create_event(event)
|
||||
return jsonify(data=event_schema.dump(event).data), 201
|
||||
Reference in New Issue
Block a user