From cd2ce601c600cb731b973bb28c4e860af3eb0f59 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 9 Sep 2025 21:03:38 +0100 Subject: [PATCH] Add barebones function for getServiceDetailByRID --- src/clients/LdbClientV2.ts | 13 +++++++++---- src/types/ldb/LdbTypesV2.ts | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/clients/LdbClientV2.ts b/src/clients/LdbClientV2.ts index 131f11a..c9d1df7 100644 --- a/src/clients/LdbClientV2.ts +++ b/src/clients/LdbClientV2.ts @@ -1,5 +1,5 @@ import { GenericV2_ApiResponse } from "../types/generic/GenericTypesV2"; -import { LdbV2_Staff } from "../types/ldb/LdbTypesV2"; +import { LdbV2_ServiceDetail, LdbV2_Staff } from "../types/ldb/LdbTypesV2"; import { BaseOwlBoardClient } from "./client"; export class LdbClientV2 { @@ -16,16 +16,21 @@ export class LdbClientV2 { } // async getPublicLdb(station: string): Promise {} + + async getServiceDetailByRID(rid: string): Promise { + const path = `/api/v2/live/train/rid/${rid}`; + return this.client.makeRequest("GET", path); + } } /* Calls to include: -[X] Staff LDB +[] Staff LDB - Need to validate input. [] Public LDB -[] Get Service by RID +[] Get Service by RID - NOT DONE, Types need revising on the backend. [] Get Service by 'Other?' -[] Get nearest stations +[X] Get nearest stations -- This has been implemented in the Reference Client */ \ No newline at end of file diff --git a/src/types/ldb/LdbTypesV2.ts b/src/types/ldb/LdbTypesV2.ts index 4d04eb5..05671a3 100644 --- a/src/types/ldb/LdbTypesV2.ts +++ b/src/types/ldb/LdbTypesV2.ts @@ -44,4 +44,19 @@ export interface LdbV2_ServiceLocation { tiploc: string; name?: string; via?: string; +} + +// This need improvement in the backend. Currently raw data from upstream is piped to the client +export interface LdbV2_ServiceDetail { + generatedAt: string; + rid: string; + uid: string; + trainid: string; + sdd: string; + operator: string; + operatorCode: string; + serviceType: string; + cancelReason: string; + category: string; + locations: []; } \ No newline at end of file