tfl_api_client 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deb99ecef39b8759c52cdaa5e774800efc2dde1b
4
- data.tar.gz: c1c9adf6bf722e5281ea6f80d920ee4edefa38dc
3
+ metadata.gz: 2df78d3542369083dd156f9abc8e5ef88771e690
4
+ data.tar.gz: 7fcedd056b1b6d294dc8eab63b5a518fa5f6108a
5
5
  SHA512:
6
- metadata.gz: 521acedbe9583749c68f84f4754fa159bc1fe7ec7ab1faab21d1c2f7b11e048ff4f03c8fa84a95d9b9cee62e2300e494bfbfc80e2269dc05ae840670d2e23048
7
- data.tar.gz: ef54b73f0b5f1ae27ae0f3bb67b3a706aa539f1c76c86471c4ba675b5ec2c5e5b7efc38d782ae112ef02a709e75f6c40157586f7ebaeee7e3576d13d09e2b894
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
@@ -24,5 +24,5 @@
24
24
  #
25
25
 
26
26
  module TflApi
27
- VERSION = '0.4.0'
27
+ VERSION = '0.5.0'
28
28
  end
@@ -30,6 +30,7 @@ require 'tfl_api_client/air_quality'
30
30
  require 'tfl_api_client/bike_point'
31
31
  require 'tfl_api_client/cycle'
32
32
  require 'tfl_api_client/cabwise'
33
+ require 'tfl_api_client/journey'
33
34
  require 'tfl_api_client/exceptions'
34
35
 
35
36
  module TflApi
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.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-04-18 00:00:00.000000000 Z
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: