1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4pub type Line = Vec<Lines>;
5pub type Disruption = Vec<Disruptions>;
6pub type Arrival = Vec<Arrivals>;
7pub type StopPoint = Vec<StopPoints>;
8pub type DisruptionCategories = Vec<String>;
9pub type Modes = Vec<ValidMode>;
10pub type LServiceTypes = Vec<String>;
11pub type Serverities = Vec<Severity>;
12pub type Route = Vec<Routes>;
13pub type LineSeverity = Vec<LineSeverities>;
14pub type LineStatusBetweenDates = Vec<LineStatusesDates>;
15pub type LineStatusForModes = Vec<LineStatusesDates>;
16
17#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
18pub struct ApiException {
19 pub exception: String,
21 pub doc: String,
23 pub display: String,
25}
26
27#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct SearchLinesRoutesByQuery {
30 #[serde(rename = "$type")]
31 pub type_field: String,
32 pub input: String,
33 pub search_matches: Vec<SearchMatch>,
34}
35
36#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub struct SearchMatch {
39 #[serde(rename = "$type")]
40 pub type_field: String,
41 pub line_id: String,
42 pub mode: String,
43 pub line_name: String,
44 pub line_route_section: Vec<LineRouteSection>,
45 pub matched_route_sections: Vec<Value>,
46 pub matched_stops: Vec<Value>,
47}
48
49#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
50#[serde(rename_all = "camelCase")]
51pub struct LineRouteSection {
52 #[serde(rename = "$type")]
53 pub type_field: String,
54 pub route_id: i64,
55 pub direction: String,
56 pub destination: String,
57 pub from_station: String,
58 pub to_station: String,
59 pub service_type: String,
60 pub vehicle_destination_text: String,
61}
62
63#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65pub struct TimetableForStationWithDestinationByLineID {
66 #[serde(rename = "$type")]
67 pub type_field: String,
68 pub line_id: String,
69 pub line_name: String,
70 pub direction: String,
71 pub stations: Vec<Station>,
72 pub stops: Vec<Stop>,
73 pub timetable: Timetable,
74}
75
76#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
77#[serde(rename_all = "camelCase")]
78pub struct Stop {
79 #[serde(rename = "$type")]
80 pub type_field: String,
81 pub parent_id: Option<String>,
82 pub station_id: String,
83 pub ics_id: String,
84 pub top_most_parent_id: String,
85 pub modes: Vec<String>,
86 pub stop_type: String,
87 pub zone: String,
88 pub lines: Vec<Line2>,
89 pub status: bool,
90 pub id: String,
91 pub name: String,
92 pub lat: f64,
93 pub lon: f64,
94 pub has_disruption: Option<bool>,
95}
96
97#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
98#[serde(rename_all = "camelCase")]
99pub struct Timetable {
100 #[serde(rename = "$type")]
101 pub type_field: String,
102 pub departure_stop_id: String,
103 pub routes: Vec<TimetableRoute>,
104}
105
106#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
107#[serde(rename_all = "camelCase")]
108pub struct TimetableRoute {
109 #[serde(rename = "$type")]
110 pub type_field: String,
111 pub station_intervals: Vec<StationInterval>,
112 pub schedules: Vec<Schedule>,
113}
114
115#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
116#[serde(rename_all = "camelCase")]
117pub struct StationInterval {
118 #[serde(rename = "$type")]
119 pub type_field: String,
120 pub id: String,
121 pub intervals: Vec<Interval>,
122}
123
124#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
125#[serde(rename_all = "camelCase")]
126pub struct Interval {
127 #[serde(rename = "$type")]
128 pub type_field: String,
129 pub stop_id: String,
130 pub time_to_arrival: f64,
131}
132
133#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
134#[serde(rename_all = "camelCase")]
135pub struct Schedule {
136 #[serde(rename = "$type")]
137 pub type_field: String,
138 pub name: String,
139 pub known_journeys: Vec<KnownJourney>,
140 pub first_journey: FirstJourney,
141 pub last_journey: LastJourney,
142 pub periods: Vec<Period>,
143}
144
145#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
146#[serde(rename_all = "camelCase")]
147pub struct KnownJourney {
148 #[serde(rename = "$type")]
149 pub type_field: String,
150 pub hour: String,
151 pub minute: String,
152 pub interval_id: i64,
153}
154
155#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
156#[serde(rename_all = "camelCase")]
157pub struct FirstJourney {
158 #[serde(rename = "$type")]
159 pub type_field: String,
160 pub hour: String,
161 pub minute: String,
162 pub interval_id: i64,
163}
164
165#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
166#[serde(rename_all = "camelCase")]
167pub struct LastJourney {
168 #[serde(rename = "$type")]
169 pub type_field: String,
170 pub hour: String,
171 pub minute: String,
172 pub interval_id: i64,
173}
174
175#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
176#[serde(rename_all = "camelCase")]
177pub struct Period {
178 #[serde(rename = "$type")]
179 pub type_field: String,
180 #[serde(rename = "type")]
181 pub type_field2: String,
182 pub from_time: FromTime,
183 pub to_time: ToTime,
184 pub frequency: Option<Frequency>,
185}
186
187#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
188#[serde(rename_all = "camelCase")]
189pub struct FromTime {
190 #[serde(rename = "$type")]
191 pub type_field: String,
192 pub hour: String,
193 pub minute: String,
194}
195
196#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
197#[serde(rename_all = "camelCase")]
198pub struct ToTime {
199 #[serde(rename = "$type")]
200 pub type_field: String,
201 pub hour: String,
202 pub minute: String,
203}
204
205#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
206#[serde(rename_all = "camelCase")]
207pub struct Frequency {
208 #[serde(rename = "$type")]
209 pub type_field: String,
210 pub lowest_frequency: f64,
211 pub highest_frequency: f64,
212}
213
214#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
215#[serde(rename_all = "camelCase")]
216pub struct TimetableForStationByLineID {
217 #[serde(rename = "$type")]
218 pub type_field: String,
219 pub disambiguation: Disambiguation,
220}
221
222#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
223#[serde(rename_all = "camelCase")]
224pub struct Disambiguation {
225 #[serde(rename = "$type")]
226 pub type_field: String,
227 pub disambiguation_options: Vec<DisambiguationOption>,
228}
229
230#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
231#[serde(rename_all = "camelCase")]
232pub struct DisambiguationOption {
233 #[serde(rename = "$type")]
234 pub type_field: String,
235 pub description: String,
236 pub uri: String,
237}
238
239#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
240#[serde(rename_all = "camelCase")]
241pub struct LineStatusesDates {
242 #[serde(rename = "$type")]
243 pub type_field: String,
244 pub id: String,
245 pub name: String,
246 pub mode_name: String,
247 pub disruptions: Vec<Value>,
248 pub created: String,
249 pub modified: String,
250 pub line_statuses: Vec<LineStatusesBetweenDates>,
251 pub route_sections: Vec<Value>,
252 pub service_types: Vec<ServiceType>,
253 pub crowding: Crowding,
254}
255
256#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
257#[serde(rename_all = "camelCase")]
258pub struct LineStatusesBetweenDates {
259 #[serde(rename = "$type")]
260 pub type_field: String,
261 pub id: i64,
262 pub status_severity: i64,
263 pub status_severity_description: String,
264 pub created: String,
265 pub validity_periods: Vec<Value>,
266}
267
268#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
269#[serde(rename_all = "camelCase")]
270pub struct LineSeverities {
271 #[serde(rename = "$type")]
272 pub type_field: String,
273 pub id: String,
274 pub name: String,
275 pub mode_name: String,
276 pub disruptions: Vec<Value>,
277 pub created: String,
278 pub modified: String,
279 pub line_statuses: Vec<LineStatuses>,
280 pub route_sections: Vec<Value>,
281 pub service_types: Vec<ServiceType>,
282 pub crowding: Crowding,
283}
284
285#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
286#[serde(rename_all = "camelCase")]
287pub struct LineStatuses {
288 #[serde(rename = "$type")]
289 pub type_field: String,
290 pub id: i64,
291 pub line_id: String,
292 pub status_severity: i64,
293 pub status_severity_description: String,
294 pub reason: String,
295 pub created: String,
296 pub validity_periods: Vec<ValidityPeriod>,
297 pub disruption: SevDisruption,
298}
299
300#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
301#[serde(rename_all = "camelCase")]
302pub struct ValidityPeriod {
303 #[serde(rename = "$type")]
304 pub type_field: String,
305 pub from_date: String,
306 pub to_date: String,
307 pub is_now: bool,
308}
309
310#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
311#[serde(rename_all = "camelCase")]
312pub struct SevDisruption {
313 #[serde(rename = "$type")]
314 pub type_field: String,
315 pub category: String,
316 pub category_description: String,
317 pub description: String,
318 pub created: Option<String>,
319 pub affected_routes: Vec<Value>,
320 pub affected_stops: Vec<Value>,
321 pub additional_info: Option<String>,
322 pub closure_text: Option<String>,
323}
324
325#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
326#[serde(rename_all = "camelCase")]
327pub struct Routes {
328 #[serde(rename = "$type")]
329 pub type_field: String,
330 pub line_id: String,
332 pub line_name: String,
334 pub direction: String,
336 pub is_outbound_only: bool,
338 pub mode: String,
340 pub line_strings: Vec<String>,
342 pub stations: Vec<Station>,
344 pub stop_point_sequences: Vec<StopPointSequence>,
346 pub ordered_line_routes: Vec<OrderedLineRoute>,
348}
349
350#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
351#[serde(rename_all = "camelCase")]
352pub struct Station {
353 #[serde(rename = "$type")]
354 pub type_field: String,
355 pub station_id: Option<String>,
357 pub ics_id: String,
359 pub top_most_parent_id: Option<String>,
361 pub modes: Vec<String>,
363 pub stop_type: String,
365 pub zone: String,
367 pub lines: Vec<RouteLines>,
369 pub status: bool,
371 pub id: String,
373 pub name: String,
375 pub lat: f64,
377 pub lon: f64,
379}
380
381#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
382#[serde(rename_all = "camelCase")]
383pub struct RouteLines {
384 #[serde(rename = "$type")]
385 pub type_field: String,
386 pub id: String,
388 pub name: String,
390 pub uri: String,
392 #[serde(rename = "type")]
393 pub type_field2: String,
394 pub crowding: Crowding,
396 pub route_type: String,
398 pub status: String,
400}
401
402#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
403#[serde(rename_all = "camelCase")]
404pub struct StopPointSequence {
405 #[serde(rename = "$type")]
406 pub type_field: String,
407 pub line_id: String,
409 pub line_name: String,
411 pub direction: String,
413 pub branch_id: i64,
415 pub next_branch_ids: Vec<Value>,
417 pub prev_branch_ids: Vec<Value>,
419 pub stop_point: Vec<RouteStopPoint>,
421 pub service_type: String,
423}
424
425#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
426#[serde(rename_all = "camelCase")]
427pub struct RouteStopPoint {
428 #[serde(rename = "$type")]
429 pub type_field: String,
430 pub parent_id: Option<String>,
432 pub station_id: String,
434 pub ics_id: String,
436 pub top_most_parent_id: String,
438 pub modes: Vec<String>,
440 pub stop_type: String,
442 pub zone: String,
444 pub lines: Vec<Line2>,
446 pub status: bool,
448 pub id: String,
450 pub name: String,
452 pub lat: f64,
454 pub lon: f64,
456 pub has_disruption: Option<bool>,
458}
459
460#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
461#[serde(rename_all = "camelCase")]
462pub struct Line2 {
463 #[serde(rename = "$type")]
464 pub type_field: String,
465 pub id: String,
467 pub name: String,
469 pub uri: String,
471 #[serde(rename = "type")]
472 pub type_field2: String,
473 pub crowding: Crowding2,
475 pub route_type: String,
477 pub status: String,
479}
480
481#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
482#[serde(rename_all = "camelCase")]
483pub struct Crowding2 {
484 #[serde(rename = "$type")]
485 pub type_field: String,
486}
487
488#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
489#[serde(rename_all = "camelCase")]
490pub struct OrderedLineRoute {
491 #[serde(rename = "$type")]
492 pub type_field: String,
493 pub name: String,
495 pub naptan_ids: Vec<String>,
497 pub service_type: String,
499}
500
501#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
502#[serde(rename_all = "camelCase")]
503pub struct Severity {
504 #[serde(rename = "$type")]
505 pub type_field: String,
506 pub mode_name: String,
508 pub severity_level: i64,
510 pub description: String,
512}
513
514#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
515#[serde(rename_all = "camelCase")]
516pub struct ValidMode {
517 #[serde(rename = "$type")]
518 pub type_field: String,
519 pub is_tfl_service: bool,
521 pub is_fare_paying: bool,
523 pub is_scheduled_service: bool,
525 pub mode_name: String,
527}
528
529#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
531pub struct Version {
532 pub label: String,
534 pub timestamp: String,
536 pub version: String,
538}
539
540#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
541#[serde(rename_all = "camelCase")]
542pub struct StopPoints {
543 #[serde(rename = "$type")]
544 pub type_field: String,
545 pub naptan_id: String,
547 pub modes: Vec<String>,
549 pub ics_code: String,
551 pub stop_type: String,
553 pub station_naptan: String,
555 pub lines: Vec<StopPointLine>,
557 pub line_group: Vec<LineGroup>,
559 pub line_mode_groups: Vec<LineModeGroup>,
561 pub status: bool,
563 pub id: String,
565 pub common_name: String,
567 pub place_type: String,
569 pub additional_properties: Vec<AdditionalProperty>,
571 pub children: Vec<Children>,
573 pub lat: f64,
575 pub lon: f64,
577 pub hub_naptan_code: Option<String>,
579}
580
581#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
582#[serde(rename_all = "camelCase")]
583pub struct StopPointLine {
584 #[serde(rename = "$type")]
585 pub type_field: String,
586 pub id: String,
588 pub name: String,
590 pub uri: String,
592 #[serde(rename = "type")]
593 pub type_field2: String,
594 pub crowding: Crowding,
596 pub route_type: String,
598 pub status: String,
600}
601
602#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
603#[serde(rename_all = "camelCase")]
604pub struct LineGroup {
605 #[serde(rename = "$type")]
606 pub type_field: String,
607 pub naptan_id_reference: Option<String>,
609 pub station_atco_code: String,
611 pub line_identifier: Vec<String>,
613}
614
615#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
616#[serde(rename_all = "camelCase")]
617pub struct LineModeGroup {
618 #[serde(rename = "$type")]
619 pub type_field: String,
620 pub mode_name: String,
622 pub line_identifier: Vec<String>,
624}
625
626#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
627#[serde(rename_all = "camelCase")]
628pub struct AdditionalProperty {
629 #[serde(rename = "$type")]
630 pub type_field: String,
631 pub category: String,
633 pub key: String,
635 pub source_system_key: String,
637 pub value: String,
639}
640
641#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
642#[serde(rename_all = "camelCase")]
643pub struct Children {
644 #[serde(rename = "$type")]
645 pub type_field: String,
646 pub naptan_id: String,
648 pub modes: Vec<Value>,
650 pub ics_code: String,
652 pub station_naptan: String,
654 pub lines: Vec<Value>,
656 pub line_group: Vec<Value>,
658 pub line_mode_groups: Vec<Value>,
660 pub status: bool,
662 pub id: String,
664 pub common_name: String,
666 pub place_type: String,
668 pub additional_properties: Vec<Value>,
670 pub children: Vec<Value>,
672 pub lat: f64,
674 pub lon: f64,
676 pub hub_naptan_code: Option<String>,
678 pub indicator: Option<String>,
680}
681
682#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
683#[serde(rename_all = "camelCase")]
684pub struct Lines {
685 #[serde(rename = "$type")]
686 pub type_field: String,
687 pub id: String,
689 pub name: String,
691 pub mode_name: String,
693 pub disruptions: Vec<Value>,
695 pub created: String,
697 pub modified: String,
699 pub line_statuses: Vec<Value>,
701 pub route_sections: Vec<RouteSection>,
703 pub service_types: Vec<ServiceType>,
705 pub crowding: Crowding,
707}
708
709#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
710#[serde(rename_all = "camelCase")]
711pub struct RouteSection {
712 #[serde(rename = "$type")]
713 pub type_field: String,
714 pub name: String,
716 pub direction: String,
718 pub origination_name: String,
720 pub destination_name: String,
722 pub originator: String,
724 pub destination: String,
726 pub service_type: String,
728 pub valid_to: String,
730 pub valid_from: String,
732}
733
734#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
735#[serde(rename_all = "camelCase")]
736pub struct ServiceType {
737 #[serde(rename = "$type")]
738 pub type_field: String,
739 pub name: String,
741 pub uri: String,
743}
744
745#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
746#[serde(rename_all = "camelCase")]
747pub struct Crowding {
748 #[serde(rename = "$type")]
749 pub type_field: String,
750}
751
752#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
753#[serde(rename_all = "camelCase")]
754pub struct Disruptions {
755 #[serde(rename = "$type")]
756 pub type_field: String,
757 pub category: String,
759 #[serde(rename = "type")]
760 pub type_field2: String,
761 pub category_description: String,
763 pub description: String,
765 pub created: Option<String>,
767 pub last_update: Option<String>,
769 pub affected_routes: Vec<Value>,
771 pub affected_stops: Vec<Value>,
773 pub closure_text: Option<String>,
775}
776
777#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
778#[serde(rename_all = "camelCase")]
779#[serde(default)]
780pub struct Arrivals {
781 #[serde(rename = "$type")]
782 pub type_field: String,
783 pub id: String,
784 pub operation_type: i64,
785 pub vehicle_id: String,
786 pub naptan_id: String,
787 pub station_name: String,
788 pub line_id: String,
789 pub line_name: String,
790 pub platform_name: String,
791 pub direction: Option<String>,
792 pub bearing: String,
793 pub destination_naptan_id: String,
794 pub destination_name: String,
795 pub timestamp: String,
796 pub time_to_station: i64,
797 pub current_location: String,
798 pub towards: String,
799 pub expected_arrival: String,
800 pub time_to_live: String,
801 pub mode_name: String,
802 pub timing: Timing,
803}
804
805#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
806#[serde(rename_all = "camelCase")]
807pub struct Timing {
808 #[serde(rename = "$type")]
809 pub type_field: String,
810 pub countdown_server_adjustment: String,
811 pub source: String,
812 pub insert: String,
813 pub read: String,
814 pub sent: String,
815 pub received: String,
816}
817
818#[derive(Debug)]
819pub enum ServiceTypes {
820 Regular,
821 Night,
822}
823
824impl ServiceTypes {
825 pub fn to_type(&self) -> &'static str {
826 match self {
827 ServiceTypes::Regular => "Regular",
828 ServiceTypes::Night => "Night",
829 }
830 }
831}
832pub enum Directions {
833 Inbound,
834 Outbound,
835 All,
836}
837
838impl Directions {
839 pub fn to_type(&self) -> &'static str {
840 match self {
841 Directions::Inbound => "Inbound",
842 Directions::Outbound => "Outbound",
843 Directions::All => "All",
844 }
845 }
846}
847
848pub enum Mode {
849 Tube,
850 DLR,
851 Bus,
852 RiverBus,
853 NationalRail,
854 Tram,
855 ElizabethLine,
856}
857
858impl Mode {
859 pub fn mode(&self) -> &'static str {
860 match self {
861 Mode::Tube => "Tube",
862 Mode::DLR => "DLR",
863 Mode::Bus => "Bus",
864 Mode::RiverBus => "river-bus",
865 Mode::NationalRail => "national-rail",
866 Mode::Tram => "Tram",
867 Mode::ElizabethLine => "elizabeth-line",
868 }
869 }
870}
871
872#[derive(Debug, Default, Serialize)]
873pub struct Parameters {
874 #[serde(flatten)]
875 pub lines: String,
876 pub line_id: String,
877 pub service_type: Option<String>,
878 pub modes: String,
879 pub stop_point_id: String,
880 pub from_stop_point_id: String,
881 pub to_stop_point_id: String,
882 pub direction: Option<String>,
883 pub destination_station_id: Option<String>,
884 pub tfl_operated_national_rail_stations_only: Option<bool>,
885 pub exclude_crowding: Option<bool>,
886 pub severity: Option<i8>,
887 pub start_date: String,
888 pub end_date: String,
889 pub detail: Option<bool>,
890 pub query: String,
891}