From db097b00dcacff4c3702b8bc25acde3160c66e66 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Sun, 6 Apr 2025 10:43:34 -0700 Subject: [PATCH] rename class to InterchangeSystem.ts and add builder arguments --- src/ServerContext.ts | 4 ++-- .../{System.ts => InterchangeSystem.ts} | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) rename src/entities/{System.ts => InterchangeSystem.ts} (84%) diff --git a/src/ServerContext.ts b/src/ServerContext.ts index 93cd9ca..bccfcf2 100644 --- a/src/ServerContext.ts +++ b/src/ServerContext.ts @@ -1,5 +1,5 @@ -import { System } from "./entities/System"; +import { InterchangeSystem } from "./entities/InterchangeSystem"; export interface ServerContext { - systems: System[]; + systems: InterchangeSystem[]; } diff --git a/src/entities/System.ts b/src/entities/InterchangeSystem.ts similarity index 84% rename from src/entities/System.ts rename to src/entities/InterchangeSystem.ts index 456fd7a..a2af349 100644 --- a/src/entities/System.ts +++ b/src/entities/InterchangeSystem.ts @@ -6,7 +6,12 @@ import { RedisNotificationRepository } from "../repositories/RedisNotificationRe import { NotificationRepository } from "../repositories/NotificationRepository"; import { ShuttleGetterSetterRepository } from "../repositories/ShuttleGetterSetterRepository"; -export class System { +export interface InterchangeSystemBuilderArguments { + name: string; + passioSystemId: string; +} + +export class InterchangeSystem { constructor( public systemId: string, public shuttleDataLoader: ShuttleRepositoryLoader, @@ -19,25 +24,24 @@ export class System { /** * Construct an instance of the class where all composited * classes are correctly linked. - * @param systemId + * @param args * @param notificationRepository */ static build( - systemId: string, + args: InterchangeSystemBuilderArguments, notificationRepository: NotificationRepository = new RedisNotificationRepository() ) { const shuttleRepository = new UnoptimizedInMemoryShuttleRepository(); - const shuttleDataLoader = new TimedApiBasedShuttleRepositoryLoader(systemId, shuttleRepository); + const shuttleDataLoader = new TimedApiBasedShuttleRepositoryLoader(args.passioSystemId, shuttleRepository); const notificationScheduler = new ETANotificationScheduler(shuttleRepository, notificationRepository); - const system = new System( - systemId, + return new InterchangeSystem( + args.name, shuttleDataLoader, shuttleRepository, notificationScheduler, notificationRepository, ); - return system; } }