47
									
								
								src/models/responses/ResponseRunnerCard.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								src/models/responses/ResponseRunnerCard.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
import { IsBoolean, IsEAN, IsInt, IsNotEmpty, IsObject, IsString } from "class-validator";
 | 
			
		||||
import { RunnerCard } from '../entities/RunnerCard';
 | 
			
		||||
import { ResponseRunner } from './ResponseRunner';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Defines the runner card response.
 | 
			
		||||
*/
 | 
			
		||||
export class ResponseRunnerCard {
 | 
			
		||||
    /**
 | 
			
		||||
     * The card's id.
 | 
			
		||||
     */
 | 
			
		||||
    @IsInt()
 | 
			
		||||
    id: number;;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The card's associated runner.
 | 
			
		||||
     * This is important to link scans to runners.
 | 
			
		||||
     */
 | 
			
		||||
    @IsObject()
 | 
			
		||||
    runner: ResponseRunner;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The card's code.
 | 
			
		||||
     */
 | 
			
		||||
    @IsEAN()
 | 
			
		||||
    @IsString()
 | 
			
		||||
    @IsNotEmpty()
 | 
			
		||||
    code: string;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Is the enabled valid (for fraud reasons).
 | 
			
		||||
     * The determination of validity will work differently for every child class.
 | 
			
		||||
     */
 | 
			
		||||
    @IsBoolean()
 | 
			
		||||
    enabled: boolean = true;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a ResponseRunnerCard object from a runner card.
 | 
			
		||||
     * @param card The card the response shall be build for.
 | 
			
		||||
     */
 | 
			
		||||
    public constructor(card: RunnerCard) {
 | 
			
		||||
        this.id = card.id;
 | 
			
		||||
        this.runner = card.runner.toResponse() || null;
 | 
			
		||||
        this.code = card.code;
 | 
			
		||||
        this.enabled = card.enabled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user