import { IsNotEmpty, IsObject } from "class-validator";
import { RunnerTeam } from '../entities/RunnerTeam';
import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse';
import { ResponseRunnerGroup } from './ResponseRunnerGroup';
import type { ResponseRunnerOrganization } from './ResponseRunnerOrganization';

/**
 * Defines the runnerTeam response.
*/
export class ResponseRunnerTeam extends ResponseRunnerGroup implements IResponse {
    /**
    * The responseType.
    * This contains the type of class/entity this response contains.
    */
    responseType: ResponseObjectType = ResponseObjectType.RUNNERTEAM;

    /**
     * The runnerTeam's parent group (organization).
     */
    @IsObject()
    @IsNotEmpty()
    parentGroup?: ResponseRunnerOrganization;

    /**
     * Creates a ResponseRunnerTeam object from a runnerTeam.
     * @param team The team the response shall be build for.
     */
    public constructor(team: RunnerTeam) {
        super(team);
        if (team.parentGroup) { this.parentGroup = team.parentGroup.toResponse(); }
    }
}
