diff --git a/src/models/responses/ResponseSelfServiceDonor.ts b/src/models/responses/ResponseSelfServiceDonor.ts new file mode 100644 index 0000000..9be0212 --- /dev/null +++ b/src/models/responses/ResponseSelfServiceDonor.ts @@ -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; + } +}