backend/source/api/actions/member_info.ts

122 lines
3 KiB
TypeScript
Raw Normal View History

2024-05-20 21:56:48 +02:00
/*
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
<https://www.gnu.org/licenses/>.
*/
2024-04-29 22:40:52 +02:00
namespace _espe.api
{
/**
* @todo zeitliche Begrenzung?
*/
export function register_member_info(
2025-04-03 06:19:19 +00:00
rest_subject : lib_plankton.rest_http.type_rest
2024-04-29 22:40:52 +02:00
) : void
{
2025-04-03 06:19:19 +00:00
lib_plankton.rest_http.register<
2024-04-29 22:40:52 +02:00
int,
(
null
|
{
name_real_value : string;
name_real_index : int;
name_login : string;
2024-05-27 18:12:15 +02:00
email_address_veiled : (null | string);
2024-04-29 22:40:52 +02:00
email_address_nominal : string;
}
)
>(
rest_subject,
lib_plankton.http.enum_method.get,
2025-04-03 06:19:19 +00:00
_espe.api.full_path("/member/info/:id"),
2024-04-29 22:40:52 +02:00
{
2025-04-03 06:19:19 +00:00
"description": () => "gibt Angaben über ein Mitglied aus, die für die Registrierung verwendet werden dürfen",
2024-04-29 22:40:52 +02:00
"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",
2024-05-27 18:12:15 +02:00
"nullable": true,
2024-04-29 22:40:52 +02:00
},
"email_address_nominal": {
"type": "string",
"nullable": false,
},
},
"required": [
"name_real_value",
"name_real_index",
"name_login",
"email_address_veiled",
"email_address_nominal",
]
}),
2025-04-03 06:19:19 +00:00
"query_parameters": () => [
2024-04-29 22:40:52 +02:00
{
"name": "key",
"required": true,
"description": "Zugriffs-Schlüssel",
},
],
2025-04-03 06:19:19 +00:00
"restriction": () => restriction_verification(
2024-04-29 22:40:52 +02:00
stuff => parseInt(stuff.path_parameters["id"]),
stuff => stuff.query_parameters["key"]
),
2025-04-03 06:19:19 +00:00
"execution": () => async ({"path_parameters": path_parameters, "input": input}) => {
2024-04-29 22:40:52 +02:00
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;
2024-05-27 18:12:15 +02:00
email_address_veiled : (null | string);
2024-04-29 22:40:52 +02:00
email_address_nominal : string;
}
) = await _espe.service.member.info(member_id);
return Promise.resolve({
"status_code": (
(data === null)
? 409
: 200
),
"data": data
});
},
}
)
}
}