namespace _espe.api
{
	
	/**
	 */
	export function register_member_create(
		rest_subject : lib_plankton.rest.type_rest
	) : void
	{
		lib_plankton.rest.register<_espe.service.member.type_value, _espe.service.member.type_id>(
			rest_subject,
			lib_plankton.http.enum_method.post,
			"/member",
			{
				"description": "erstellt ein neues Mitglied und gibt die erzeugte ID aus",
				"input_schema": () => ({
					"type": "object",
					"nullable": false,
					"additionalProperties": false,
					"properties": {
						"name": {
							"type": "string",
							"nullable": false,
						},
						"password_image": {
							"type": "string",
							"nullable": true,
						},
						"email_address": {
							"type": "string",
							"nullable": true,
						},
						"data": {
							"type": "object",
							"nullable": true,
							"properties": {
							},
							"additionalPropertis": {
								"type": "string",
								"nullable": false,
							},
							"required": [
							]
						},
					},
					"required": [
						"name",
					]
				}),
				"output_schema": () => ({
					"type": "integer",
					"nullable": false,
				}),
				"restriction": restriction_logged_in,
				"execution": async ({"input": input}) => {
					const member_value : _espe.service.member.type_value = {
						"enabled": false,
						"membership_number": input["membership_number"],
						"name_real_value": input["name_real_value"],
						"name_real_extension": input["name_real_extension"],
						"name_display": input["name_display"],
						"name_login": input["name_login"],
						"password_image": input["password_image"],
						"email_address_private_value": input["email_address_private_value"],
						"email_address_numberbased_use": input["email_address_numberbased_use"],
						"email_address_namebased_use": input["email_address_namebased_use"],
						"email_redirect_to_private": input["email_redirect_to_private"],
						"salutation": input["salutation"],
					};
					const member_id : _espe.service.member.type_id = await _espe.service.member.add(member_value);
					return Promise.resolve({
						"status_code": 201,
						"data": member_id
					});
				}
			}
		);
	}
	
}
