namespace _espe.api
{
	
	/**
	 */
	export function register_member_urge_for_registration(
		rest_subject : lib_plankton.rest.type_rest
	) : void
	{
		lib_plankton.rest.register<{id : int; url : string;}, null>(
			rest_subject,
			lib_plankton.http.enum_method.post,
			"/member/urge_for_registration",
			{
				"description": "sendet an ein Mitglied eine E-Mail mit Aufforderung zur Registrierung",
				"restriction": restriction_logged_in,
				"execution": async ({"input": input}) => {
					const member_id : _espe.service.member.type_id = input.id;
					const member_value : _espe.service.member.type_value = await _espe.service.member.get(member_id);
					const verification : string = await _espe.helpers.verification_get(member_id);
					
					await _espe.helpers.email_send(
						[
							member_value.email_address_private_value,
						],
						_espe.conf.get().settings.registration_email.subject,
						lib_plankton.string.coin(
							_espe.conf.get().settings.registration_email.body,
							{
								"name": member_value.name_real_value,
								"url": lib_plankton.string.coin(
									input.url,
									{
										"verification": verification,
									}
								),
							}
						)
					);
					
					return Promise.resolve({
						"status_code": 200,
						"data": null,
					});
				}
			}
		);
	}
	
}
