Added selfservice org response model

ref #146
This commit is contained in:
Nicolai Ort 2021-02-24 18:20:31 +01:00
parent ba396e0eba
commit ba3b5eeefc
1 changed files with 38 additions and 0 deletions

View File

@ -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<ResponseSelfServiceTeam>();
for (let team of org.teams) {
this.teams.push(new ResponseSelfServiceTeam(team));
}
}
}