34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
export interface NotificationLookupArguments {
|
|
deviceId: string;
|
|
shuttleId: string;
|
|
stopId: string;
|
|
}
|
|
|
|
export interface ScheduledNotification extends NotificationLookupArguments {
|
|
/**
|
|
* Value which specifies the ETA of the shuttle for when
|
|
* the notification should fire.
|
|
* For example, a secondsThreshold of 180 would mean that the notification
|
|
* fires when the ETA drops below 3 minutes.
|
|
*/
|
|
secondsThreshold: number;
|
|
}
|
|
|
|
export type Listener = ((event: NotificationEvent) => any);
|
|
|
|
export interface NotificationEvent {
|
|
notification: ScheduledNotification,
|
|
event: 'delete' | 'addOrUpdate'
|
|
}
|
|
|
|
export interface NotificationRepository {
|
|
getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string): Promise<ScheduledNotification[]>;
|
|
getSecondsThresholdForNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<number | null>;
|
|
isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise<boolean>;
|
|
addOrUpdateNotification(notification: ScheduledNotification): Promise<void>;
|
|
deleteNotificationIfExists(lookupArguments: NotificationLookupArguments): Promise<void>;
|
|
|
|
subscribeToNotificationChanges(listener: Listener): void;
|
|
unsubscribeFromNotificationChanges(listener: Listener): void;
|
|
}
|