@@ -3,6 +3,7 @@ import { plainToInstance } from 'class-transformer';
33import got , { OptionsOfJSONResponseBody } from 'got' ;
44import { CONFIG } from '../../Library/Config' ;
55import { logger , LogMode } from '../../Library/Logger' ;
6+ import { GoTransitStop , GoTransitStopType } from './Stop' ;
67import { GoTransitTrainTrip } from './TrainTrip' ;
78import { GoTransitUnionDepartureTrip } from './UnionDeparture' ;
89
@@ -19,6 +20,7 @@ interface APIMetadata {
1920
2021 ErrorMessage : string ;
2122}
23+
2224interface APIResponse {
2325 Metadata : APIMetadata ;
2426}
@@ -61,6 +63,12 @@ export class GoTransit {
6163 return request . body ;
6264 }
6365
66+ /**
67+ * Gets all the trains soon arriving at Union and the platform allocation
68+ * if provided/same as the departure board/go tracker.
69+ *
70+ * @returns array of GoTransitUnionDepartureTrip
71+ */
6472 public async unionDepartures ( ) : Promise < GoTransitUnionDepartureTrip [ ] > {
6573 const response = await this . makeRequest <
6674 APIResponse & { AllDepartures : { Trip : GoTransitUnionDepartureTrip [ ] } }
@@ -72,11 +80,31 @@ export class GoTransit {
7280 ) ;
7381 }
7482
83+
84+ /**
85+ * Function to get all active trains within the Go Transit network.
86+ *
87+ * @returns All active trains in Go Network
88+ */
7589 public async getAllTrains ( ) : Promise < GoTransitTrainTrip [ ] > {
7690 const response = await this . makeRequest <
7791 APIResponse & { Trips : { Trip : GoTransitUnionDepartureTrip [ ] } }
7892 > ( 'ServiceataGlance/Trains/All' ) ;
7993
8094 return plainToInstance ( GoTransitTrainTrip , response . Trips . Trip ) ;
8195 }
96+
97+ /**
98+ * Get all Go Transit Stops within the network
99+ *
100+ * @returns Array of all Go Transit Bus Stops,
101+ * Bus Terminals, Bus & Train Stations, and Park & Ride Stops
102+ */
103+ public async getAllStops ( ) : Promise < GoTransitStop [ ] > {
104+ const response = await this . makeRequest <
105+ APIResponse & { Stations : { Station : GoTransitStop [ ] } }
106+ > ( 'Stop/All' ) ;
107+
108+ return plainToInstance ( GoTransitStop , response . Stations . Station ) ;
109+ }
82110}
0 commit comments