backend/src/models/responses/ResponseRunnerGroup.ts
Nicolai Ort ff7406e71a
All checks were successful
continuous-integration/drone/pr Build is passing
Cleaned up realations regarding response classes
ref #132
2021-01-30 16:19:42 +01:00

49 lines
1.2 KiB
TypeScript

import { IsInt, IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator";
import { RunnerGroup } from '../entities/RunnerGroup';
import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse';
import { ResponseGroupContact } from './ResponseGroupContact';
/**
* Defines the runnerGroup response.
*/
export abstract class ResponseRunnerGroup implements IResponse {
/**
* The responseType.
* This contains the type of class/entity this response contains.
*/
responseType: ResponseObjectType = ResponseObjectType.RUNNERGROUP;
/**
* The runnerGroup's id.
*/
@IsInt()
@IsNotEmpty()
id: number;;
/**
* The runnerGroup's name.
*/
@IsString()
@IsNotEmpty()
name: string;
/**
* The runnerGroup's contact.
*/
@IsObject()
@IsOptional()
contact?: ResponseGroupContact;
/**
* Creates a ResponseRunnerGroup object from a runnerGroup.
* @param group The runnerGroup the response shall be build for.
*/
public constructor(group: RunnerGroup) {
this.id = group.id;
this.name = group.name;
if (group.contact) { this.contact = group.contact.toResponse(); };
}
}