tfl-api-wrapper 0.1.4

TFL API Wrapper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
use serde::{Deserialize, Serialize};
use serde_json::Value;

pub type Line = Vec<Lines>;
pub type Disruption = Vec<Disruptions>;
pub type Arrival = Vec<Arrivals>;
pub type StopPoint = Vec<StopPoints>;
pub type DisruptionCategories = Vec<String>;
pub type Modes = Vec<ValidMode>;
pub type LServiceTypes = Vec<String>;
pub type Serverities = Vec<Severity>;
pub type Route = Vec<Routes>;
pub type LineSeverity = Vec<LineSeverities>;
pub type LineStatusBetweenDates = Vec<LineStatusesDates>;
pub type LineStatusForModes = Vec<LineStatusesDates>;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ApiException {
    /// A string representing the class of exception.
    pub exception: String,
    /// Readable error message
    pub doc: String,
    /// TBD
    pub display: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchLinesRoutesByQuery {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub input: String,
    pub search_matches: Vec<SearchMatch>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchMatch {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub line_id: String,
    pub mode: String,
    pub line_name: String,
    pub line_route_section: Vec<LineRouteSection>,
    pub matched_route_sections: Vec<Value>,
    pub matched_stops: Vec<Value>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineRouteSection {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub route_id: i64,
    pub direction: String,
    pub destination: String,
    pub from_station: String,
    pub to_station: String,
    pub service_type: String,
    pub vehicle_destination_text: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TimetableForStationWithDestinationByLineID {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub line_id: String,
    pub line_name: String,
    pub direction: String,
    pub stations: Vec<Station>,
    pub stops: Vec<Stop>,
    pub timetable: Timetable,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Stop {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub parent_id: Option<String>,
    pub station_id: String,
    pub ics_id: String,
    pub top_most_parent_id: String,
    pub modes: Vec<String>,
    pub stop_type: String,
    pub zone: String,
    pub lines: Vec<Line2>,
    pub status: bool,
    pub id: String,
    pub name: String,
    pub lat: f64,
    pub lon: f64,
    pub has_disruption: Option<bool>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Timetable {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub departure_stop_id: String,
    pub routes: Vec<TimetableRoute>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TimetableRoute {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub station_intervals: Vec<StationInterval>,
    pub schedules: Vec<Schedule>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StationInterval {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub id: String,
    pub intervals: Vec<Interval>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Interval {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub stop_id: String,
    pub time_to_arrival: f64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Schedule {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub name: String,
    pub known_journeys: Vec<KnownJourney>,
    pub first_journey: FirstJourney,
    pub last_journey: LastJourney,
    pub periods: Vec<Period>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KnownJourney {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub hour: String,
    pub minute: String,
    pub interval_id: i64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FirstJourney {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub hour: String,
    pub minute: String,
    pub interval_id: i64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LastJourney {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub hour: String,
    pub minute: String,
    pub interval_id: i64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Period {
    #[serde(rename = "$type")]
    pub type_field: String,
    #[serde(rename = "type")]
    pub type_field2: String,
    pub from_time: FromTime,
    pub to_time: ToTime,
    pub frequency: Option<Frequency>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FromTime {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub hour: String,
    pub minute: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToTime {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub hour: String,
    pub minute: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Frequency {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub lowest_frequency: f64,
    pub highest_frequency: f64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TimetableForStationByLineID {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub disambiguation: Disambiguation,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Disambiguation {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub disambiguation_options: Vec<DisambiguationOption>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DisambiguationOption {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub description: String,
    pub uri: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineStatusesDates {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub id: String,
    pub name: String,
    pub mode_name: String,
    pub disruptions: Vec<Value>,
    pub created: String,
    pub modified: String,
    pub line_statuses: Vec<LineStatusesBetweenDates>,
    pub route_sections: Vec<Value>,
    pub service_types: Vec<ServiceType>,
    pub crowding: Crowding,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineStatusesBetweenDates {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub id: i64,
    pub status_severity: i64,
    pub status_severity_description: String,
    pub created: String,
    pub validity_periods: Vec<Value>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineSeverities {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub id: String,
    pub name: String,
    pub mode_name: String,
    pub disruptions: Vec<Value>,
    pub created: String,
    pub modified: String,
    pub line_statuses: Vec<LineStatuses>,
    pub route_sections: Vec<Value>,
    pub service_types: Vec<ServiceType>,
    pub crowding: Crowding,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineStatuses {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub id: i64,
    pub line_id: String,
    pub status_severity: i64,
    pub status_severity_description: String,
    pub reason: String,
    pub created: String,
    pub validity_periods: Vec<ValidityPeriod>,
    pub disruption: SevDisruption,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ValidityPeriod {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub from_date: String,
    pub to_date: String,
    pub is_now: bool,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SevDisruption {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub category: String,
    pub category_description: String,
    pub description: String,
    pub created: Option<String>,
    pub affected_routes: Vec<Value>,
    pub affected_stops: Vec<Value>,
    pub additional_info: Option<String>,
    pub closure_text: Option<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Routes {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Line ID
    pub line_id: String,
    /// Line name
    pub line_name: String,
    /// Line direction
    pub direction: String,
    /// Outbound only line
    pub is_outbound_only: bool,
    /// Mode
    pub mode: String,
    /// Line strings
    pub line_strings: Vec<String>,
    /// Stations on the line
    pub stations: Vec<Station>,
    /// Stop point sequences
    pub stop_point_sequences: Vec<StopPointSequence>,
    /// Ordered line routes
    pub ordered_line_routes: Vec<OrderedLineRoute>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Station {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Station ID
    pub station_id: Option<String>,
    /// ICS ID
    pub ics_id: String,
    /// Top most parent id
    pub top_most_parent_id: Option<String>,
    /// Modes
    pub modes: Vec<String>,
    /// Stop type
    pub stop_type: String,
    /// Station zone
    pub zone: String,
    /// Lines
    pub lines: Vec<RouteLines>,
    /// Status of the station
    pub status: bool,
    /// Station ID
    pub id: String,
    /// Station name
    pub name: String,
    /// Latitude
    pub lat: f64,
    /// Longitude
    pub lon: f64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RouteLines {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Line ID
    pub id: String,
    /// Line name
    pub name: String,
    /// URI
    pub uri: String,
    #[serde(rename = "type")]
    pub type_field2: String,
    /// Crowding stat
    pub crowding: Crowding,
    /// Route type
    pub route_type: String,
    /// Line status
    pub status: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StopPointSequence {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Line ID
    pub line_id: String,
    /// Line name
    pub line_name: String,
    /// Traveling direction
    pub direction: String,
    /// Branch ID
    pub branch_id: i64,
    /// Subsequent branch IDs
    pub next_branch_ids: Vec<Value>,
    /// Previous branch IDs
    pub prev_branch_ids: Vec<Value>,
    /// Stop points
    pub stop_point: Vec<RouteStopPoint>,
    /// Service type
    pub service_type: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RouteStopPoint {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Parent ID
    pub parent_id: Option<String>,
    /// Station ID
    pub station_id: String,
    /// ICS ID
    pub ics_id: String,
    /// Top most parent ID
    pub top_most_parent_id: String,
    /// Modes
    pub modes: Vec<String>,
    /// Stop type
    pub stop_type: String,
    /// Zone
    pub zone: String,
    /// Lines
    pub lines: Vec<Line2>,
    /// Status
    pub status: bool,
    /// Stop point ID
    pub id: String,
    /// Stop point name
    pub name: String,
    /// Latitude
    pub lat: f64,
    /// Longitude
    pub lon: f64,
    /// Does it has a reported disruption
    pub has_disruption: Option<bool>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Line2 {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Line ID
    pub id: String,
    /// Line name
    pub name: String,
    /// Line URI
    pub uri: String,
    #[serde(rename = "type")]
    pub type_field2: String,
    /// Crowding
    pub crowding: Crowding2,
    /// Route type
    pub route_type: String,
    /// Line status
    pub status: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Crowding2 {
    #[serde(rename = "$type")]
    pub type_field: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OrderedLineRoute {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Ordered line route name
    pub name: String,
    /// NAPTAN IDs
    pub naptan_ids: Vec<String>,
    /// Service type
    pub service_type: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Severity {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Transport mode name
    pub mode_name: String,
    /// Severity level
    pub severity_level: i64,
    /// Severity description
    pub description: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ValidMode {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Is mode type a TFL service
    pub is_tfl_service: bool,
    /// Is Fare paying service
    pub is_fare_paying: bool,
    /// Is it a scheduled service
    pub is_scheduled_service: bool,
    /// Name of the mode
    pub mode_name: String,
}

// Returned by TFl version endpoint
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Version {
    /// Labels returned by the API
    pub label: String,
    /// Timestamp returned from the API
    pub timestamp: String,
    /// Current TFL API version
    pub version: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StopPoints {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// NAPTAN ID
    pub naptan_id: String,
    /// List of modes
    pub modes: Vec<String>,
    /// ICS code
    pub ics_code: String,
    /// Stop type
    pub stop_type: String,
    /// Station NAPTAN
    pub station_naptan: String,
    /// List of lines
    pub lines: Vec<StopPointLine>,
    /// Line group
    pub line_group: Vec<LineGroup>,
    /// Line mode groups
    pub line_mode_groups: Vec<LineModeGroup>,
    /// Status
    pub status: bool,
    /// ID
    pub id: String,
    /// Common Name
    pub common_name: String,
    /// Place type
    pub place_type: String,
    /// Additional properties
    pub additional_properties: Vec<AdditionalProperty>,
    /// Children
    pub children: Vec<Children>,
    /// Latitude
    pub lat: f64,
    /// Longitude
    pub lon: f64,
    /// Hub NAPTAN code
    pub hub_naptan_code: Option<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StopPointLine {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Stop point line ID
    pub id: String,
    /// Stop point line name
    pub name: String,
    /// URI
    pub uri: String,
    #[serde(rename = "type")]
    pub type_field2: String,
    /// Crowding details
    pub crowding: Crowding,
    /// Route type
    pub route_type: String,
    /// Status
    pub status: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineGroup {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// NAPTAN ID reference for line group
    pub naptan_id_reference: Option<String>,
    /// Station atco code for line group
    pub station_atco_code: String,
    /// Line identifier for line group
    pub line_identifier: Vec<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LineModeGroup {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Mode name of line mode group
    pub mode_name: String,
    /// Line identifier
    pub line_identifier: Vec<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdditionalProperty {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Additional property category
    pub category: String,
    /// Additional property key
    pub key: String,
    /// Source system key
    pub source_system_key: String,
    /// Porperty value
    pub value: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Children {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Children NAPTAN ID
    pub naptan_id: String,
    /// Children modes
    pub modes: Vec<Value>,
    /// ICS Code
    pub ics_code: String,
    /// Station NAPTAN
    pub station_naptan: String,
    /// Lines
    pub lines: Vec<Value>,
    /// Line group
    pub line_group: Vec<Value>,
    /// Line mode groups
    pub line_mode_groups: Vec<Value>,
    /// Status
    pub status: bool,
    /// ID
    pub id: String,
    /// Common name
    pub common_name: String,
    /// Place type
    pub place_type: String,
    /// Additional properties
    pub additional_properties: Vec<Value>,
    /// Children
    pub children: Vec<Value>,
    /// Latitude
    pub lat: f64,
    /// Longitude
    pub lon: f64,
    /// Hub NAPTAN code
    pub hub_naptan_code: Option<String>,
    /// Indicator
    pub indicator: Option<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Lines {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Line ID
    pub id: String,
    /// Line name. E.g. Bakerloo
    pub name: String,
    /// Mode name of the line. E.g. Tube, DLR, Bus
    pub mode_name: String,
    /// Disruptions for the line
    pub disruptions: Vec<Value>,
    /// Created time
    pub created: String,
    /// Modified time
    pub modified: String,
    /// Line statuses
    pub line_statuses: Vec<Value>,
    /// Route section for the line
    pub route_sections: Vec<RouteSection>,
    /// Type of the service. E.g. Regular, Night
    pub service_types: Vec<ServiceType>,
    /// Crowding details for the line
    pub crowding: Crowding,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RouteSection {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Route section name
    pub name: String,
    /// Route direction
    pub direction: String,
    /// Route origin name
    pub origination_name: String,
    /// Route destination name
    pub destination_name: String,
    /// Route originator
    pub originator: String,
    /// Route destination
    pub destination: String,
    /// Service type of the route. E.g. Regular, Night
    pub service_type: String,
    /// Valid until
    pub valid_to: String,
    /// Valid from
    pub valid_from: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ServiceType {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Service type name
    pub name: String,
    /// Service type URI
    pub uri: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Crowding {
    #[serde(rename = "$type")]
    pub type_field: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Disruptions {
    #[serde(rename = "$type")]
    pub type_field: String,
    /// Disruption category
    pub category: String,
    #[serde(rename = "type")]
    pub type_field2: String,
    /// Description for disruption category
    pub category_description: String,
    /// Description
    pub description: String,
    /// Creation time for disruption
    pub created: Option<String>,
    /// Last update time for disruption
    pub last_update: Option<String>,
    /// Affected routes for disruption
    pub affected_routes: Vec<Value>,
    /// Affected stops for disruption
    pub affected_stops: Vec<Value>,
    /// closure text
    pub closure_text: Option<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(default)]
pub struct Arrivals {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub id: String,
    pub operation_type: i64,
    pub vehicle_id: String,
    pub naptan_id: String,
    pub station_name: String,
    pub line_id: String,
    pub line_name: String,
    pub platform_name: String,
    pub direction: Option<String>,
    pub bearing: String,
    pub destination_naptan_id: String,
    pub destination_name: String,
    pub timestamp: String,
    pub time_to_station: i64,
    pub current_location: String,
    pub towards: String,
    pub expected_arrival: String,
    pub time_to_live: String,
    pub mode_name: String,
    pub timing: Timing,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Timing {
    #[serde(rename = "$type")]
    pub type_field: String,
    pub countdown_server_adjustment: String,
    pub source: String,
    pub insert: String,
    pub read: String,
    pub sent: String,
    pub received: String,
}

#[derive(Debug)]
pub enum ServiceTypes {
    Regular,
    Night,
}

impl ServiceTypes {
    pub fn to_type(&self) -> &'static str {
        match self {
            ServiceTypes::Regular => "Regular",
            ServiceTypes::Night => "Night",
        }
    }
}
pub enum Directions {
    Inbound,
    Outbound,
    All,
}

impl Directions {
    pub fn to_type(&self) -> &'static str {
        match self {
            Directions::Inbound => "Inbound",
            Directions::Outbound => "Outbound",
            Directions::All => "All",
        }
    }
}

pub enum Mode {
    Tube,
    DLR,
    Bus,
    RiverBus,
    NationalRail,
    Tram,
    ElizabethLine,
}

impl Mode {
    pub fn mode(&self) -> &'static str {
        match self {
            Mode::Tube => "Tube",
            Mode::DLR => "DLR",
            Mode::Bus => "Bus",
            Mode::RiverBus => "river-bus",
            Mode::NationalRail => "national-rail",
            Mode::Tram => "Tram",
            Mode::ElizabethLine => "elizabeth-line",
        }
    }
}

#[derive(Debug, Default, Serialize)]
pub struct Parameters {
    #[serde(flatten)]
    pub lines: String,
    pub line_id: String,
    pub service_type: Option<String>,
    pub modes: String,
    pub stop_point_id: String,
    pub from_stop_point_id: String,
    pub to_stop_point_id: String,
    pub direction: Option<String>,
    pub destination_station_id: Option<String>,
    pub tfl_operated_national_rail_stations_only: Option<bool>,
    pub exclude_crowding: Option<bool>,
    pub severity: Option<i8>,
    pub start_date: String,
    pub end_date: String,
    pub detail: Option<bool>,
    pub query: String,
}