backend/source/api/actions/member_register.ts

126 lines
2.8 KiB
TypeScript

namespace _espe.api
{
/**
* @todo zeitliche Begrenzung?
*/
export function register_member_register(
rest_subject : lib_plankton.rest.type_rest
) : void
{
register<
{
email_use_veiled_address : boolean;
email_use_nominal_address : boolean;
email_redirect_to_private_address : boolean;
password : (null | string);
},
Array<
{
incident : string;
details : Record<string, any>;
}
>
>(
rest_subject,
lib_plankton.http.enum_method.post,
"/member/register/:id",
{
"description": "nimmt zusätzliche Angaben eines Mitglieds entgegen",
"input_schema": () => ({
"type": "object",
"nullable": false,
"additionalProperties": false,
"properties": {
"email_use_veiled_address": {
"type": "boolean",
"nullable": false,
},
"email_use_nominal_address": {
"type": "boolean",
"nullable": false,
},
"email_redirect_to_private_address": {
"type": "boolean",
"nullable": false,
},
"password": {
"type": "string",
"nullable": true,
},
},
"required": [
"email_use_veiled_address",
"email_use_nominal_address",
"email_redirect_to_private_address",
"password",
]
}),
"output_schema": () => ({
"nullable": false,
"type": "array",
"items": {
"nullable": false,
"type": "object",
"properties": {
"incident": {
"nullable": false,
"type": "string"
},
"details": {
"nullable": false,
"type": "object",
"properties": {},
"additionalProperties": {
"nullable": true
},
"required": []
},
},
"additionalProperties": false,
"required": [
"incident",
"details",
]
}
}),
"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": ({"path_parameters": path_parameters, "input": input}) => {
const member_id : _espe.type.member_id = parseInt(path_parameters["id"]);
return (
_espe.service.member.register(
member_id,
{
"email_use_veiled_address": input.email_use_veiled_address,
"email_use_nominal_address": input.email_use_nominal_address,
"email_redirect_to_private_address": input.email_redirect_to_private_address,
"password": input.password,
}
)
.then(
flaws => Promise.resolve({
"status_code": (
(flaws.length <= 0)
? 200
: 409
),
"data": flaws
})
)
);
},
}
)
}
}