ldbws 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +25 -1
- data/doc/Ldbws/Request/ParamValidationError.html +138 -0
- data/doc/Ldbws/RequestError.html +151 -0
- data/doc/Ldbws/ResponseParsingError.html +99 -0
- data/doc/README_md.html +36 -1
- data/doc/created.rid +7 -6
- data/doc/index.html +27 -1
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +23 -0
- data/lib/ldbws/request/base.rb +15 -3
- data/lib/ldbws/service.rb +11 -1
- data/lib/ldbws/version.rb +1 -1
- data/lib/ldbws.rb +31 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629711e2f0ecde9ac01eaac4f20bc06b422171420b8ef090fdcaaef862274630
|
4
|
+
data.tar.gz: 8a4b08a682981069a7fb77240ad6e4e3bdab678da0c02af22be3a1255a8f57d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22cc7775c39e4b85dc5a228685413a158910b86d46b245107632ab7c4c18044a6ddc3a6f621cdb252404966aee329c66b360edb45eb3d794ba06ce5c951dc914
|
7
|
+
data.tar.gz: 558ec444228a7894b42798a65a21eee269b85b9e42c8043f6eafad8c7a402a77f93eedf18ad632f7bcaa0bd53cc2aea29433c02079db55b6b744c0e8485b35e6
|
data/.gitattributes
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Reminder: you can list affected files via
|
2
|
+
#
|
3
|
+
# git ls-files | xargs git check-attr -a
|
4
|
+
#
|
5
|
+
|
6
|
+
# =================================================================================
|
7
|
+
# Mark files as being automatically-generated so they get minimised in github diffs
|
8
|
+
# =================================================================================
|
9
|
+
|
10
|
+
# rdoc
|
11
|
+
doc/**/* linguist-generated
|
12
|
+
|
13
|
+
# Lockfiles
|
14
|
+
Gemfile.lock linguist-generated
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ I built it for a project I’m hacking at + thought I’d release it into the wo
|
|
9
9
|
All operations are supported, in `snake_case`, thus:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
require "
|
12
|
+
require "ldbws"
|
13
13
|
|
14
14
|
service = Ldbws.service(YOUR_API_TOKEN)
|
15
15
|
result = service.get_departure_board(crs: "CDF")
|
@@ -38,6 +38,30 @@ end
|
|
38
38
|
|
39
39
|
LDBWS uses rate-limiting for free access: while this <i>probably</i> isn’t going to be an issue for the casual user, you may want to consider using a cache in front of this gem, just in case.
|
40
40
|
|
41
|
+
## Error-handling
|
42
|
+
|
43
|
+
This module is pretty decent at validating request parameters, but beyond that all it can really do is just echo what LDBWS says. To wit, there are three errors that can be raised:
|
44
|
+
|
45
|
+
### `Ldbws::Request::ParamValidationError`
|
46
|
+
|
47
|
+
This is raised when parameter validation fails. Details about exactly which parameters and why can be found using the `#messages`, and is provided in hash format, thus:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
begin
|
51
|
+
service.get_departure_board
|
52
|
+
rescue Ldbws::Request::ParamValidationError => e
|
53
|
+
# e = { crs: "is missing" }
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
### `Ldbws::RequestError`
|
58
|
+
|
59
|
+
Raised when LDBWS returns an error message, usually because the request is bad (eg: invalid CRS). Unfortunately LDBWS’ error messages are pretty terrible, so it’s generally not too edifying to look at them.
|
60
|
+
|
61
|
+
### `Ldbws::ResponseParsingError`
|
62
|
+
|
63
|
+
Raised when the response from LDBWS cannot be parsed.
|
64
|
+
|
41
65
|
## Caveats
|
42
66
|
|
43
67
|
This is released into the world as-is. If you use it for something and end up missing your train, or do something that falls foul of the LDBWS terms of use, it’s not my fault :)
|
@@ -0,0 +1,138 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Ldbws::Request::ParamValidationError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../../";
|
11
|
+
var index_rel_prefix = "../../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../../js/navigation.js" defer></script>
|
15
|
+
<script src="../../js/search.js" defer></script>
|
16
|
+
<script src="../../js/search_index.js" defer></script>
|
17
|
+
<script src="../../js/searcher.js" defer></script>
|
18
|
+
<script src="../../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">RuntimeError
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li ><a href="#method-i-messages">#messages</a>
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main" aria-labelledby="class-Ldbws::Request::ParamValidationError">
|
83
|
+
<h1 id="class-Ldbws::Request::ParamValidationError" class="class">
|
84
|
+
class Ldbws::Request::ParamValidationError
|
85
|
+
</h1>
|
86
|
+
|
87
|
+
<section class="description">
|
88
|
+
|
89
|
+
<p>Raised when an error occurs when validating request parameters. Messages are passed through directly from <a href="https://dry-rb.org/gems/dry-schema/1.10/">dry-schema</a>.</p>
|
90
|
+
|
91
|
+
</section>
|
92
|
+
|
93
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
100
|
+
<header>
|
101
|
+
<h3>Public Instance Methods</h3>
|
102
|
+
</header>
|
103
|
+
|
104
|
+
<div id="method-i-messages" class="method-detail ">
|
105
|
+
<div class="method-header">
|
106
|
+
<div class="method-heading">
|
107
|
+
<span class="method-name">messages</span><span
|
108
|
+
class="method-args">()</span>
|
109
|
+
<span class="method-click-advice">click to toggle source</span>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<div class="method-description">
|
114
|
+
<p>Returns the validation error messages as a hash.</p>
|
115
|
+
|
116
|
+
<div class="method-source-code" id="messages-source">
|
117
|
+
<pre><span class="ruby-comment"># File lib/ldbws/request/base.rb, line 77</span>
|
118
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">messages</span>
|
119
|
+
<span class="ruby-ivar">@messages</span>
|
120
|
+
<span class="ruby-keyword">end</span></pre>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
</section>
|
128
|
+
|
129
|
+
</section>
|
130
|
+
</main>
|
131
|
+
|
132
|
+
|
133
|
+
<footer id="validator-badges" role="contentinfo">
|
134
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
135
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.5.0.
|
136
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
137
|
+
</footer>
|
138
|
+
|
@@ -0,0 +1,151 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Ldbws::RequestError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">RuntimeError
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li ><a href="#method-i-details">#details</a>
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main" aria-labelledby="class-Ldbws::RequestError">
|
83
|
+
<h1 id="class-Ldbws::RequestError" class="class">
|
84
|
+
class Ldbws::RequestError
|
85
|
+
</h1>
|
86
|
+
|
87
|
+
<section class="description">
|
88
|
+
|
89
|
+
<p>Raised when a request has resulted in an error that this library can make some sense of. This <em>usually</em> occurs due to something being wrong with a request like an invalid CRS code.</p>
|
90
|
+
|
91
|
+
<p>Unfortunately LDBWS doesn’t generate particularly helpful CRS codes, so the <a href="RequestError.html#method-i-details"><code>details</code></a> method will return a hashified version of the response from the server.</p>
|
92
|
+
|
93
|
+
<p>Thus, for a missing CRS, you’ll get:</p>
|
94
|
+
|
95
|
+
<pre class="ruby">{
|
96
|
+
<span class="ruby-value">faultcode:</span> <span class="ruby-string">"soap:Server"</span>,
|
97
|
+
<span class="ruby-value">faultstring:</span> <span class="ruby-string">"Unexpected server error"</span>,
|
98
|
+
<span class="ruby-value">detail:</span> <span class="ruby-string">""</span>
|
99
|
+
}
|
100
|
+
</pre>
|
101
|
+
|
102
|
+
<p>Which isn’t especially useful. Best suggestion if you get this is to double-check your code to make sure the request is sane.</p>
|
103
|
+
|
104
|
+
</section>
|
105
|
+
|
106
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
113
|
+
<header>
|
114
|
+
<h3>Public Instance Methods</h3>
|
115
|
+
</header>
|
116
|
+
|
117
|
+
<div id="method-i-details" class="method-detail ">
|
118
|
+
<div class="method-header">
|
119
|
+
<div class="method-heading">
|
120
|
+
<span class="method-name">details</span><span
|
121
|
+
class="method-args">()</span>
|
122
|
+
<span class="method-click-advice">click to toggle source</span>
|
123
|
+
</div>
|
124
|
+
</div>
|
125
|
+
|
126
|
+
<div class="method-description">
|
127
|
+
<p>Returns the details of the error as a hash.</p>
|
128
|
+
|
129
|
+
<div class="method-source-code" id="details-source">
|
130
|
+
<pre><span class="ruby-comment"># File lib/ldbws.rb, line 36</span>
|
131
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">details</span>
|
132
|
+
<span class="ruby-ivar">@details</span>
|
133
|
+
<span class="ruby-keyword">end</span></pre>
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
|
138
|
+
</div>
|
139
|
+
|
140
|
+
</section>
|
141
|
+
|
142
|
+
</section>
|
143
|
+
</main>
|
144
|
+
|
145
|
+
|
146
|
+
<footer id="validator-badges" role="contentinfo">
|
147
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
148
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.5.0.
|
149
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
150
|
+
</footer>
|
151
|
+
|
@@ -0,0 +1,99 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Ldbws::ResponseParsingError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">RuntimeError
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</div>
|
71
|
+
</nav>
|
72
|
+
|
73
|
+
<main role="main" aria-labelledby="class-Ldbws::ResponseParsingError">
|
74
|
+
<h1 id="class-Ldbws::ResponseParsingError" class="class">
|
75
|
+
class Ldbws::ResponseParsingError
|
76
|
+
</h1>
|
77
|
+
|
78
|
+
<section class="description">
|
79
|
+
|
80
|
+
<p>Raised when a response from LDBWS cannot be parsed by this library. This is unexpected, and generally means you’ll need to raise an issue against this gem.</p>
|
81
|
+
|
82
|
+
</section>
|
83
|
+
|
84
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
</section>
|
91
|
+
</main>
|
92
|
+
|
93
|
+
|
94
|
+
<footer id="validator-badges" role="contentinfo">
|
95
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
96
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.5.0.
|
97
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
98
|
+
</footer>
|
99
|
+
|
data/doc/README_md.html
CHANGED
@@ -75,6 +75,18 @@
|
|
75
75
|
</ul>
|
76
76
|
</details>
|
77
77
|
</li>
|
78
|
+
<li>
|
79
|
+
<details open>
|
80
|
+
<summary> <a href="#label-Error-handling">Error-handling</a>
|
81
|
+
</summary>
|
82
|
+
<ul class="link-list" role="directory">
|
83
|
+
<li> <a href="#label-Ldbws-3A-3ARequest-3A-3AParamValidationError"><code>Ldbws::Request::ParamValidationError</code></a>
|
84
|
+
<li> <a href="#label-Ldbws-3A-3ARequestError"><code>Ldbws::RequestError</code></a>
|
85
|
+
<li> <a href="#label-Ldbws-3A-3AResponseParsingError"><code>Ldbws::ResponseParsingError</code></a>
|
86
|
+
|
87
|
+
</ul>
|
88
|
+
</details>
|
89
|
+
</li>
|
78
90
|
<li> <a href="#label-Caveats">Caveats</a>
|
79
91
|
|
80
92
|
</ul>
|
@@ -111,7 +123,7 @@
|
|
111
123
|
|
112
124
|
<p>All operations are supported, in <code>snake_case</code>, thus:</p>
|
113
125
|
|
114
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">"
|
126
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">"ldbws"</span>
|
115
127
|
|
116
128
|
<span class="ruby-identifier">service</span> = <span class="ruby-constant">Ldbws</span>.<span class="ruby-identifier">service</span>(<span class="ruby-constant">YOUR_API_TOKEN</span>)
|
117
129
|
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">service</span>.<span class="ruby-identifier">get_departure_board</span>(<span class="ruby-value">crs:</span> <span class="ruby-string">"CDF"</span>)
|
@@ -140,6 +152,29 @@
|
|
140
152
|
|
141
153
|
<p>LDBWS uses rate-limiting for free access: while this <em>probably</em> isn’t going to be an issue for the casual user, you may want to consider using a cache in front of this gem, just in case.</p>
|
142
154
|
|
155
|
+
<h2 id="label-Error-handling">Error-handling<span><a href="#label-Error-handling">¶</a> <a href="#top">↑</a></span></h2>
|
156
|
+
|
157
|
+
<p>This module is pretty decent at validating request parameters, but beyond that all it can really do is just echo what LDBWS says. To wit, there are three errors that can be raised:</p>
|
158
|
+
|
159
|
+
<h3 id="label-Ldbws-3A-3ARequest-3A-3AParamValidationError"><code>Ldbws::Request::ParamValidationError</code><span><a href="#label-Ldbws-3A-3ARequest-3A-3AParamValidationError">¶</a> <a href="#top">↑</a></span></h3>
|
160
|
+
|
161
|
+
<p>This is raised when parameter validation fails. Details about exactly which parameters and why can be found using the <code>#messages</code>, and is provided in hash format, thus:</p>
|
162
|
+
|
163
|
+
<pre class="ruby"><span class="ruby-keyword">begin</span>
|
164
|
+
<span class="ruby-identifier">service</span>.<span class="ruby-identifier">get_departure_board</span>
|
165
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Ldbws</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span><span class="ruby-operator">::</span><span class="ruby-constant">ParamValidationError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
166
|
+
<span class="ruby-comment"># e = { crs: "is missing" }</span>
|
167
|
+
<span class="ruby-keyword">end</span>
|
168
|
+
</pre>
|
169
|
+
|
170
|
+
<h3 id="label-Ldbws-3A-3ARequestError"><code>Ldbws::RequestError</code><span><a href="#label-Ldbws-3A-3ARequestError">¶</a> <a href="#top">↑</a></span></h3>
|
171
|
+
|
172
|
+
<p>Raised when LDBWS returns an error message, usually because the request is bad (eg: invalid CRS). Unfortunately LDBWS’ error messages are pretty terrible, so it’s generally not too edifying to look at them.</p>
|
173
|
+
|
174
|
+
<h3 id="label-Ldbws-3A-3AResponseParsingError"><code>Ldbws::ResponseParsingError</code><span><a href="#label-Ldbws-3A-3AResponseParsingError">¶</a> <a href="#top">↑</a></span></h3>
|
175
|
+
|
176
|
+
<p>Raised when the response from LDBWS cannot be parsed.</p>
|
177
|
+
|
143
178
|
<h2 id="label-Caveats">Caveats<span><a href="#label-Caveats">¶</a> <a href="#top">↑</a></span></h2>
|
144
179
|
|
145
180
|
<p>This is released into the world as-is. If you use it for something and end up missing your train, or do something that falls foul of the LDBWS terms of use, it’s not my fault :)</p>
|
data/doc/created.rid
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
Mon, 03 Apr 2023 16:32:07 +0100
|
2
2
|
LICENSE Thu, 06 Oct 2022 18:25:44 +0100
|
3
|
-
README.md
|
4
|
-
|
3
|
+
README.md Mon, 03 Apr 2023 16:14:38 +0100
|
4
|
+
ldbws-1.0.1.gem Mon, 03 Apr 2023 16:31:55 +0100
|
5
|
+
lib/ldbws/request/base.rb Sun, 02 Apr 2023 11:45:01 +0100
|
5
6
|
lib/ldbws/request/get_departures_board.rb Sat, 01 Apr 2023 18:55:20 +0100
|
6
7
|
lib/ldbws/request/get_service_details.rb Sat, 01 Apr 2023 18:55:20 +0100
|
7
8
|
lib/ldbws/request/get_station_board.rb Sat, 01 Apr 2023 18:55:20 +0100
|
@@ -13,7 +14,7 @@ lib/ldbws/response_types/parsing_functions.rb Sat, 01 Apr 2023 18:55:20 +0100
|
|
13
14
|
lib/ldbws/response_types/service_details.rb Sat, 01 Apr 2023 18:56:26 +0100
|
14
15
|
lib/ldbws/response_types/service_item.rb Sat, 01 Apr 2023 18:56:26 +0100
|
15
16
|
lib/ldbws/response_types/station_board.rb Sat, 01 Apr 2023 18:55:20 +0100
|
16
|
-
lib/ldbws/service.rb
|
17
|
+
lib/ldbws/service.rb Sun, 02 Apr 2023 11:45:01 +0100
|
17
18
|
lib/ldbws/utils.rb Sat, 01 Apr 2023 18:57:09 +0100
|
18
|
-
lib/ldbws/version.rb
|
19
|
-
lib/ldbws.rb
|
19
|
+
lib/ldbws/version.rb Mon, 03 Apr 2023 16:12:40 +0100
|
20
|
+
lib/ldbws.rb Sun, 02 Apr 2023 11:45:01 +0100
|
data/doc/index.html
CHANGED
@@ -78,7 +78,10 @@
|
|
78
78
|
<li><code><a href="./Ldbws/Request/GetServiceDetails.html">GetServiceDetails</a></code>
|
79
79
|
<li><code><a href="./Ldbws/Request/GetStationBoard.html">GetStationBoard</a></code>
|
80
80
|
<li><code><a href="./Ldbws/Request/GetStationBoardWithDetails.html">GetStationBoardWithDetails</a></code>
|
81
|
+
<li><code><a href="./Ldbws/Request/ParamValidationError.html">ParamValidationError</a></code>
|
81
82
|
</ul></details>
|
83
|
+
<li><code><a href="./Ldbws/RequestError.html">RequestError</a></code>
|
84
|
+
<li><code><a href="./Ldbws/ResponseParsingError.html">ResponseParsingError</a></code>
|
82
85
|
<li><details><summary><code><a href="./Ldbws/ResponseTypes.html">ResponseTypes</a></code></summary>
|
83
86
|
<ul class="link-list">
|
84
87
|
<li><code><a href="./Ldbws/ResponseTypes/BaseStationBoard.html">BaseStationBoard</a></code>
|
@@ -118,7 +121,7 @@
|
|
118
121
|
|
119
122
|
<p>All operations are supported, in <code>snake_case</code>, thus:</p>
|
120
123
|
|
121
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">"
|
124
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">"ldbws"</span>
|
122
125
|
|
123
126
|
<span class="ruby-identifier">service</span> = <span class="ruby-constant">Ldbws</span>.<span class="ruby-identifier">service</span>(<span class="ruby-constant">YOUR_API_TOKEN</span>)
|
124
127
|
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">service</span>.<span class="ruby-identifier">get_departure_board</span>(<span class="ruby-value">crs:</span> <span class="ruby-string">"CDF"</span>)
|
@@ -147,6 +150,29 @@
|
|
147
150
|
|
148
151
|
<p>LDBWS uses rate-limiting for free access: while this <em>probably</em> isn’t going to be an issue for the casual user, you may want to consider using a cache in front of this gem, just in case.</p>
|
149
152
|
|
153
|
+
<h2 id="label-Error-handling">Error-handling<span><a href="#label-Error-handling">¶</a> <a href="#top">↑</a></span></h2>
|
154
|
+
|
155
|
+
<p>This module is pretty decent at validating request parameters, but beyond that all it can really do is just echo what LDBWS says. To wit, there are three errors that can be raised:</p>
|
156
|
+
|
157
|
+
<h3 id="label-Ldbws-3A-3ARequest-3A-3AParamValidationError"><code>Ldbws::Request::ParamValidationError</code><span><a href="#label-Ldbws-3A-3ARequest-3A-3AParamValidationError">¶</a> <a href="#top">↑</a></span></h3>
|
158
|
+
|
159
|
+
<p>This is raised when parameter validation fails. Details about exactly which parameters and why can be found using the <code>#messages</code>, and is provided in hash format, thus:</p>
|
160
|
+
|
161
|
+
<pre class="ruby"><span class="ruby-keyword">begin</span>
|
162
|
+
<span class="ruby-identifier">service</span>.<span class="ruby-identifier">get_departure_board</span>
|
163
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Ldbws</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span><span class="ruby-operator">::</span><span class="ruby-constant">ParamValidationError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
164
|
+
<span class="ruby-comment"># e = { crs: "is missing" }</span>
|
165
|
+
<span class="ruby-keyword">end</span>
|
166
|
+
</pre>
|
167
|
+
|
168
|
+
<h3 id="label-Ldbws-3A-3ARequestError"><code>Ldbws::RequestError</code><span><a href="#label-Ldbws-3A-3ARequestError">¶</a> <a href="#top">↑</a></span></h3>
|
169
|
+
|
170
|
+
<p>Raised when LDBWS returns an error message, usually because the request is bad (eg: invalid CRS). Unfortunately LDBWS’ error messages are pretty terrible, so it’s generally not too edifying to look at them.</p>
|
171
|
+
|
172
|
+
<h3 id="label-Ldbws-3A-3AResponseParsingError"><code>Ldbws::ResponseParsingError</code><span><a href="#label-Ldbws-3A-3AResponseParsingError">¶</a> <a href="#top">↑</a></span></h3>
|
173
|
+
|
174
|
+
<p>Raised when the response from LDBWS cannot be parsed.</p>
|
175
|
+
|
150
176
|
<h2 id="label-Caveats">Caveats<span><a href="#label-Caveats">¶</a> <a href="#top">↑</a></span></h2>
|
151
177
|
|
152
178
|
<p>This is released into the world as-is. If you use it for something and end up missing your train, or do something that falls foul of the LDBWS terms of use, it’s not my fault :)</p>
|
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["ldbws","request","getdeparturesboard","getdeparturesboardwithdetails","getservicedetails","getstationboard","getstationboardwithdetails","responsetypes","basestationboard","callingpoint","coach","departureitem","departureitemwithdetails","departuresboard","departuresboardwithdetails","formation","loadingcategory","location","servicedetails","serviceitem","serviceitemwithcallingpoints","stationboard","stationboardwithdetails","toiletavailability","service","get_arr_board_with_details()","get_arr_dep_board_with_details()","get_arrival_board()","get_arrival_board_with_details()","get_arrival_departure_board()","get_arrival_departure_board_with_details()","get_dep_board_with_details()","get_departure_board()","get_departure_board_with_details()","get_fastest_departures_with_details()","get_next_departures()","get_next_departures_with_details()","get_service_details()","new()","service()","license","readme"],"longSearchIndex":["ldbws","ldbws::request","ldbws::request::getdeparturesboard","ldbws::request::getdeparturesboardwithdetails","ldbws::request::getservicedetails","ldbws::request::getstationboard","ldbws::request::getstationboardwithdetails","ldbws::responsetypes","ldbws::responsetypes::basestationboard","ldbws::responsetypes::callingpoint","ldbws::responsetypes::coach","ldbws::responsetypes::departureitem","ldbws::responsetypes::departureitemwithdetails","ldbws::responsetypes::departuresboard","ldbws::responsetypes::departuresboardwithdetails","ldbws::responsetypes::formation","ldbws::responsetypes::loadingcategory","ldbws::responsetypes::location","ldbws::responsetypes::servicedetails","ldbws::responsetypes::serviceitem","ldbws::responsetypes::serviceitemwithcallingpoints","ldbws::responsetypes::stationboard","ldbws::responsetypes::stationboardwithdetails","ldbws::responsetypes::toiletavailability","ldbws::service","ldbws::service#get_arr_board_with_details()","ldbws::service#get_arr_dep_board_with_details()","ldbws::service#get_arrival_board()","ldbws::service#get_arrival_board_with_details()","ldbws::service#get_arrival_departure_board()","ldbws::service#get_arrival_departure_board_with_details()","ldbws::service#get_dep_board_with_details()","ldbws::service#get_departure_board()","ldbws::service#get_departure_board_with_details()","ldbws::service#get_fastest_departures_with_details()","ldbws::service#get_next_departures()","ldbws::service#get_next_departures_with_details()","ldbws::service#get_service_details()","ldbws::service::new()","ldbws::service()","",""],"info":[["Ldbws","","Ldbws.html","","<p>Provides a Ruby abstraction around the UK’s Network Rail live departure board webservice (LDBWS). See …\n"],["Ldbws::Request","","Ldbws/Request.html","",""],["Ldbws::Request::GetDeparturesBoard","","Ldbws/Request/GetDeparturesBoard.html","","<p>Requests a departure board for a station, filtered by departures to one or many other stations. Corresponds …\n"],["Ldbws::Request::GetDeparturesBoardWithDetails","","Ldbws/Request/GetDeparturesBoardWithDetails.html","","<p>Requests a departure board for a statuion, filtered by departures to one or more other stations. This …\n"],["Ldbws::Request::GetServiceDetails","","Ldbws/Request/GetServiceDetails.html","","<p>Returns details about a particular service. Corresponds to <code>GetServiceDetailsResponse</code> in the LDBWS schema. …\n"],["Ldbws::Request::GetStationBoard","","Ldbws/Request/GetStationBoard.html","","<p>Returns an arrival or departure board for a given station. Corresponds to <code>GetStationBoardRequest</code> in the …\n"],["Ldbws::Request::GetStationBoardWithDetails","","Ldbws/Request/GetStationBoardWithDetails.html","","<p>Returns an arrival or departure board for a given station with full service details. Corresponds to …\n"],["Ldbws::ResponseTypes","","Ldbws/ResponseTypes.html","",""],["Ldbws::ResponseTypes::BaseStationBoard","","Ldbws/ResponseTypes/BaseStationBoard.html","","<p>Base station board information. This does not directly correspond to a type in LDBWS.\n<p>Properties\n"],["Ldbws::ResponseTypes::CallingPoint","","Ldbws/ResponseTypes/CallingPoint.html","","<p>Represents a calling point in the LDBWS.\n<p>Properties\n<p>location_name — the name of the station\n"],["Ldbws::ResponseTypes::Coach","","Ldbws/ResponseTypes/Coach.html","","<p>Information about an individual coach in the train.\n<p>Properties\n<p>number — the coach number or identifier\n"],["Ldbws::ResponseTypes::DepartureItem","","Ldbws/ResponseTypes/DepartureItem.html","","<p>Represents an item on a departure board.\n<p>Properties\n<p>crs — the CRS for the item\n"],["Ldbws::ResponseTypes::DepartureItemWithDetails","","Ldbws/ResponseTypes/DepartureItemWithDetails.html","","<p>Represents an item on a departure board with additional details.\n<p>Properties\n<p>crs — the CRS for the item\n"],["Ldbws::ResponseTypes::DeparturesBoard","","Ldbws/ResponseTypes/DeparturesBoard.html","","<p>Represents a departures board.\n<p>Properties\n<p>departures — a list of departures.\n"],["Ldbws::ResponseTypes::DeparturesBoardWithDetails","","Ldbws/ResponseTypes/DeparturesBoardWithDetails.html","","<p>Represents a departures board with additional details.\n<p>Properties\n<p>departures — a list of departures.\n"],["Ldbws::ResponseTypes::Formation","","Ldbws/ResponseTypes/Formation.html","","<p>Information about the formation of a train\n<p>Properties\n<p>loading_category — how heavily-loaded the train is. …\n"],["Ldbws::ResponseTypes::LoadingCategory","","Ldbws/ResponseTypes/LoadingCategory.html","","<p>The loading category of a train\n<p>Properties\n<p>code, colour, image — \n"],["Ldbws::ResponseTypes::Location","","Ldbws/ResponseTypes/Location.html","","<p>Represents a location in LDBWS.\n<p>Properties\n<p>name, crs, via — \n"],["Ldbws::ResponseTypes::ServiceDetails","","Ldbws/ResponseTypes/ServiceDetails.html","","<p>Represents details about a service in LDBWS.\n<p>Properties\n"],["Ldbws::ResponseTypes::ServiceItem","","Ldbws/ResponseTypes/ServiceItem.html","","<p>Represents a service item in LDBWS.\n<p>Properties\n<p>sta — the scheduled arrival time as a Time object\n"],["Ldbws::ResponseTypes::ServiceItemWithCallingPoints","","Ldbws/ResponseTypes/ServiceItemWithCallingPoints.html","","<p>Represents a service item with additional details in LDBWS: extends ServiceItem.\n<p>Properties\n<p>As ServiceItem …\n"],["Ldbws::ResponseTypes::StationBoard","","Ldbws/ResponseTypes/StationBoard.html","","<p>Represents a station arrival/departure board in LDBWS.\n<p>Properties\n<p>As BaseStationBoard, and additionally: …\n"],["Ldbws::ResponseTypes::StationBoardWithDetails","","Ldbws/ResponseTypes/StationBoardWithDetails.html","","<p>Represents a station arrival/departure board with additional details in LDBWS.\n<p>Properties\n<p>As BaseStationBoard …\n"],["Ldbws::ResponseTypes::ToiletAvailability","","Ldbws/ResponseTypes/ToiletAvailability.html","","<p>The availability of an individual toilet on a train\n<p>Properties\n<p>type — the type of toilet\n"],["Ldbws::Service","","Ldbws/Service.html","","<p>A wrapper around the National Rail Live Departure Boards Webservice (LDBWS) API.\n<p>API methods are pretty …\n"],["get_arr_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arr_board_with_details","(params)","<p>Retrieves a detailed station arrival board.\n<p>Parameters are validated using GetStationBoardWithDetails …\n"],["get_arr_dep_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arr_dep_board_with_details","(params)","<p>Retrieves a detailed station arrival + departures board.\n<p>Parameters are validated using GetStationBoardWithDetails …\n"],["get_arrival_board","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_board","(params)","<p>Retrieves a station arrival board.\n<p>Parameters are validated using GetStationBoard, returns a StationBoard …\n"],["get_arrival_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_board_with_details","(params)",""],["get_arrival_departure_board","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_departure_board","(params)","<p>Retrieves a station arrival + departure board.\n<p>Parameters are validated using GetStationBoard, returns …\n"],["get_arrival_departure_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_departure_board_with_details","(params)",""],["get_dep_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_dep_board_with_details","(params)","<p>Retrieves a detailed station departure board.\n<p>Parameters are validated using GetStationBoardWithDetails …\n"],["get_departure_board","Ldbws::Service","Ldbws/Service.html#method-i-get_departure_board","(params)","<p>Retrieves a station departure board.\n<p>Parameters are validated using GetStationBoard, returns a StationBoard …\n"],["get_departure_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_departure_board_with_details","(params)",""],["get_fastest_departures_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_fastest_departures_with_details","(params)","<p>Retrieves detailed information about the fastest departures from one station to one or many others.\n<p>Parameters …\n"],["get_next_departures","Ldbws::Service","Ldbws/Service.html#method-i-get_next_departures","(params)","<p>Retrieves the next departures from one station to one or many others.\n<p>Parameters are validated using …\n"],["get_next_departures_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_next_departures_with_details","(params)","<p>Retrieves detailed information about the next departures from one station to one or many others.\n<p>Parameters …\n"],["get_service_details","Ldbws::Service","Ldbws/Service.html#method-i-get_service_details","(params)","<p>Retrieves information about a specific service.\n<p>Parameters are validated using GetServiceDetails, returns …\n"],["new","Ldbws::Service","Ldbws/Service.html#method-c-new","(token)","<p>Creates a service object.\n<p>Parameters\n<p>token — the API token used to connect to the service\n"],["service","Ldbws","Ldbws.html#method-c-service","(token)","<p>Helper method that returns an instance of [Service].\n<p>Parameters\n<p>token — the API token used to connect to …\n"],["LICENSE","","LICENSE.html","","<p>MIT License\n<p>Copyright © 2022 Jon Pearse\n<p>Permission is hereby granted, free of charge, to any person obtaining …\n"],["README","","README_md.html","","<p>ldbws-ruby\n<p>I’ll write a proper readme/howto at some point, but short version is that this is a Ruby wrapper …\n"]]}}
|
1
|
+
var search_data = {"index":{"searchIndex":["ldbws","request","getdeparturesboard","getdeparturesboardwithdetails","getservicedetails","getstationboard","getstationboardwithdetails","paramvalidationerror","requesterror","responseparsingerror","responsetypes","basestationboard","callingpoint","coach","departureitem","departureitemwithdetails","departuresboard","departuresboardwithdetails","formation","loadingcategory","location","servicedetails","serviceitem","serviceitemwithcallingpoints","stationboard","stationboardwithdetails","toiletavailability","service","details()","get_arr_board_with_details()","get_arr_dep_board_with_details()","get_arrival_board()","get_arrival_board_with_details()","get_arrival_departure_board()","get_arrival_departure_board_with_details()","get_dep_board_with_details()","get_departure_board()","get_departure_board_with_details()","get_fastest_departures_with_details()","get_next_departures()","get_next_departures_with_details()","get_service_details()","messages()","new()","service()","license","readme"],"longSearchIndex":["ldbws","ldbws::request","ldbws::request::getdeparturesboard","ldbws::request::getdeparturesboardwithdetails","ldbws::request::getservicedetails","ldbws::request::getstationboard","ldbws::request::getstationboardwithdetails","ldbws::request::paramvalidationerror","ldbws::requesterror","ldbws::responseparsingerror","ldbws::responsetypes","ldbws::responsetypes::basestationboard","ldbws::responsetypes::callingpoint","ldbws::responsetypes::coach","ldbws::responsetypes::departureitem","ldbws::responsetypes::departureitemwithdetails","ldbws::responsetypes::departuresboard","ldbws::responsetypes::departuresboardwithdetails","ldbws::responsetypes::formation","ldbws::responsetypes::loadingcategory","ldbws::responsetypes::location","ldbws::responsetypes::servicedetails","ldbws::responsetypes::serviceitem","ldbws::responsetypes::serviceitemwithcallingpoints","ldbws::responsetypes::stationboard","ldbws::responsetypes::stationboardwithdetails","ldbws::responsetypes::toiletavailability","ldbws::service","ldbws::requesterror#details()","ldbws::service#get_arr_board_with_details()","ldbws::service#get_arr_dep_board_with_details()","ldbws::service#get_arrival_board()","ldbws::service#get_arrival_board_with_details()","ldbws::service#get_arrival_departure_board()","ldbws::service#get_arrival_departure_board_with_details()","ldbws::service#get_dep_board_with_details()","ldbws::service#get_departure_board()","ldbws::service#get_departure_board_with_details()","ldbws::service#get_fastest_departures_with_details()","ldbws::service#get_next_departures()","ldbws::service#get_next_departures_with_details()","ldbws::service#get_service_details()","ldbws::request::paramvalidationerror#messages()","ldbws::service::new()","ldbws::service()","",""],"info":[["Ldbws","","Ldbws.html","","<p>Provides a Ruby abstraction around the UK’s Network Rail live departure board webservice (LDBWS). See …\n"],["Ldbws::Request","","Ldbws/Request.html","",""],["Ldbws::Request::GetDeparturesBoard","","Ldbws/Request/GetDeparturesBoard.html","","<p>Requests a departure board for a station, filtered by departures to one or many other stations. Corresponds …\n"],["Ldbws::Request::GetDeparturesBoardWithDetails","","Ldbws/Request/GetDeparturesBoardWithDetails.html","","<p>Requests a departure board for a statuion, filtered by departures to one or more other stations. This …\n"],["Ldbws::Request::GetServiceDetails","","Ldbws/Request/GetServiceDetails.html","","<p>Returns details about a particular service. Corresponds to <code>GetServiceDetailsResponse</code> in the LDBWS schema. …\n"],["Ldbws::Request::GetStationBoard","","Ldbws/Request/GetStationBoard.html","","<p>Returns an arrival or departure board for a given station. Corresponds to <code>GetStationBoardRequest</code> in the …\n"],["Ldbws::Request::GetStationBoardWithDetails","","Ldbws/Request/GetStationBoardWithDetails.html","","<p>Returns an arrival or departure board for a given station with full service details. Corresponds to …\n"],["Ldbws::Request::ParamValidationError","","Ldbws/Request/ParamValidationError.html","","<p>Raised when an error occurs when validating request parameters. Messages are passed through directly …\n"],["Ldbws::RequestError","","Ldbws/RequestError.html","","<p>Raised when a request has resulted in an error that this library can make some sense of. This <em>usually</em> …\n"],["Ldbws::ResponseParsingError","","Ldbws/ResponseParsingError.html","","<p>Raised when a response from LDBWS cannot be parsed by this library. This is unexpected, and generally …\n"],["Ldbws::ResponseTypes","","Ldbws/ResponseTypes.html","",""],["Ldbws::ResponseTypes::BaseStationBoard","","Ldbws/ResponseTypes/BaseStationBoard.html","","<p>Base station board information. This does not directly correspond to a type in LDBWS.\n<p>Properties\n"],["Ldbws::ResponseTypes::CallingPoint","","Ldbws/ResponseTypes/CallingPoint.html","","<p>Represents a calling point in the LDBWS.\n<p>Properties\n<p>location_name — the name of the station\n"],["Ldbws::ResponseTypes::Coach","","Ldbws/ResponseTypes/Coach.html","","<p>Information about an individual coach in the train.\n<p>Properties\n<p>number — the coach number or identifier\n"],["Ldbws::ResponseTypes::DepartureItem","","Ldbws/ResponseTypes/DepartureItem.html","","<p>Represents an item on a departure board.\n<p>Properties\n<p>crs — the CRS for the item\n"],["Ldbws::ResponseTypes::DepartureItemWithDetails","","Ldbws/ResponseTypes/DepartureItemWithDetails.html","","<p>Represents an item on a departure board with additional details.\n<p>Properties\n<p>crs — the CRS for the item\n"],["Ldbws::ResponseTypes::DeparturesBoard","","Ldbws/ResponseTypes/DeparturesBoard.html","","<p>Represents a departures board.\n<p>Properties\n<p>departures — a list of departures.\n"],["Ldbws::ResponseTypes::DeparturesBoardWithDetails","","Ldbws/ResponseTypes/DeparturesBoardWithDetails.html","","<p>Represents a departures board with additional details.\n<p>Properties\n<p>departures — a list of departures.\n"],["Ldbws::ResponseTypes::Formation","","Ldbws/ResponseTypes/Formation.html","","<p>Information about the formation of a train\n<p>Properties\n<p>loading_category — how heavily-loaded the train is. …\n"],["Ldbws::ResponseTypes::LoadingCategory","","Ldbws/ResponseTypes/LoadingCategory.html","","<p>The loading category of a train\n<p>Properties\n<p>code, colour, image — \n"],["Ldbws::ResponseTypes::Location","","Ldbws/ResponseTypes/Location.html","","<p>Represents a location in LDBWS.\n<p>Properties\n<p>name, crs, via — \n"],["Ldbws::ResponseTypes::ServiceDetails","","Ldbws/ResponseTypes/ServiceDetails.html","","<p>Represents details about a service in LDBWS.\n<p>Properties\n"],["Ldbws::ResponseTypes::ServiceItem","","Ldbws/ResponseTypes/ServiceItem.html","","<p>Represents a service item in LDBWS.\n<p>Properties\n<p>sta — the scheduled arrival time as a Time object\n"],["Ldbws::ResponseTypes::ServiceItemWithCallingPoints","","Ldbws/ResponseTypes/ServiceItemWithCallingPoints.html","","<p>Represents a service item with additional details in LDBWS: extends ServiceItem.\n<p>Properties\n<p>As ServiceItem …\n"],["Ldbws::ResponseTypes::StationBoard","","Ldbws/ResponseTypes/StationBoard.html","","<p>Represents a station arrival/departure board in LDBWS.\n<p>Properties\n<p>As BaseStationBoard, and additionally: …\n"],["Ldbws::ResponseTypes::StationBoardWithDetails","","Ldbws/ResponseTypes/StationBoardWithDetails.html","","<p>Represents a station arrival/departure board with additional details in LDBWS.\n<p>Properties\n<p>As BaseStationBoard …\n"],["Ldbws::ResponseTypes::ToiletAvailability","","Ldbws/ResponseTypes/ToiletAvailability.html","","<p>The availability of an individual toilet on a train\n<p>Properties\n<p>type — the type of toilet\n"],["Ldbws::Service","","Ldbws/Service.html","","<p>A wrapper around the National Rail Live Departure Boards Webservice (LDBWS) API.\n<p>API methods are pretty …\n"],["details","Ldbws::RequestError","Ldbws/RequestError.html#method-i-details","()","<p>Returns the details of the error as a hash.\n"],["get_arr_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arr_board_with_details","(params)","<p>Retrieves a detailed station arrival board.\n<p>Parameters are validated using GetStationBoardWithDetails …\n"],["get_arr_dep_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arr_dep_board_with_details","(params)","<p>Retrieves a detailed station arrival + departures board.\n<p>Parameters are validated using GetStationBoardWithDetails …\n"],["get_arrival_board","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_board","(params)","<p>Retrieves a station arrival board.\n<p>Parameters are validated using GetStationBoard, returns a StationBoard …\n"],["get_arrival_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_board_with_details","(params)",""],["get_arrival_departure_board","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_departure_board","(params)","<p>Retrieves a station arrival + departure board.\n<p>Parameters are validated using GetStationBoard, returns …\n"],["get_arrival_departure_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_arrival_departure_board_with_details","(params)",""],["get_dep_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_dep_board_with_details","(params)","<p>Retrieves a detailed station departure board.\n<p>Parameters are validated using GetStationBoardWithDetails …\n"],["get_departure_board","Ldbws::Service","Ldbws/Service.html#method-i-get_departure_board","(params)","<p>Retrieves a station departure board.\n<p>Parameters are validated using GetStationBoard, returns a StationBoard …\n"],["get_departure_board_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_departure_board_with_details","(params)",""],["get_fastest_departures_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_fastest_departures_with_details","(params)","<p>Retrieves detailed information about the fastest departures from one station to one or many others.\n<p>Parameters …\n"],["get_next_departures","Ldbws::Service","Ldbws/Service.html#method-i-get_next_departures","(params)","<p>Retrieves the next departures from one station to one or many others.\n<p>Parameters are validated using …\n"],["get_next_departures_with_details","Ldbws::Service","Ldbws/Service.html#method-i-get_next_departures_with_details","(params)","<p>Retrieves detailed information about the next departures from one station to one or many others.\n<p>Parameters …\n"],["get_service_details","Ldbws::Service","Ldbws/Service.html#method-i-get_service_details","(params)","<p>Retrieves information about a specific service.\n<p>Parameters are validated using GetServiceDetails, returns …\n"],["messages","Ldbws::Request::ParamValidationError","Ldbws/Request/ParamValidationError.html#method-i-messages","()","<p>Returns the validation error messages as a hash.\n"],["new","Ldbws::Service","Ldbws/Service.html#method-c-new","(token)","<p>Creates a service object.\n<p>Parameters\n<p>token — the API token used to connect to the service\n"],["service","Ldbws","Ldbws.html#method-c-service","(token)","<p>Helper method that returns an instance of [Service].\n<p>Parameters\n<p>token — the API token used to connect to …\n"],["LICENSE","","LICENSE.html","","<p>MIT License\n<p>Copyright © 2022 Jon Pearse\n<p>Permission is hereby granted, free of charge, to any person obtaining …\n"],["README","","README_md.html","","<p>ldbws-ruby\n<p>I’ll write a proper readme/howto at some point, but short version is that this is a Ruby wrapper …\n"]]}}
|
data/doc/js/search_index.js.gz
CHANGED
Binary file
|
data/doc/table_of_contents.html
CHANGED
@@ -37,6 +37,10 @@
|
|
37
37
|
<li><a href="README_md.html#label-ldbws-ruby">ldbws-ruby</a>
|
38
38
|
<li><a href="README_md.html#label-HOWTO">HOWTO</a>
|
39
39
|
<li><a href="README_md.html#label-A+note+about+rate+limiting">A note about rate limiting</a>
|
40
|
+
<li><a href="README_md.html#label-Error-handling">Error-handling</a>
|
41
|
+
<li><a href="README_md.html#label-Ldbws-3A-3ARequest-3A-3AParamValidationError"><code>Ldbws::Request::ParamValidationError</code></a>
|
42
|
+
<li><a href="README_md.html#label-Ldbws-3A-3ARequestError"><code>Ldbws::RequestError</code></a>
|
43
|
+
<li><a href="README_md.html#label-Ldbws-3A-3AResponseParsingError"><code>Ldbws::ResponseParsingError</code></a>
|
40
44
|
<li><a href="README_md.html#label-Caveats">Caveats</a>
|
41
45
|
</ul>
|
42
46
|
</li>
|
@@ -85,6 +89,15 @@
|
|
85
89
|
<li><a href="Ldbws/Request/GetStationBoardWithDetails.html#label-Parameters">Parameters</a>
|
86
90
|
</ul>
|
87
91
|
</li>
|
92
|
+
<li class="class">
|
93
|
+
<a href="Ldbws/Request/ParamValidationError.html">Ldbws::Request::ParamValidationError</a>
|
94
|
+
</li>
|
95
|
+
<li class="class">
|
96
|
+
<a href="Ldbws/RequestError.html">Ldbws::RequestError</a>
|
97
|
+
</li>
|
98
|
+
<li class="class">
|
99
|
+
<a href="Ldbws/ResponseParsingError.html">Ldbws::ResponseParsingError</a>
|
100
|
+
</li>
|
88
101
|
<li class="module">
|
89
102
|
<a href="Ldbws/ResponseTypes.html">Ldbws::ResponseTypes</a>
|
90
103
|
</li>
|
@@ -223,6 +236,11 @@
|
|
223
236
|
—
|
224
237
|
<span class="container">Ldbws</span>
|
225
238
|
|
239
|
+
<li class="method">
|
240
|
+
<a href="Ldbws/RequestError.html#method-i-details">#details</a>
|
241
|
+
—
|
242
|
+
<span class="container">Ldbws::RequestError</span>
|
243
|
+
|
226
244
|
<li class="method">
|
227
245
|
<a href="Ldbws/Service.html#method-i-get_arr_board_with_details">#get_arr_board_with_details</a>
|
228
246
|
—
|
@@ -287,6 +305,11 @@
|
|
287
305
|
<a href="Ldbws/Service.html#method-i-get_service_details">#get_service_details</a>
|
288
306
|
—
|
289
307
|
<span class="container">Ldbws::Service</span>
|
308
|
+
|
309
|
+
<li class="method">
|
310
|
+
<a href="Ldbws/Request/ParamValidationError.html#method-i-messages">#messages</a>
|
311
|
+
—
|
312
|
+
<span class="container">Ldbws::Request::ParamValidationError</span>
|
290
313
|
</ul>
|
291
314
|
</main>
|
292
315
|
|
data/lib/ldbws/request/base.rb
CHANGED
@@ -48,7 +48,9 @@ module Ldbws::Request # :nodoc:
|
|
48
48
|
# xml:: the {XML node}[rdoc-ref:Nokogiri::XML::Node] that should contain the response to this request.
|
49
49
|
def from_soap(xml)
|
50
50
|
result_node = xml.xpath(self.class::RESULT_XPATH).first
|
51
|
-
|
51
|
+
unless result_node
|
52
|
+
raise Ldbws::ResponseParsingError("Root node not found (#{self.class::RESULT_XPATH})")
|
53
|
+
end
|
52
54
|
|
53
55
|
self.class::RESULT_TYPE.from_xml(result_node)
|
54
56
|
end
|
@@ -64,6 +66,16 @@ module Ldbws::Request # :nodoc:
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
#
|
68
|
-
|
69
|
+
# Raised when an error occurs when validating request parameters. Messages are passed through directly from
|
70
|
+
# {dry-schema}[https://dry-rb.org/gems/dry-schema/1.10/].
|
71
|
+
class ParamValidationError < RuntimeError
|
72
|
+
def initialize(messages) # :nodoc:
|
73
|
+
@messages = messages.to_h
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns the validation error messages as a hash.
|
77
|
+
def messages
|
78
|
+
@messages
|
79
|
+
end
|
80
|
+
end
|
69
81
|
end
|
data/lib/ldbws/service.rb
CHANGED
@@ -179,7 +179,7 @@ module Ldbws
|
|
179
179
|
xml.remove_namespaces!
|
180
180
|
|
181
181
|
response_node = xml.xpath("//#{root_node}Response").first
|
182
|
-
|
182
|
+
return extract_error(xml) unless response_node
|
183
183
|
|
184
184
|
request.from_soap(response_node)
|
185
185
|
end
|
@@ -214,5 +214,15 @@ module Ldbws
|
|
214
214
|
|
215
215
|
conn.post(uri.path, body).body
|
216
216
|
end
|
217
|
+
|
218
|
+
def extract_error(xml)
|
219
|
+
# attempt to work out what the error is from the response, or fail with a general error
|
220
|
+
fault_node = xml.xpath("/Envelope/Body/Fault").first
|
221
|
+
raise Ldbws::ParsingError.new("Could not parse the response from the server") unless fault_node
|
222
|
+
|
223
|
+
# try and acquire information from the server
|
224
|
+
details = fault_node.children.map { |child| [child.name.to_sym, child.text] }.to_h
|
225
|
+
raise Ldbws::RequestError.new(details)
|
226
|
+
end
|
217
227
|
end
|
218
228
|
end
|
data/lib/ldbws/version.rb
CHANGED
data/lib/ldbws.rb
CHANGED
@@ -10,4 +10,35 @@ module Ldbws
|
|
10
10
|
def self.service(token)
|
11
11
|
Service.new(token)
|
12
12
|
end
|
13
|
+
|
14
|
+
# Raised when a request has resulted in an error that this library can make some sense of. This <i>usually</i>
|
15
|
+
# occurs due to something being wrong with a request like an invalid CRS code.
|
16
|
+
#
|
17
|
+
# Unfortunately LDBWS doesn’t generate particularly helpful CRS codes, so the #details method will return a hashified
|
18
|
+
# version of the response from the server.
|
19
|
+
#
|
20
|
+
# Thus, for a missing CRS, you’ll get:
|
21
|
+
#
|
22
|
+
# {
|
23
|
+
# faultcode: "soap:Server",
|
24
|
+
# faultstring: "Unexpected server error",
|
25
|
+
# detail: ""
|
26
|
+
# }
|
27
|
+
#
|
28
|
+
# Which isn’t especially useful. Best suggestion if you get this is to double-check your code to make sure the request
|
29
|
+
# is sane.
|
30
|
+
class RequestError < RuntimeError
|
31
|
+
def initialize(details) # :nodoc:
|
32
|
+
@details = details
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns the details of the error as a hash.
|
36
|
+
def details
|
37
|
+
@details
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Raised when a response from LDBWS cannot be parsed by this library. This is unexpected, and generally means you’ll
|
42
|
+
# need to raise an issue against this gem.
|
43
|
+
class ResponseParsingError < RuntimeError; end
|
13
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ldbws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Pearse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-schema
|
@@ -102,6 +102,7 @@ extra_rdoc_files: []
|
|
102
102
|
files:
|
103
103
|
- ".editorconfig"
|
104
104
|
- ".envrc"
|
105
|
+
- ".gitattributes"
|
105
106
|
- ".gitignore"
|
106
107
|
- Gemfile
|
107
108
|
- Gemfile.lock
|
@@ -116,6 +117,9 @@ files:
|
|
116
117
|
- doc/Ldbws/Request/GetServiceDetails.html
|
117
118
|
- doc/Ldbws/Request/GetStationBoard.html
|
118
119
|
- doc/Ldbws/Request/GetStationBoardWithDetails.html
|
120
|
+
- doc/Ldbws/Request/ParamValidationError.html
|
121
|
+
- doc/Ldbws/RequestError.html
|
122
|
+
- doc/Ldbws/ResponseParsingError.html
|
119
123
|
- doc/Ldbws/ResponseTypes.html
|
120
124
|
- doc/Ldbws/ResponseTypes/BaseStationBoard.html
|
121
125
|
- doc/Ldbws/ResponseTypes/CallingPoint.html
|