From 9d5e486c6ddb4db87d36409fbd8bca1bf9659e9f Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 29 Jan 2021 17:06:43 +0100 Subject: [PATCH] Implemented the interface in all responses refr #132 --- src/models/responses/ResponseAuth.ts | 11 ++++++++++- src/models/responses/ResponseDistanceDonation.ts | 9 ++++++++- src/models/responses/ResponseDonation.ts | 11 ++++++++++- src/models/responses/ResponseDonor.ts | 9 ++++++++- src/models/responses/ResponseEmpty.ts | 10 +++++++++- src/models/responses/ResponseGroupContact.ts | 10 +++++++++- src/models/responses/ResponseLogout.ts | 10 +++++++++- src/models/responses/ResponseParticipant.ts | 10 +++++++++- src/models/responses/ResponsePermission.ts | 10 +++++++++- src/models/responses/ResponsePrincipal.ts | 10 +++++++++- src/models/responses/ResponseRunner.ts | 9 ++++++++- src/models/responses/ResponseRunnerCard.ts | 10 +++++++++- src/models/responses/ResponseRunnerGroup.ts | 10 +++++++++- src/models/responses/ResponseRunnerOrganization.ts | 9 ++++++++- src/models/responses/ResponseRunnerTeam.ts | 9 ++++++++- src/models/responses/ResponseScan.ts | 10 +++++++++- src/models/responses/ResponseScanStation.ts | 12 ++++++++++-- .../responses/ResponseSelfServiceDonation.ts | 10 +++++++++- src/models/responses/ResponseSelfServiceRunner.ts | 9 ++++++++- src/models/responses/ResponseStats.ts | 10 +++++++++- src/models/responses/ResponseStatsClient.ts | 10 +++++++++- src/models/responses/ResponseStatsOrganization.ts | 10 +++++++++- src/models/responses/ResponseStatsRunner.ts | 10 +++++++++- src/models/responses/ResponseStatsTeam.ts | 10 +++++++++- src/models/responses/ResponseTrack.ts | 10 +++++++++- src/models/responses/ResponseTrackScan.ts | 14 +++++++++++--- src/models/responses/ResponseUser.ts | 10 +++++++++- src/models/responses/ResponseUserGroup.ts | 10 +++++++++- src/models/responses/ResponseUserPermissions.ts | 10 +++++++++- 29 files changed, 260 insertions(+), 32 deletions(-) diff --git a/src/models/responses/ResponseAuth.ts b/src/models/responses/ResponseAuth.ts index 6948253..7c042ac 100644 --- a/src/models/responses/ResponseAuth.ts +++ b/src/models/responses/ResponseAuth.ts @@ -1,9 +1,18 @@ import { IsInt, IsString } from 'class-validator'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the repsonse auth. */ -export class ResponseAuth { +export class ResponseAuth implements IResponse { + + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.AUTH; + /** * The access_token - JWT shortterm access token. */ diff --git a/src/models/responses/ResponseDistanceDonation.ts b/src/models/responses/ResponseDistanceDonation.ts index 388ece0..a76d122 100644 --- a/src/models/responses/ResponseDistanceDonation.ts +++ b/src/models/responses/ResponseDistanceDonation.ts @@ -1,12 +1,19 @@ import { IsInt, IsObject, IsPositive } from 'class-validator'; import { DistanceDonation } from '../entities/DistanceDonation'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseDonation } from './ResponseDonation'; import { ResponseRunner } from './ResponseRunner'; /** * Defines the distance donation response. */ -export class ResponseDistanceDonation extends ResponseDonation { +export class ResponseDistanceDonation extends ResponseDonation implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.DISTANCEDONATION; /** * The donation's associated runner. diff --git a/src/models/responses/ResponseDonation.ts b/src/models/responses/ResponseDonation.ts index c2789e3..e29f11f 100644 --- a/src/models/responses/ResponseDonation.ts +++ b/src/models/responses/ResponseDonation.ts @@ -1,11 +1,20 @@ import { IsInt, IsNotEmpty, IsPositive } from "class-validator"; import { Donation } from '../entities/Donation'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseDonor } from './ResponseDonor'; /** * Defines the donation response. */ -export class ResponseDonation { +export class ResponseDonation implements IResponse { + + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.DONATION; + /** * The donation's id. */ diff --git a/src/models/responses/ResponseDonor.ts b/src/models/responses/ResponseDonor.ts index 5f659f9..2b1e3fc 100644 --- a/src/models/responses/ResponseDonor.ts +++ b/src/models/responses/ResponseDonor.ts @@ -2,12 +2,19 @@ import { IsBoolean, IsInt } from "class-validator"; import { Donor } from '../entities/Donor'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseParticipant } from './ResponseParticipant'; /** * Defines the donor response. */ -export class ResponseDonor extends ResponseParticipant { +export class ResponseDonor extends ResponseParticipant implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.DONOR; /** * Does this donor need a receipt? diff --git a/src/models/responses/ResponseEmpty.ts b/src/models/responses/ResponseEmpty.ts index 57b0543..d6e2018 100644 --- a/src/models/responses/ResponseEmpty.ts +++ b/src/models/responses/ResponseEmpty.ts @@ -1,9 +1,17 @@ import { IsString } from 'class-validator'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines a empty response object. */ -export class ResponseEmpty { +export class ResponseEmpty implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.EMPTY; + @IsString() response: string = "nothing here" } diff --git a/src/models/responses/ResponseGroupContact.ts b/src/models/responses/ResponseGroupContact.ts index 291dde5..4cd826d 100644 --- a/src/models/responses/ResponseGroupContact.ts +++ b/src/models/responses/ResponseGroupContact.ts @@ -1,12 +1,20 @@ import { IsInt, IsObject, IsString } from "class-validator"; import { Address } from '../entities/Address'; import { GroupContact } from '../entities/GroupContact'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseRunnerGroup } from './ResponseRunnerGroup'; /** * Defines the group contact response. */ -export class ResponseGroupContact { +export class ResponseGroupContact implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.GROUPCONTACT; + /** * The contact's id. */ diff --git a/src/models/responses/ResponseLogout.ts b/src/models/responses/ResponseLogout.ts index fdb8d49..8cd8ce9 100644 --- a/src/models/responses/ResponseLogout.ts +++ b/src/models/responses/ResponseLogout.ts @@ -1,9 +1,17 @@ import { IsString } from 'class-validator'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the logout response. */ -export class Logout { +export class Logout implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.LOGOUT; + /** * The logout's timestamp. */ diff --git a/src/models/responses/ResponseParticipant.ts b/src/models/responses/ResponseParticipant.ts index 93a6918..b5ca124 100644 --- a/src/models/responses/ResponseParticipant.ts +++ b/src/models/responses/ResponseParticipant.ts @@ -1,11 +1,19 @@ import { IsInt, IsObject, IsOptional, IsString } from "class-validator"; import { Address } from '../entities/Address'; import { Participant } from '../entities/Participant'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the participant response. */ -export abstract class ResponseParticipant { +export abstract class ResponseParticipant implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.PARTICIPANT; + /** * The participant's id. */ diff --git a/src/models/responses/ResponsePermission.ts b/src/models/responses/ResponsePermission.ts index a6b0bc1..5eb500d 100644 --- a/src/models/responses/ResponsePermission.ts +++ b/src/models/responses/ResponsePermission.ts @@ -7,12 +7,20 @@ import { import { Permission } from '../entities/Permission'; import { PermissionAction } from '../enums/PermissionAction'; import { PermissionTarget } from '../enums/PermissionTargets'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponsePrincipal } from './ResponsePrincipal'; /** * Defines the permission response. */ -export class ResponsePermission { +export class ResponsePermission implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.PERMISSION; + /** * The permission's id. */ diff --git a/src/models/responses/ResponsePrincipal.ts b/src/models/responses/ResponsePrincipal.ts index afd4dd1..8ad4414 100644 --- a/src/models/responses/ResponsePrincipal.ts +++ b/src/models/responses/ResponsePrincipal.ts @@ -2,11 +2,19 @@ import { IsInt } 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 { +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. diff --git a/src/models/responses/ResponseRunner.ts b/src/models/responses/ResponseRunner.ts index 0d2fb67..5820baf 100644 --- a/src/models/responses/ResponseRunner.ts +++ b/src/models/responses/ResponseRunner.ts @@ -4,12 +4,19 @@ import { } from "class-validator"; import { Runner } from '../entities/Runner'; import { RunnerGroup } from '../entities/RunnerGroup'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseParticipant } from './ResponseParticipant'; /** * Defines the runner response. */ -export class ResponseRunner extends ResponseParticipant { +export class ResponseRunner extends ResponseParticipant implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.RUNNER; /** * The runner's currently ran distance in meters. diff --git a/src/models/responses/ResponseRunnerCard.ts b/src/models/responses/ResponseRunnerCard.ts index f895a9c..84309be 100644 --- a/src/models/responses/ResponseRunnerCard.ts +++ b/src/models/responses/ResponseRunnerCard.ts @@ -1,11 +1,19 @@ import { IsBoolean, IsEAN, IsInt, IsNotEmpty, IsObject, IsString } from "class-validator"; import { RunnerCard } from '../entities/RunnerCard'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseRunner } from './ResponseRunner'; /** * Defines the runner card response. */ -export class ResponseRunnerCard { +export class ResponseRunnerCard implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.RUNNERCARD; + /** * The card's id. */ diff --git a/src/models/responses/ResponseRunnerGroup.ts b/src/models/responses/ResponseRunnerGroup.ts index 7be35a6..e9f6e56 100644 --- a/src/models/responses/ResponseRunnerGroup.ts +++ b/src/models/responses/ResponseRunnerGroup.ts @@ -1,11 +1,19 @@ import { IsInt, IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator"; import { GroupContact } from '../entities/GroupContact'; import { RunnerGroup } from '../entities/RunnerGroup'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the runnerGroup response. */ -export abstract class ResponseRunnerGroup { +export abstract class ResponseRunnerGroup implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.RUNNERGROUP; + /** * The runnerGroup's id. */ diff --git a/src/models/responses/ResponseRunnerOrganization.ts b/src/models/responses/ResponseRunnerOrganization.ts index dcafb53..37e9af5 100644 --- a/src/models/responses/ResponseRunnerOrganization.ts +++ b/src/models/responses/ResponseRunnerOrganization.ts @@ -12,12 +12,19 @@ import { import { Address } from '../entities/Address'; import { RunnerOrganization } from '../entities/RunnerOrganization'; import { RunnerTeam } from '../entities/RunnerTeam'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseRunnerGroup } from './ResponseRunnerGroup'; /** * Defines the runnerOrganization response. */ -export class ResponseRunnerOrganization extends ResponseRunnerGroup { +export class ResponseRunnerOrganization extends ResponseRunnerGroup implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.RUNNERORGANIZATION; /** * The runnerOrganization's address. diff --git a/src/models/responses/ResponseRunnerTeam.ts b/src/models/responses/ResponseRunnerTeam.ts index 50566cf..5d5760b 100644 --- a/src/models/responses/ResponseRunnerTeam.ts +++ b/src/models/responses/ResponseRunnerTeam.ts @@ -1,12 +1,19 @@ import { IsNotEmpty, IsObject } from "class-validator"; import { RunnerTeam } from '../entities/RunnerTeam'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseRunnerGroup } from './ResponseRunnerGroup'; import { ResponseRunnerOrganization } from './ResponseRunnerOrganization'; /** * Defines the runnerTeam response. */ -export class ResponseRunnerTeam extends ResponseRunnerGroup { +export class ResponseRunnerTeam extends ResponseRunnerGroup implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.RUNNERTEAM; /** * The runnerTeam's parent group (organization). diff --git a/src/models/responses/ResponseScan.ts b/src/models/responses/ResponseScan.ts index e666442..f8f2142 100644 --- a/src/models/responses/ResponseScan.ts +++ b/src/models/responses/ResponseScan.ts @@ -1,11 +1,19 @@ import { IsBoolean, IsInt, IsNotEmpty, IsPositive } from "class-validator"; import { Scan } from '../entities/Scan'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseRunner } from './ResponseRunner'; /** * Defines the scan response. */ -export class ResponseScan { +export class ResponseScan implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.SCAN; + /** * The scans's id. */ diff --git a/src/models/responses/ResponseScanStation.ts b/src/models/responses/ResponseScanStation.ts index 7d7dc48..455549b 100644 --- a/src/models/responses/ResponseScanStation.ts +++ b/src/models/responses/ResponseScanStation.ts @@ -11,12 +11,20 @@ import { IsString } from "class-validator"; import { ScanStation } from '../entities/ScanStation'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseTrack } from './ResponseTrack'; /** * Defines the statsClient response. */ -export class ResponseScanStation { +export class ResponseScanStation implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.SCANSTATION; + /** * The client's id. */ @@ -64,7 +72,7 @@ export class ResponseScanStation { this.description = station.description; this.prefix = station.prefix; this.key = "Only visible on creation."; - this.track = station.track; + this.track = station.track.toResponse(); this.enabled = station.enabled; } } diff --git a/src/models/responses/ResponseSelfServiceDonation.ts b/src/models/responses/ResponseSelfServiceDonation.ts index 4f10f3c..beb8fdc 100644 --- a/src/models/responses/ResponseSelfServiceDonation.ts +++ b/src/models/responses/ResponseSelfServiceDonation.ts @@ -1,11 +1,19 @@ import { IsInt, IsNotEmpty, IsPositive } from 'class-validator'; import { DistanceDonation } from '../entities/DistanceDonation'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the runner selfservice donation response. * Why? B/C runner's are not allowed to view all information available to admin users. */ -export class ResponseSelfServiceDonation { +export class ResponseSelfServiceDonation implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.SELFSERVICEDONATION; + /** * The donation's donor. */ diff --git a/src/models/responses/ResponseSelfServiceRunner.ts b/src/models/responses/ResponseSelfServiceRunner.ts index fa9a1f1..00fe9b9 100644 --- a/src/models/responses/ResponseSelfServiceRunner.ts +++ b/src/models/responses/ResponseSelfServiceRunner.ts @@ -3,6 +3,8 @@ import { DistanceDonation } from '../entities/DistanceDonation'; import { Runner } from '../entities/Runner'; import { RunnerGroup } from '../entities/RunnerGroup'; import { RunnerTeam } from '../entities/RunnerTeam'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseParticipant } from './ResponseParticipant'; import { ResponseSelfServiceDonation } from './ResponseSelfServiceDonation'; @@ -10,7 +12,12 @@ import { ResponseSelfServiceDonation } from './ResponseSelfServiceDonation'; * Defines the runner selfservice response. * Why? B/C runner's are not allowed to view all information available to admin users. */ -export class ResponseSelfServiceRunner extends ResponseParticipant { +export class ResponseSelfServiceRunner extends ResponseParticipant implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.SELFSERVICERUNNER; /** * The runner's currently ran distance in meters. diff --git a/src/models/responses/ResponseStats.ts b/src/models/responses/ResponseStats.ts index d184089..f3d36a3 100644 --- a/src/models/responses/ResponseStats.ts +++ b/src/models/responses/ResponseStats.ts @@ -7,12 +7,20 @@ import { RunnerOrganization } from '../entities/RunnerOrganization'; import { RunnerTeam } from '../entities/RunnerTeam'; import { Scan } from '../entities/Scan'; import { User } from '../entities/User'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the stats response. * The stats response calculates some basic stats for a dashboard or public display. */ -export class ResponseStats { +export class ResponseStats implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.STATS; + /** * The amount of runners registered in the system. */ diff --git a/src/models/responses/ResponseStatsClient.ts b/src/models/responses/ResponseStatsClient.ts index 4028e2a..7f10352 100644 --- a/src/models/responses/ResponseStatsClient.ts +++ b/src/models/responses/ResponseStatsClient.ts @@ -8,11 +8,19 @@ import { IsString } from "class-validator"; import { StatsClient } from '../entities/StatsClient'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the statsClient response. */ -export class ResponseStatsClient { +export class ResponseStatsClient implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.STATSCLIENT; + /** * The client's id. */ diff --git a/src/models/responses/ResponseStatsOrganization.ts b/src/models/responses/ResponseStatsOrganization.ts index 592435a..5339b55 100644 --- a/src/models/responses/ResponseStatsOrganization.ts +++ b/src/models/responses/ResponseStatsOrganization.ts @@ -4,12 +4,20 @@ import { IsString } from "class-validator"; import { RunnerOrganization } from '../entities/RunnerOrganization'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the org stats response. * This differs from the normal org responce. */ -export class ResponseStatsOrgnisation { +export class ResponseStatsOrgnisation implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.STATSORGANIZATION; + /** * The orgs's id. */ diff --git a/src/models/responses/ResponseStatsRunner.ts b/src/models/responses/ResponseStatsRunner.ts index 8b55983..bd0b212 100644 --- a/src/models/responses/ResponseStatsRunner.ts +++ b/src/models/responses/ResponseStatsRunner.ts @@ -5,12 +5,20 @@ import { } from "class-validator"; import { Runner } from '../entities/Runner'; import { RunnerGroup } from '../entities/RunnerGroup'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the runner stats response. * This differs from the normal runner responce. */ -export class ResponseStatsRunner { +export class ResponseStatsRunner implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.STATSRUNNER; + /** * The runner's id. */ diff --git a/src/models/responses/ResponseStatsTeam.ts b/src/models/responses/ResponseStatsTeam.ts index 362971a..b1fbd22 100644 --- a/src/models/responses/ResponseStatsTeam.ts +++ b/src/models/responses/ResponseStatsTeam.ts @@ -5,12 +5,20 @@ import { } from "class-validator"; import { RunnerGroup } from '../entities/RunnerGroup'; import { RunnerTeam } from '../entities/RunnerTeam'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the team stats response. * This differs from the normal team responce. */ -export class ResponseStatsTeam { +export class ResponseStatsTeam implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.STATSTEAM; + /** * The team's id. */ diff --git a/src/models/responses/ResponseTrack.ts b/src/models/responses/ResponseTrack.ts index 27ef813..a4bdea0 100644 --- a/src/models/responses/ResponseTrack.ts +++ b/src/models/responses/ResponseTrack.ts @@ -1,11 +1,19 @@ import { IsInt, IsOptional, IsString } from "class-validator"; import { TrackLapTimeCantBeNegativeError } from '../../errors/TrackErrors'; import { Track } from '../entities/Track'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; /** * Defines the track response. */ -export class ResponseTrack { +export class ResponseTrack implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.TRACK; + /** * The track's id. */ diff --git a/src/models/responses/ResponseTrackScan.ts b/src/models/responses/ResponseTrackScan.ts index d52b4f7..c92bd46 100644 --- a/src/models/responses/ResponseTrackScan.ts +++ b/src/models/responses/ResponseTrackScan.ts @@ -1,5 +1,7 @@ import { IsDateString, IsNotEmpty } from "class-validator"; import { TrackScan } from '../entities/TrackScan'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponseRunnerCard } from './ResponseRunnerCard'; import { ResponseScan } from './ResponseScan'; import { ResponseScanStation } from './ResponseScanStation'; @@ -8,10 +10,16 @@ import { ResponseTrack } from './ResponseTrack'; /** * Defines the trackScan response. */ -export class ResponseTrackScan extends ResponseScan { +export class ResponseTrackScan extends ResponseScan implements IResponse { /** - * The scan's associated track. - */ + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.TRACKSCAN; + + /** + * The scan's associated track. + */ @IsNotEmpty() track: ResponseTrack; diff --git a/src/models/responses/ResponseUser.ts b/src/models/responses/ResponseUser.ts index 884622c..598189f 100644 --- a/src/models/responses/ResponseUser.ts +++ b/src/models/responses/ResponseUser.ts @@ -7,12 +7,20 @@ import { } from "class-validator"; import { User } from '../entities/User'; import { UserGroup } from '../entities/UserGroup'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponsePrincipal } from './ResponsePrincipal'; /** * Defines the user response. */ -export class ResponseUser extends ResponsePrincipal { +export class ResponseUser extends ResponsePrincipal implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.USER; + /** * The user's first name. */ diff --git a/src/models/responses/ResponseUserGroup.ts b/src/models/responses/ResponseUserGroup.ts index e0276f9..9d1923f 100644 --- a/src/models/responses/ResponseUserGroup.ts +++ b/src/models/responses/ResponseUserGroup.ts @@ -1,12 +1,20 @@ import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator"; import { Permission } from '../entities/Permission'; import { UserGroup } from '../entities/UserGroup'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponsePrincipal } from './ResponsePrincipal'; /** * Defines the userGroup response. */ -export class ResponseUserGroup extends ResponsePrincipal { +export class ResponseUserGroup extends ResponsePrincipal implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.USERGROUP; + /** * The userGroup's name. */ diff --git a/src/models/responses/ResponseUserPermissions.ts b/src/models/responses/ResponseUserPermissions.ts index d5a8a7b..524398d 100644 --- a/src/models/responses/ResponseUserPermissions.ts +++ b/src/models/responses/ResponseUserPermissions.ts @@ -5,12 +5,20 @@ import { IsOptional } from "class-validator"; import { User } from '../entities/User'; +import { ResponseObjectType } from '../enums/ResponseObjectType'; +import { IResponse } from './IResponse'; import { ResponsePermission } from './ResponsePermission'; /** * Defines the user permission response (get /api/users/:id/permissions). */ -export class ResponseUserPermissions { +export class ResponseUserPermissions implements IResponse { + /** + * The responseType. + * This contains the type of class/entity this response contains. + */ + responseType: ResponseObjectType = ResponseObjectType.USERPERMISSIONS; + /** * The permissions directly granted to the user. */