import {
    IsInt,
    IsPositive
} from "class-validator";
import { Principal } from '../entities/Principal';
import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse';

/**
 * Defines the principal response.
*/
export abstract class ResponsePrincipal implements IResponse {

    /**
    * The responseType.
    * This contains the type of class/entity this response contains.
    */
    responseType: ResponseObjectType = ResponseObjectType.PRINCIPAL;

    /**
     * The principal's id.
     */
    @IsInt()
    id: number;

    @IsInt()
    @IsPositive()
    created_at: number;

    @IsInt()
    @IsPositive()
    updated_at: number;

    /**
     * Creates a ResponsePrincipal object from a principal.
     * @param principal The principal the response shall be build for.
     */
    public constructor(principal: Principal) {
        this.id = principal.id;
        this.created_at = principal.created_at;
        this.updated_at = principal.updated_at;
    }
}
