From c447114297f2a5d2f64582a16cf5c6a2b258086c Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 7 Jan 2021 17:31:44 +0100 Subject: [PATCH] Added a ScanStation response class ref #67 --- src/models/responses/ResponseScanStation.ts | 62 +++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/models/responses/ResponseScanStation.ts diff --git a/src/models/responses/ResponseScanStation.ts b/src/models/responses/ResponseScanStation.ts new file mode 100644 index 0000000..6b147c9 --- /dev/null +++ b/src/models/responses/ResponseScanStation.ts @@ -0,0 +1,62 @@ +import { + + IsInt, + + IsNotEmpty, + + IsObject, + + IsOptional, + IsString +} from "class-validator"; +import { ScanStation } from '../entities/ScanStation'; +import { ResponseTrack } from './ResponseTrack'; + +/** + * Defines the statsClient response. +*/ +export class ResponseScanStation { + /** + * The client's id. + */ + @IsInt() + id: number; + + /** + * The client's description. + */ + @IsString() + @IsOptional() + description?: string; + + /** + * The client's api key. + * Only visible on creation or regeneration. + */ + @IsString() + @IsOptional() + key: string; + + /** + * The client's api key prefix. + */ + @IsString() + @IsNotEmpty() + prefix: string; + + @IsObject() + @IsNotEmpty() + track: ResponseTrack; + + /** + * Creates a ResponseStatsClient object from a statsClient. + * @param client The statsClient the response shall be build for. + */ + public constructor(station: ScanStation) { + this.id = station.id; + this.description = station.description; + this.prefix = station.prefix; + this.key = "Only visible on creation."; + this.track = station.track; + } +}