diff --git a/src/clients/LdbClientV2.ts b/src/clients/LdbClientV2.ts index 84c65f0..131f11a 100644 --- a/src/clients/LdbClientV2.ts +++ b/src/clients/LdbClientV2.ts @@ -1,3 +1,5 @@ +import { GenericV2_ApiResponse } from "../types/generic/GenericTypesV2"; +import { LdbV2_Staff } from "../types/ldb/LdbTypesV2"; import { BaseOwlBoardClient } from "./client"; export class LdbClientV2 { @@ -6,4 +8,24 @@ export class LdbClientV2 { constructor(client: BaseOwlBoardClient) { this.client = client; } -} \ No newline at end of file + + async getStaffLdb(station: string): Promise> { + // 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 {} +} + +/* + +Calls to include: + +[X] Staff LDB +[] Public LDB +[] Get Service by RID +[] Get Service by 'Other?' +[] Get nearest stations + +*/ \ No newline at end of file diff --git a/src/types/generic/GenericTypesV2.ts b/src/types/generic/GenericTypesV2.ts new file mode 100644 index 0000000..6dca3f7 --- /dev/null +++ b/src/types/generic/GenericTypesV2.ts @@ -0,0 +1,5 @@ +export interface GenericV2_ApiResponse { + obStatus: number, + obMsg: string, + data?: T +} \ No newline at end of file diff --git a/src/types/ldb/LdbTypesV2.ts b/src/types/ldb/LdbTypesV2.ts new file mode 100644 index 0000000..4d04eb5 --- /dev/null +++ b/src/types/ldb/LdbTypesV2.ts @@ -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; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index ac86154..79f80e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -50,7 +50,7 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ /* 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. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */