74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import { IsInt, IsObject, IsOptional, IsString } from "class-validator";
|
|
import { Address } from '../entities/Address';
|
|
import { Participant } from '../entities/Participant';
|
|
import { ResponseObjectType } from '../enums/ResponseObjectType';
|
|
import { IResponse } from './IResponse';
|
|
|
|
/**
|
|
* Defines the participant response.
|
|
*/
|
|
export abstract class ResponseParticipant implements IResponse {
|
|
/**
|
|
* The responseType.
|
|
* This contains the type of class/entity this response contains.
|
|
*/
|
|
responseType: ResponseObjectType = ResponseObjectType.PARTICIPANT;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
/**
|
|
* The participant's phone number.
|
|
*/
|
|
@IsString()
|
|
phone?: string;
|
|
|
|
/**
|
|
* The participant's e-mail address.
|
|
*/
|
|
@IsString()
|
|
email?: string;
|
|
|
|
/**
|
|
* The participant's address.
|
|
*/
|
|
@IsOptional()
|
|
@IsObject()
|
|
address?: Address;
|
|
|
|
/**
|
|
* Creates a ResponseParticipant object from a participant.
|
|
* @param participant The participant the response shall be build for.
|
|
*/
|
|
public constructor(participant: Participant) {
|
|
this.id = participant.id;
|
|
this.firstname = participant.firstname;
|
|
this.middlename = participant.middlename;
|
|
this.lastname = participant.lastname;
|
|
this.phone = participant.phone;
|
|
this.email = participant.email;
|
|
this.address = participant.address;
|
|
}
|
|
}
|