mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
rename class to InterchangeSystem.ts and add builder arguments
This commit is contained in:
47
src/entities/InterchangeSystem.ts
Normal file
47
src/entities/InterchangeSystem.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { ShuttleRepositoryLoader } from "../loaders/ShuttleRepositoryLoader";
|
||||
import { ETANotificationScheduler } from "../notifications/schedulers/ETANotificationScheduler";
|
||||
import { TimedApiBasedShuttleRepositoryLoader } from "../loaders/TimedApiBasedShuttleRepositoryLoader";
|
||||
import { UnoptimizedInMemoryShuttleRepository } from "../repositories/UnoptimizedInMemoryShuttleRepository";
|
||||
import { RedisNotificationRepository } from "../repositories/RedisNotificationRepository";
|
||||
import { NotificationRepository } from "../repositories/NotificationRepository";
|
||||
import { ShuttleGetterSetterRepository } from "../repositories/ShuttleGetterSetterRepository";
|
||||
|
||||
export interface InterchangeSystemBuilderArguments {
|
||||
name: string;
|
||||
passioSystemId: string;
|
||||
}
|
||||
|
||||
export class InterchangeSystem {
|
||||
constructor(
|
||||
public systemId: string,
|
||||
public shuttleDataLoader: ShuttleRepositoryLoader,
|
||||
public shuttleRepository: ShuttleGetterSetterRepository,
|
||||
public notificationScheduler: ETANotificationScheduler,
|
||||
public notificationRepository: NotificationRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of the class where all composited
|
||||
* classes are correctly linked.
|
||||
* @param args
|
||||
* @param notificationRepository
|
||||
*/
|
||||
static build(
|
||||
args: InterchangeSystemBuilderArguments,
|
||||
notificationRepository: NotificationRepository = new RedisNotificationRepository()
|
||||
) {
|
||||
const shuttleRepository = new UnoptimizedInMemoryShuttleRepository();
|
||||
const shuttleDataLoader = new TimedApiBasedShuttleRepositoryLoader(args.passioSystemId, shuttleRepository);
|
||||
|
||||
const notificationScheduler = new ETANotificationScheduler(shuttleRepository, notificationRepository);
|
||||
|
||||
return new InterchangeSystem(
|
||||
args.name,
|
||||
shuttleDataLoader,
|
||||
shuttleRepository,
|
||||
notificationScheduler,
|
||||
notificationRepository,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user