tfl_api_client 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tfl_api_client/client.rb +9 -1
- data/lib/tfl_api_client/journey.rb +65 -0
- data/lib/tfl_api_client/version.rb +1 -1
- data/lib/tfl_api_client.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2df78d3542369083dd156f9abc8e5ef88771e690
|
4
|
+
data.tar.gz: 7fcedd056b1b6d294dc8eab63b5a518fa5f6108a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ee5f0764e016b88ab6a41f091473bd841dc2691b774e1199ec3ef185c862c7cb4c5b1def163a859321d020923a9d92fb2ac3cd506f01c6c41d6bc28bb0a5cc
|
7
|
+
data.tar.gz: '08fabde513a3ea107ee8a3eec8555f3cb7d614689702ca661a64765f3ef9aa2d6583e7f0adaebbc795085c93d4d645d8bdef0b7d5f20a43c0d6c86d203c1307f'
|
@@ -136,6 +136,14 @@ module TflApi
|
|
136
136
|
TflApi::Client::Cabwise.new(self)
|
137
137
|
end
|
138
138
|
|
139
|
+
# Creates an instance to the Journey class by passing a reference to self
|
140
|
+
#
|
141
|
+
# @return [TflApi::Client::Journey] An object to Journey subclass
|
142
|
+
#
|
143
|
+
def journey
|
144
|
+
TflApi::Client::Journey.new(self)
|
145
|
+
end
|
146
|
+
|
139
147
|
# Performs a HTTP GET request to the api, based upon the given URI resource
|
140
148
|
# and any additional HTTP query parameters. This method will automatically
|
141
149
|
# inject the mandatory application id and application key HTTP query
|
@@ -216,7 +224,7 @@ module TflApi
|
|
216
224
|
def format_request_uri(path, params)
|
217
225
|
params.merge!({app_id: app_id, app_key: app_key})
|
218
226
|
params_string = URI.encode_www_form(params)
|
219
|
-
URI::HTTPS.build(host: host.host, path: path, query: params_string)
|
227
|
+
URI::HTTPS.build(host: host.host, path: URI.escape(path), query: params_string)
|
220
228
|
end
|
221
229
|
|
222
230
|
# Parses the given response body as JSON, and returns a hash representation of the
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2015 - 2017 Luke Hackett
|
3
|
+
#
|
4
|
+
# MIT License
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#
|
25
|
+
|
26
|
+
module TflApi
|
27
|
+
class Client
|
28
|
+
# This class communicates with the TFL "/Journey" API to obtain
|
29
|
+
# details about taxis and minicabs contact information.
|
30
|
+
#
|
31
|
+
class Journey
|
32
|
+
|
33
|
+
# Initialize the Journey object and store the reference to Client object
|
34
|
+
#
|
35
|
+
# @param client [Client] the client object
|
36
|
+
#
|
37
|
+
# @return [Journey] the Journey object
|
38
|
+
#
|
39
|
+
def initialize(client)
|
40
|
+
@client = client
|
41
|
+
end
|
42
|
+
|
43
|
+
# Gets a list of all of the available journey planner modes.
|
44
|
+
#
|
45
|
+
# @return [Array] An array of all available journey planner modes
|
46
|
+
#
|
47
|
+
def modes
|
48
|
+
@client.get('/Journey/Meta/Modes')
|
49
|
+
end
|
50
|
+
|
51
|
+
# Perform a Journey Planner search from the parameters specified in
|
52
|
+
# simple types.
|
53
|
+
#
|
54
|
+
# @param from [String] the origin of the journey
|
55
|
+
# @param to [String] the destination of the journey
|
56
|
+
#
|
57
|
+
# @return [Hash] A hash of planner journey results
|
58
|
+
#
|
59
|
+
def planner(from, to, params={})
|
60
|
+
@client.get("/Journey/JourneyResults/#{from}/to/#{to}", params)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/tfl_api_client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tfl_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Hackett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/tfl_api_client/client.rb
|
157
157
|
- lib/tfl_api_client/cycle.rb
|
158
158
|
- lib/tfl_api_client/exceptions.rb
|
159
|
+
- lib/tfl_api_client/journey.rb
|
159
160
|
- lib/tfl_api_client/version.rb
|
160
161
|
homepage: https://github.com/LukeHackett/tfl_api_client
|
161
162
|
licenses:
|