/* Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Backend Copyright (C) 2024 Christian Fraß This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ namespace _espe.api { /** * @todo zeitliche Begrenzung? */ export function register_member_info( rest_subject : lib_plankton.rest.type_rest ) : void { register< int, ( null | { name_real_value : string; name_real_index : int; name_login : string; email_address_veiled : string; email_address_nominal : string; } ) >( rest_subject, lib_plankton.http.enum_method.get, "/member/info/:id", { "description": "gibt Angaben über ein Mitglied aus, die für die Registrierung verwendet werden dürfen", "input_schema": () => ({ "type": "number", "nullable": false, }), "output_schema": () => ({ "type": "object", "nullable": false, "additionalProperties": false, "properties": { "name_real_value": { "type": "string", "nullable": false, }, "name_real_index": { "type": "number", "nullable": false, }, "name_login": { "type": "string", "nullable": false, }, "email_address_veiled": { "type": "string", "nullable": false, }, "email_address_nominal": { "type": "string", "nullable": false, }, }, "required": [ "name_real_value", "name_real_index", "name_login", "email_address_veiled", "email_address_nominal", ] }), "query_parameters": [ { "name": "key", "required": true, "description": "Zugriffs-Schlüssel", }, ], "restriction": restriction_verification( stuff => parseInt(stuff.path_parameters["id"]), stuff => stuff.query_parameters["key"] ), "execution": async ({"path_parameters": path_parameters, "input": input}) => { const member_id : _espe.type.member_id = parseInt(path_parameters["id"]); const data : ( null | { name_real_value : string; name_real_index : int; name_login : string; email_address_veiled : string; email_address_nominal : string; } ) = await _espe.service.member.info(member_id); return Promise.resolve({ "status_code": ( (data === null) ? 409 : 200 ), "data": data }); }, } ) } }