namespace _espe.api
{
	
	/**
	 */
	export function register_email(
		rest_subject : lib_plankton.rest.type_rest
	) : void
	{
		lib_plankton.rest.register<
			{
				receivers : Array<string>;
				subject : string;
				content : string;
			},
			null
		>(
			rest_subject,
			lib_plankton.http.enum_method.post,
			"/email",
			{
				"description": "sendet eine E-Mail",
				"input_schema": () => ({
					"type": "object",
					"nullable": false,
					"properties": {
						"receivers": {
							"type": "array",
							"nullable": false,
							"items": {
								"type": "string",
								"nullable": false,
							}
						},
						"subject": {
							"type": "string",
							"nullable": false,
						},
						"content": {
							"type": "string",
							"nullable": false,
						},
					},
					"additionalProperties": false,
					"required": [
						"receivers",
						"subject",
						"content",
					]
				}),
				"output_schema": () => ({
					"nullable": true,
				}),
				"restriction": restriction_logged_in,
				"execution": async ({"input": input}) => {
					await _espe.helpers.email_send(
						input.receivers,
						input.subject,
						input.content
					);
					return Promise.resolve({
						"status_code": 200,
						"data": null,
					});
				},
			}
		);
	}
	
}
