New class: ResponseSelfServiceDonor

ref #187
This commit is contained in:
Nicolai Ort 2021-04-03 17:05:10 +02:00
parent 71e3d0efe2
commit d70c5b1bbc

View File

@ -0,0 +1,51 @@
import { IsInt, IsString } from "class-validator";
import { Donor } from '../entities/Donor';
import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse';
/**
* Defines the donor selfservice response.
* Why? B/C runner's are not allowed to view all information available to admin users.
*/
export class ResponseSelfServiceDonor implements IResponse {
/**
* The responseType.
* This contains the type of class/entity this response contains.
*/
responseType: ResponseObjectType = ResponseObjectType.SELFSERVICERUNNER;
/**
* The participant's id.
*/
@IsInt()
id: number;
/**
* The participant's first name.
*/
@IsString()
firstname: string;
/**
* The participant's middle name.
*/
@IsString()
middlename?: string;
/**
* The participant's last name.
*/
@IsString()
lastname: string;
/**
* Creates a ResponseSelfServiceDonor object from a runner.
* @param donor The donor the response shall be build for.
*/
public constructor(donor: Donor) {
this.id = donor.id;
this.firstname = donor.firstname;
this.middlename = donor.middlename;
this.lastname = donor.lastname;
}
}