import { IsArray, IsBase64, IsBoolean, IsObject, IsOptional, IsString } from "class-validator"; import { Address } from '../entities/Address'; import { RunnerOrganization } from '../entities/RunnerOrganization'; import { RunnerTeam } from '../entities/RunnerTeam'; import { ResponseRunnerGroup } from './ResponseRunnerGroup'; /** * Defines the runnerOrganization response. */ export class ResponseRunnerOrganization extends ResponseRunnerGroup { /** * The runnerOrganization's address. */ @IsObject() @IsOptional() address?: Address; /** * The runnerOrganization associated teams. */ @IsArray() teams: RunnerTeam[]; /** * The organization's registration key. * If registration is disabled this is null. */ @IsString() @IsOptional() @IsBase64() registrationKey?: string; /** * Is registration enabled for the organization? */ @IsOptional() @IsBoolean() registrationEnabled?: boolean = true; /** * Creates a ResponseRunnerOrganization object from a runnerOrganization. * @param org The runnerOrganization the response shall be build for. */ public constructor(org: RunnerOrganization) { super(org); this.address = org.address; this.teams = org.teams; if (!org.key) { this.registrationEnabled = false; } else { this.registrationKey = Buffer.from(org.key).toString('base64'); } } }