/* 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 { /** */ export function register_invitation_read( rest_subject : lib_plankton.rest_http.type_rest ) : void { lib_plankton.rest_http.register< int, ( string | { key : string; expiry : (null | int); name_changeable : boolean; name_value : (null | string); email_address_changeable : boolean; email_address_value : (null | string); groups_changeable : boolean; groups_value : (null | Array); } ) >( rest_subject, lib_plankton.http.enum_method.get, _espe.api.full_path("/invitation/read"), { /** * @todo translation */ "description": () => "gibt die Daten einer Einladung anhand ihrer ID aus", "query_parameters": () => [ { "name": "id", "required": true, "description": "id", } ], "output_schema": () => ({ "type": "object", "nullable": false, "additionalProperties": false, "properties": { "expiry": { "nullable": true, "type": "integer", "description": "Ablaufzeitpunkt" }, "name_changeable": { "type": "boolean", "nullable": false, "description": "Name | änderbar" }, "name_value": { "type": "string", "nullable": true, "description": "Name | Wert" }, "email_address_changeable": { "type": "boolean", "nullable": false, "description": "E-Mail-Adresse | änderbar" }, "email_address_value": { "type": "string", "nullable": true, "description": "E-Mail-Adresse | Wert" }, "groups_changeable": { "type": "boolean", "nullable": false, "description": "Gruppen | änderbar" }, "groups_value": { "nullable": false, "type": "array", "items": { "type": "integer", "nullable": false, }, "description": "Gruppen | Wert" }, }, "required": [ "expiry", "name_mode", "name_value", "email_address_mode", "email_address_value", "groups_mode", "groups_value", ] }), "restriction": () => restriction_logged_in, "execution": () => ({"query_parameters": query_parameters, "input": input}) => { const invitation_id : _espe.type.invitation_id = parseInt(query_parameters["id"]); return ( _espe.service.invitation.get_by_id(invitation_id) .then( (invitation_object) => Promise.resolve({ "status_code": 200, "data": { "key": invitation_object.key, "expiry": invitation_object.expiry, "name_changeable": invitation_object.name_changeable, "name_value": invitation_object.name_value, "email_address_changeable": invitation_object.email_address_changeable, "email_address_value": invitation_object.email_address_value, "groups_changeable": invitation_object.groups_changeable, "groups_value": invitation_object.groups_value, } }) ) .catch( (error) => Promise.resolve({ "status_code": 404, "data": "not found" }) ) ); } } ); } }