Add part LDB Client
All checks were successful
Testing / run-tests (push) Successful in 3m16s

This commit is contained in:
Fred Boniface 2025-09-08 21:04:28 +01:00
parent a5337323c7
commit c1406a3e34
4 changed files with 76 additions and 2 deletions

View File

@ -1,3 +1,5 @@
import { GenericV2_ApiResponse } from "../types/generic/GenericTypesV2";
import { LdbV2_Staff } from "../types/ldb/LdbTypesV2";
import { BaseOwlBoardClient } from "./client"; import { BaseOwlBoardClient } from "./client";
export class LdbClientV2 { export class LdbClientV2 {
@ -6,4 +8,24 @@ export class LdbClientV2 {
constructor(client: BaseOwlBoardClient) { constructor(client: BaseOwlBoardClient) {
this.client = client; this.client = client;
} }
async getStaffLdb(station: string): Promise<GenericV2_ApiResponse<LdbV2_Staff>> {
// Validate needs to accept TIPLOC or 3ALPHA
const path = `/api/v2/live/station/${station}/staff`;
return this.client.makeRequest("GET", path);
}
// async getPublicLdb(station: string): Promise<LdbV2_Public> {}
} }
/*
Calls to include:
[X] Staff LDB
[] Public LDB
[] Get Service by RID
[] Get Service by 'Other?'
[] Get nearest stations
*/

View File

@ -0,0 +1,5 @@
export interface GenericV2_ApiResponse<T> {
obStatus: number,
obMsg: string,
data?: T
}

View File

@ -0,0 +1,47 @@
export interface LdbV2_Staff {
generatedAt: Date;
locationName: string;
stationManagerCode: string;
nrccMessages?: LdbV2_StaffNrccMessage[];
trainServices?: LdbV2_StaffTrainServices[];
busServices?: LdbV2_StaffTrainServices[];
ferryServices?: LdbV2_StaffTrainServices[];
}
export interface LdbV2_StaffNrccMessage {
severity: string;
xhtmlMessage: string;
}
export interface LdbV2_StaffTrainServices {
rid: string;
uid: string;
trainid: string;
operatorCode: string;
isPassengerService?: string;
platform?: string;
platformIsHidden?: string;
serviceIsSupressed?: string;
origin: LdbV2_ServiceLocation[];
destination: LdbV2_ServiceLocation[];
length?: number;
isCancelled?: string;
cancelReason?: string;
delayReason?: string;
arrivalType?: string;
departureType?: string;
sta?: Date | string;
eta?: Date | string;
ata?: Date | string;
std?: Date | string;
etd?: Date | string;
atd?: Date | string;
[key: string]: any;
}
export interface LdbV2_ServiceLocation {
tiploc: string;
name?: string;
via?: string;
}

View File

@ -50,7 +50,7 @@
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */ /* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */