namespace _espe.api
{
	
	/**
	 */
	export function register_member_update(
		rest_subject : lib_plankton.rest.type_rest
	) : void
	{
		lib_plankton.rest.register<_espe.service.member.type_value, null>(
			rest_subject,
			lib_plankton.http.enum_method.patch,
			"/member/:id",
			{
				"description": "ändert ein vorhandenes Mitglied",
				"restriction": restriction_logged_in,
				"execution": async ({"path_parameters": path_parameters, "input": input}) => {
					const member_id : _espe.service.member.type_id = parseInt(path_parameters["id"]);
					const member_value_old : _espe.service.member.type_value = await _espe.service.member.get(member_id);
					const member_value_new : _espe.service.member.type_value = {
						"enabled": input["enabled"],
						"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": member_value_old.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"],
					};
					await _espe.service.member.modify(member_id, member_value_new);
					return Promise.resolve({
						"status_code": 200,
						"data": null
					});
				}
			}
		);
	}
	
}
