
namespace _zeitbild.api
{
	
	/**
	 */
	export function register_calendar_event_remove(
		rest_subject : lib_plankton.rest.type_rest
	) : void
	{
		register<
			null,
			(
				null
				|
				string
			)
		>(
			rest_subject,
			lib_plankton.http.enum_method.delete,
			"/calendar/:calendar_id/event/:event_id",
			{
				"description": "entfernt einen Termin",
				"output_schema": () => ({
					"nullable": true,
					"type": "null"
				}),
				"restriction": restriction_logged_in,
				"execution": async (stuff) => {
					const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
					const user_id : _zeitbild.type_user_id = await _zeitbild.service.user.identify(session.value.name);
					
					return (
						_zeitbild.service.calendar.event_remove(
							parseInt(stuff.path_parameters["calendar_id"]),
							parseInt(stuff.path_parameters["event_id"]),
							user_id
						)
						.then(
							() => Promise.resolve({
								"status_code": 200,
								"data": null,
							})
						)
						.catch(
							(reason) => Promise.resolve({
								"status_code": 403,
								"data": String(reason),
							})
						)
					);
				}
			}
		);
	}
	
}
