travel_time 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -0
- data/lib/travel_time/client.rb +10 -1
- data/lib/travel_time/middleware/authentication.rb +2 -0
- data/lib/travel_time/middleware/proto.rb +1 -0
- data/lib/travel_time/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf2f0de892f4913899dc12a618af54bdc0d0cd531233407608e9f95962900c8
|
4
|
+
data.tar.gz: d78ae9c592b7c8dbab7c29204f81543cda363dc03928182fe34243e7c5893951
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de6eda8e48059030a5f42fce898f444fd9ff93cdf0e0d22357f038ffc65e989fc818fe0adc2d97479ded35bc469fc20d1477c811390ab6e810a91825e270be76
|
7
|
+
data.tar.gz: 57ae66632a19f79ee6f8649551b6f4a397634d60a025c98e047c511e257a0e813fcd77699d9a4fe952b373e2b3d954ca497e05a57a01e346d169854024f7e805
|
data/README.md
CHANGED
@@ -120,6 +120,43 @@ response = client.time_map(
|
|
120
120
|
puts response.body
|
121
121
|
```
|
122
122
|
|
123
|
+
### [Isochrones (Time Map) Fast](https://docs.traveltime.com/api/reference/isochrones-fast)
|
124
|
+
A very fast version of Isochrone API. However, the request parameters are much more limited.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
require 'time'
|
128
|
+
|
129
|
+
arrival_search = {
|
130
|
+
id: "public transport to Trafalgar Square",
|
131
|
+
coords: {
|
132
|
+
lat: 51.506756,
|
133
|
+
lng: -0.128050
|
134
|
+
},
|
135
|
+
transportation: { type: "public_transport" },
|
136
|
+
arrival_time: Time.now.iso8601,
|
137
|
+
travel_time: 1800,
|
138
|
+
}
|
139
|
+
|
140
|
+
union = {
|
141
|
+
id: 'union of driving and public transport',
|
142
|
+
search_ids: ['public transport from Trafalgar Square', 'public transport to Trafalgar Square']
|
143
|
+
}
|
144
|
+
intersection = {
|
145
|
+
id: 'intersection of driving and public transport',
|
146
|
+
search_ids: ['public transport from Trafalgar Square', 'public transport to Trafalgar Square']
|
147
|
+
}
|
148
|
+
|
149
|
+
response = client.time_map_fast(
|
150
|
+
arrival_searches: {
|
151
|
+
one_to_many: [arrival_search]
|
152
|
+
},
|
153
|
+
unions: [union],
|
154
|
+
intersections: [intersection]
|
155
|
+
)
|
156
|
+
|
157
|
+
puts response.body
|
158
|
+
```
|
159
|
+
|
123
160
|
### [Distance Matrix (Time Filter)](https://traveltime.com/docs/api/reference/distance-matrix)
|
124
161
|
Given origin and destination points filter out points that cannot be reached within specified time limit.
|
125
162
|
Find out travel times, distances and costs between an origin and up to 2,000 destination points.
|
data/lib/travel_time/client.rb
CHANGED
@@ -74,7 +74,7 @@ module TravelTime
|
|
74
74
|
'format.exclude.country': exclude,
|
75
75
|
limit: limit,
|
76
76
|
'force.add.postcode': force_postcode,
|
77
|
-
bounds: bounds
|
77
|
+
bounds: bounds&.join(',')
|
78
78
|
}.compact
|
79
79
|
perform_request { connection.get('geocoding/search', query) }
|
80
80
|
end
|
@@ -99,6 +99,15 @@ module TravelTime
|
|
99
99
|
perform_request { connection.post('time-map', payload, { 'Accept' => format }) }
|
100
100
|
end
|
101
101
|
|
102
|
+
def time_map_fast(arrival_searches:, unions: nil, intersections: nil, format: nil)
|
103
|
+
payload = {
|
104
|
+
arrival_searches: arrival_searches,
|
105
|
+
unions: unions,
|
106
|
+
intersections: intersections
|
107
|
+
}.compact
|
108
|
+
perform_request { connection.post('time-map/fast', payload, { 'Accept' => format }) }
|
109
|
+
end
|
110
|
+
|
102
111
|
def time_filter(locations:, departure_searches: nil, arrival_searches: nil)
|
103
112
|
payload = {
|
104
113
|
locations: locations,
|
@@ -9,10 +9,12 @@ module TravelTime
|
|
9
9
|
class Authentication < Faraday::Middleware
|
10
10
|
APP_ID_HEADER = 'X-Application-Id'
|
11
11
|
API_KEY_HEADER = 'X-Api-Key'
|
12
|
+
USER_AGENT = 'User-Agent'
|
12
13
|
|
13
14
|
def on_request(env)
|
14
15
|
env.request_headers[APP_ID_HEADER] = TravelTime.config.application_id
|
15
16
|
env.request_headers[API_KEY_HEADER] = TravelTime.config.api_key
|
17
|
+
env.request_headers[USER_AGENT] = 'Travel Time Ruby SDK'
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -13,6 +13,7 @@ module TravelTime
|
|
13
13
|
"Basic #{Base64.encode64("#{TravelTime.config.application_id}:#{TravelTime.config.api_key}")}"
|
14
14
|
env.request_headers['Content-Type'] = 'application/octet-stream'
|
15
15
|
env.request_headers['Accept'] = 'application/octet-stream'
|
16
|
+
env.request_headers['User-Agent'] = 'Travel Time Ruby SDK'
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/travel_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travel_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TravelTime Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|