/
trainR.R
571 lines (559 loc) · 25.8 KB
/
trainR.R
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
#' @keywords internal
"_PACKAGE"
#' Get all public arrivals
#'
#' Get all public arrivals for the supplied CRS code within a defined time
#' window, including service details.
#'
#' @inheritParams process
#' @inheritParams request
#'
#' @return Tibble with arrival records. Each column is described below:
#' \describe{
#' \item{generatedAt}{The time at which the station board was generated.}
#' \item{locationName}{The name of the location that the station board is for.}
#' \item{crs}{The CRS code of the location that the station board is for.}
#' \item{filterLocationName}{If a filter was requested, the location name of
#' the filter location.}
#' \item{filtercrs}{If a filter was requested, the CRS code of the filter
#' location.}
#' \item{filterType}{If a filter was requested, the type of filter.}
#' \item{nrccMessages}{An optional list of textual messages that should be
#' displayed with the station board. The message may include embedded and XML
#' encoded HTML-like hyperlinks and paragraphs. The messages are typically
#' used to display important disruption information that applies to the
#' location that the station board was for. Any embedded \code{<p>} tags are
#' used to force a new-line in the output. Embedded \code{<a>} tags allow
#' links to external web pages that may provide more information. Output
#' channels that do not support HTML should strip out the \code{<a>} tags and
#' just leave the enclosed text.}
#' \item{platformAvailable}{An optional value that indicates if platform
#' information is available. If this value is present with the value "true"
#' then platform information will be returned in the service lists. If this
#' value is not present, or has the value "false", then the platform "heading"
#' should be suppressed in the user interface for this station board.}
#' \item{areServicesAvailable}{An optional value that indicates if services
#' are currently available for this station board. If this value is present
#' with the value "false" then no services will be returned in the service
#' lists. This value may be set, for example, if access to a station has been
#' closed to the public at short notice, even though the scheduled services
#' are still running. It would be usual in such cases for one of the
#' \code{nrccMessages} to describe why the list of services has been
#' suppressed.}
#' \item{trainServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{busServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{ferryServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' }
#' @source Documentation for the Live Departure Boards Web Service
#' (LDBWS / OpenLDBWS):
#' \url{http://lite.realtime.nationalrail.co.uk/openldbws/}
# @eval StationBoard_return()
#' @family OpenLDBSVWS requests
#' @export
#' @examples
#' \dontrun{
#' rdg_arr <- trainR::GetArrBoardWithDetailsRequest("RDG")
#' rdg_arr <- trainR::GetArrBoardWithDetailsRequest("RDG", filterCrs = "BRI")
#' trainR::print(rdg_arr)
#' }
GetArrBoardWithDetailsRequest <-
function(crs,
filterCrs = NA,
filterType = "from",
numRows = 150,
timeOffset = 0,
timeWindow = 120,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE) {
process(crs = crs,
filterCrs = filterCrs,
filterType = filterType,
numRows = numRows,
timeOffset = timeOffset,
timeWindow = timeWindow,
token = token,
url = url,
verbose = verbose,
class = "ArrBoardWithDetails")
}
#' Get all public arrivals and departures
#'
#' Get all public arrivals and departures for the supplied CRS code within a
#' defined time window, including service details.
#'
#' @inheritParams process
#' @inheritParams request
#'
#' @return Tibble with arrival and departure records. Each column is described
#' below:
#' \describe{
#' \item{generatedAt}{The time at which the station board was generated.}
#' \item{locationName}{The name of the location that the station board is for.}
#' \item{crs}{The CRS code of the location that the station board is for.}
#' \item{filterLocationName}{If a filter was requested, the location name of
#' the filter location.}
#' \item{filtercrs}{If a filter was requested, the CRS code of the filter
#' location.}
#' \item{filterType}{If a filter was requested, the type of filter.}
#' \item{nrccMessages}{An optional list of textual messages that should be
#' displayed with the station board. The message may include embedded and XML
#' encoded HTML-like hyperlinks and paragraphs. The messages are typically
#' used to display important disruption information that applies to the
#' location that the station board was for. Any embedded \code{<p>} tags are
#' used to force a new-line in the output. Embedded \code{<a>} tags allow
#' links to external web pages that may provide more information. Output
#' channels that do not support HTML should strip out the \code{<a>} tags and
#' just leave the enclosed text.}
#' \item{platformAvailable}{An optional value that indicates if platform
#' information is available. If this value is present with the value "true"
#' then platform information will be returned in the service lists. If this
#' value is not present, or has the value "false", then the platform "heading"
#' should be suppressed in the user interface for this station board.}
#' \item{areServicesAvailable}{An optional value that indicates if services
#' are currently available for this station board. If this value is present
#' with the value "false" then no services will be returned in the service
#' lists. This value may be set, for example, if access to a station has been
#' closed to the public at short notice, even though the scheduled services
#' are still running. It would be usual in such cases for one of the
#' \code{nrccMessages} to describe why the list of services has been
#' suppressed.}
#' \item{trainServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{busServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{ferryServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' }
#' @source Documentation for the Live Departure Boards Web Service
#' (LDBWS / OpenLDBWS):
#' \url{http://lite.realtime.nationalrail.co.uk/openldbws/}
#' @family OpenLDBSVWS requests
#' @export
#' @examples
#' \dontrun{
#' rdg<- trainR::GetArrDepBoardWithDetailsRequest("RDG")
#' rdg <- trainR::GetArrDepBoardWithDetailsRequest("RDG", filterCrs = "BRI")
#' trainR::print(rdg)
#' }
GetArrDepBoardWithDetailsRequest <-
function(crs,
filterCrs = NA,
filterType = "from",
numRows = 150,
timeOffset = 0,
timeWindow = 120,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE) {
process(crs = crs,
filterCrs = filterCrs,
filterType = filterType,
numRows = numRows,
timeOffset = timeOffset,
timeWindow = timeWindow,
token = token,
url = url,
verbose = verbose,
class = "ArrDepBoardWithDetails")
}
#' Get all public arrivals
#'
#' Get all public arrivals for the supplied CRS code within a defined time
#' window.
#'
#' @inheritParams process
#' @inheritParams request
#'
#' @return Tibble with arrival records. Each column is described below:
#' \describe{
#' \item{generatedAt}{The time at which the station board was generated.}
#' \item{locationName}{The name of the location that the station board is for.}
#' \item{crs}{The CRS code of the location that the station board is for.}
#' \item{filterLocationName}{If a filter was requested, the location name of
#' the filter location.}
#' \item{filtercrs}{If a filter was requested, the CRS code of the filter
#' location.}
#' \item{filterType}{If a filter was requested, the type of filter.}
#' \item{nrccMessages}{An optional list of textual messages that should be
#' displayed with the station board. The message may include embedded and XML
#' encoded HTML-like hyperlinks and paragraphs. The messages are typically
#' used to display important disruption information that applies to the
#' location that the station board was for. Any embedded \code{<p>} tags are
#' used to force a new-line in the output. Embedded \code{<a>} tags allow
#' links to external web pages that may provide more information. Output
#' channels that do not support HTML should strip out the \code{<a>} tags and
#' just leave the enclosed text.}
#' \item{platformAvailable}{An optional value that indicates if platform
#' information is available. If this value is present with the value "true"
#' then platform information will be returned in the service lists. If this
#' value is not present, or has the value "false", then the platform "heading"
#' should be suppressed in the user interface for this station board.}
#' \item{areServicesAvailable}{An optional value that indicates if services
#' are currently available for this station board. If this value is present
#' with the value "false" then no services will be returned in the service
#' lists. This value may be set, for example, if access to a station has been
#' closed to the public at short notice, even though the scheduled services
#' are still running. It would be usual in such cases for one of the
#' \code{nrccMessages} to describe why the list of services has been
#' suppressed.}
#' \item{trainServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{busServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{ferryServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' }
#' @source Documentation for the Live Departure Boards Web Service
#' (LDBWS / OpenLDBWS):
#' \url{http://lite.realtime.nationalrail.co.uk/openldbws/}
# @eval StationBoard_return()
#' @family OpenLDBSVWS requests
#' @export
#' @examples
#' \dontrun{
#' rdg_arr <- trainR::GetArrBoardRequest("RDG")
#' rdg_arr <- trainR::GetArrBoardRequest("RDG", filterCrs = "BRI")
#' trainR::print(rdg_arr)
#' }
GetArrBoardRequest <-
function(crs,
filterCrs = NA,
filterType = "from",
numRows = 150,
timeOffset = 0,
timeWindow = 120,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE) {
process(crs = crs,
filterCrs = filterCrs,
filterType = filterType,
numRows = numRows,
timeOffset = timeOffset,
timeWindow = timeWindow,
token = token,
url = url,
verbose = verbose,
class = "ArrivalBoard")
}
#' Get all public departures
#'
#' Get all public departures for the supplied CRS code within a defined time
#' window.
#'
#' @inheritParams process
#' @inheritParams request
#'
#' @return Tibble with departure records. Each column is described below:
#' \describe{
#' \item{generatedAt}{The time at which the station board was generated.}
#' \item{locationName}{The name of the location that the station board is for.}
#' \item{crs}{The CRS code of the location that the station board is for.}
#' \item{filterLocationName}{If a filter was requested, the location name of
#' the filter location.}
#' \item{filtercrs}{If a filter was requested, the CRS code of the filter
#' location.}
#' \item{filterType}{If a filter was requested, the type of filter.}
#' \item{nrccMessages}{An optional list of textual messages that should be
#' displayed with the station board. The message may include embedded and XML
#' encoded HTML-like hyperlinks and paragraphs. The messages are typically
#' used to display important disruption information that applies to the
#' location that the station board was for. Any embedded \code{<p>} tags are
#' used to force a new-line in the output. Embedded \code{<a>} tags allow
#' links to external web pages that may provide more information. Output
#' channels that do not support HTML should strip out the \code{<a>} tags and
#' just leave the enclosed text.}
#' \item{platformAvailable}{An optional value that indicates if platform
#' information is available. If this value is present with the value "true"
#' then platform information will be returned in the service lists. If this
#' value is not present, or has the value "false", then the platform "heading"
#' should be suppressed in the user interface for this station board.}
#' \item{areServicesAvailable}{An optional value that indicates if services
#' are currently available for this station board. If this value is present
#' with the value "false" then no services will be returned in the service
#' lists. This value may be set, for example, if access to a station has been
#' closed to the public at short notice, even though the scheduled services
#' are still running. It would be usual in such cases for one of the
#' \code{nrccMessages} to describe why the list of services has been
#' suppressed.}
#' \item{trainServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{busServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{ferryServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' }
#' @source Documentation for the Live Departure Boards Web Service
#' (LDBWS / OpenLDBWS):
#' \url{http://lite.realtime.nationalrail.co.uk/openldbws/}
#' @family OpenLDBSVWS requests
#' @export
#' @examples
#' \dontrun{
#' rdg_dep <- trainR::GetDepBoardRequest("RDG")
#' rdg_dep <- trainR::GetDepBoardRequest("RDG", filterCrs = "BRI")
#' trainR::print(rdg_dep)
#' }
GetDepBoardRequest <-
function(crs,
filterCrs = NA,
filterType = "to",
numRows = 150,
timeOffset = 0,
timeWindow = 120,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE) {
process(crs = crs,
filterCrs = filterCrs,
filterType = filterType,
numRows = numRows,
timeOffset = timeOffset,
timeWindow = timeWindow,
token = token,
url = url,
verbose = verbose,
class = "DepartureBoard")
}
#' Get all public departures
#'
#' Get all public departures for the supplied CRS code within a defined time
#' window, including service details.
#'
#' @inheritParams process
#' @inheritParams request
#'
#' @return Tibble with departure records. Each column is described below:
#' \describe{
#' \item{generatedAt}{The time at which the station board was generated.}
#' \item{locationName}{The name of the location that the station board is for.}
#' \item{crs}{The CRS code of the location that the station board is for.}
#' \item{filterLocationName}{If a filter was requested, the location name of
#' the filter location.}
#' \item{filtercrs}{If a filter was requested, the CRS code of the filter
#' location.}
#' \item{filterType}{If a filter was requested, the type of filter.}
#' \item{nrccMessages}{An optional list of textual messages that should be
#' displayed with the station board. The message may include embedded and XML
#' encoded HTML-like hyperlinks and paragraphs. The messages are typically
#' used to display important disruption information that applies to the
#' location that the station board was for. Any embedded \code{<p>} tags are
#' used to force a new-line in the output. Embedded \code{<a>} tags allow
#' links to external web pages that may provide more information. Output
#' channels that do not support HTML should strip out the \code{<a>} tags and
#' just leave the enclosed text.}
#' \item{platformAvailable}{An optional value that indicates if platform
#' information is available. If this value is present with the value "true"
#' then platform information will be returned in the service lists. If this
#' value is not present, or has the value "false", then the platform "heading"
#' should be suppressed in the user interface for this station board.}
#' \item{areServicesAvailable}{An optional value that indicates if services
#' are currently available for this station board. If this value is present
#' with the value "false" then no services will be returned in the service
#' lists. This value may be set, for example, if access to a station has been
#' closed to the public at short notice, even though the scheduled services
#' are still running. It would be usual in such cases for one of the
#' \code{nrccMessages} to describe why the list of services has been
#' suppressed.}
#' \item{trainServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{busServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' \item{ferryServices}{A list of \code{ServiceItem} object for each services
#' of the relevant type that is to appear on the station board. May contain
#' zero items, or may not be present at all.}
#' }
#' @source Documentation for the Live Departure Boards Web Service
#' (LDBWS / OpenLDBWS):
#' \url{http://lite.realtime.nationalrail.co.uk/openldbws/}
#' @family OpenLDBSVWS requests
#' @export
#' @examples
#' \dontrun{
#' rdg_dep <- trainR::GetDepBoardWithDetailsRequest("RDG")
#' rdg_dep <- trainR::GetDepBoardWithDetailsRequest("RDG", filterCrs = "BRI")
#' trainR::print(rdg_dep)
#' }
GetDepBoardWithDetailsRequest <-
function(crs,
filterCrs = NA,
filterType = "to",
numRows = 150,
timeOffset = 0,
timeWindow = 120,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE) {
process(crs = crs,
filterCrs = filterCrs,
filterType = filterType,
numRows = numRows,
timeOffset = timeOffset,
timeWindow = timeWindow,
token = token,
url = url,
verbose = verbose,
class = "DepBoardWithDetails")
}
#' Get service details
#'
#' Get the service details for a specific service identified by a station board.
#' These details are supplied relative to the station board from which the
#' \code{serviceID} field value was generated. Service details are only
#' available while the service appears on the station board from which it was
#' obtained. This is normally for two minutes after it is expected to have
#' departed, or after a terminal arrival. If a request is made for a service
#' that is no longer available then a \code{NULL} value is returned.
#'
#' @param serviceID (string): The LDBWS service ID of the service to request
#' the details of. The service ID is obtained from a service listed in a
#' \code{StationBoard} object returned from any other request.
#'
#' @inheritParams process
#' @inheritParams request
#'
#' @return Tibble with departure records.
#' @family OpenLDBSVWS requests
#' @export
GetServiceDetailsRequest <-
function(serviceID,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE) {
# Create SOAP request components
header <- glue::glue("<typ:AccessToken>
<typ:TokenValue>{token}</typ:TokenValue>
</typ:AccessToken>")
body <- glue::glue("<ldb:GetServiceDetailsRequest>
<ldb:serviceID>{serviceID}</ldb:serviceID>
</ldb:GetServiceDetailsRequest>")
# Submit request
request(body, header, url, verbose, c("ServiceDetails"))#, "service"))
}
#' Process \code{StationBoard} request
#'
#' @param crs (string, 3 characters, alphabetic): The CRS code of the location
#' for which the request is being made.
#' @param filterCrs (string, 3 characters, alphabetic): The CRS code of either
#' an origin or destination location to filter in. Optional.
#' @param filterType (string, either "from" or "to"): The type of filter to
#' apply. Filters services to include only those originating or terminating
#' at the \code{filterCrs} location. Defaults to "to".
#' @param numRows (integer, between 0 and 150 exclusive): The number of
#' services to return in the resulting station board.
#' @param timeOffset (integer, between -120 and 120 exclusive): An offset in
#' minutes against the current time to provide the station board for.
#' Defaults to 0.
#' @param timeWindow (integer, between -120 and 120 exclusive): How far into
#' the future in minutes, relative to \code{timeOffset}, to return services
#' for. Defaults to 120.
#' @param token Token to access the data feed. The token can be obtained at
#' \url{http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/}.
#' @param class String with request class.
#' @param extra String with extra classes (default = "StationBoard").
#' @return Tibble with request data.
#' @keywords internal
process <- function(crs,
filterCrs = NA,
filterType = "to",
numRows = 150,
timeOffset = 0,
timeWindow = 120,
token = get_token(),
url = "https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb11.asmx",
verbose = FALSE,
class = NULL,
extra = "StationBoard") {
# Check arguments
is_valid_crs(crs)
# Check if filterCrs is not empty
if (!is.na(filterCrs)) {
is_valid_crs(filterCrs, "filterCrs")
filterCrs <- glue::glue("<ldb:filterCrs>{filterCrs}</ldb:filterCrs>")
} else {
filterCrs <- ""
}
# Create SOAP request components
header <- glue::glue("<typ:AccessToken>
<typ:TokenValue>{token}</typ:TokenValue>
</typ:AccessToken>")
body <- glue::glue("<ldb:Get{class}Request>
<ldb:numRows>{numRows}</ldb:numRows>
<ldb:crs>{crs}</ldb:crs>
<!--Optional:-->
{filterCrs}
<!--Optional:-->
<ldb:filterType>{filterType}</ldb:filterType>
<!--Optional:-->
<ldb:timeOffset>{timeOffset}</ldb:timeOffset>
<!--Optional:-->
<ldb:timeWindow>{timeWindow}</ldb:timeWindow>
</ldb:Get{class}Request>")
# Submit request
request(body, header, url, verbose, class = c(class, extra))
}
#' Submit a SOAP XML request
#'
#' @param body XML body arguments.
#' @param header XML header arguments.
#' @param url Data feed source URL.
#' @param verbose Boolean flag to indicate whether or not to show status
#' messages.
#' @inheritParams process
#'
#' @return Request results or error message if not found.
#' @keywords internal
request <- function(body, header, url, verbose = FALSE, class = NULL) {
# Local binding
. <- NULL
body_contents <-
glue::glue('<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:typ="http://thalesgroup.com/RTTI/2013-11-28/Token/types"
xmlns:ldb="http://thalesgroup.com/RTTI/2017-10-01/ldb/">
<soap:Header>
{header}
</soap:Header>
<soap:Body>
{body}
</soap:Body>
</soap:Envelope>')
header_contents <- c(Connection = "close",
# Accept = "text/xml",
# Accept = "multipart/*",
'Content-Type' = "text/xml; charset=utf-8",
# 'Content-Type' = "application/xml",
'Content-length' = nchar(body_contents))
# Send request to server
RCurl::getURL(url = url,
postfields = body_contents,
httpheader = header_contents,
verbose = verbose) %>%
xml2::read_xml() %>%
# xml2::xml_find_all(xpath = ".//lt7:trainServices") %>%
xml2::xml_find_all(".//soap:Body") %>%
xml2::xml_contents() %>%
xml2::as_list() %>%
.[[1]] %>% # Extract request result
validate() %>% # Validate request result
reclass(class = class) %>% # Update class of the result object
extract()
}