in api/wheel.py [0:0]
def create_wheel(event):
"""
Create a wheel. Requires a name
:param event: Lambda event containing the API Gateway request body including a name
{
"body":
{
"name": string wheel name,
}
}
:return: response dictionary containing new wheel object if successful
{
"body":
{
"id": string ID of the wheel (DDB Hash Key),
"name": string name of the wheel,
"participant_count": number of participants in the wheel,
"created_at": creation timestamp,
"updated_at": updated timestamp,
}
}
"""
create_timestamp = get_utc_timestamp()
body = event['body']
if body is None or not check_string(body.get('name', None)):
raise base.BadRequestError(
f"New wheels require a name that must be a string with a length of at least 1. Got: {body}"
)
wheel = {
'id': get_uuid(),
'name': body['name'],
'created_at': create_timestamp,
'updated_at': create_timestamp,
}
with choice_algorithm.wrap_wheel_creation(wheel):
Wheel.put_item(Item=wheel)
return wheel