diff --git a/src/models/responses/ResponseSelfServiceOrganisation.ts b/src/models/responses/ResponseSelfServiceOrganisation.ts new file mode 100644 index 0000000..aa8ae8b --- /dev/null +++ b/src/models/responses/ResponseSelfServiceOrganisation.ts @@ -0,0 +1,38 @@ +import { IsArray, IsNotEmpty, IsString } from 'class-validator'; +import { RunnerOrganization } from '../entities/RunnerOrganization'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; +import { ResponseSelfServiceTeam } from './ResponseSelfServiceTeam'; + +/** + * Defines the runner selfservice organization response. + * Why? B/C runner's are not allowed to view all information available to admin users. +*/ +export class ResponseSelfServiceOrganisation implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.SELFSERVICEORGANIZATION; + + /** + * The org's name. + */ + @IsNotEmpty() + @IsString() + name: string; + + /** + * The org's teams (just containing name and id). + */ + @IsArray() + teams: ResponseSelfServiceTeam[]; + + public constructor(org: RunnerOrganization) { + this.name = org.name; + this.teams = new Array(); + for (let team of org.teams) { + this.teams.push(new ResponseSelfServiceTeam(team)); + } + } +} \ No newline at end of file