Skip to content

Commit

Permalink
- enable proto distance
Browse files Browse the repository at this point in the history
- add disclaimer to readme on proto distance
  • Loading branch information
EivydasKoc committed Nov 7, 2022
1 parent 8e5c6b2 commit 402039e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,40 @@ response = client.time_filter_fast_proto(
puts(response.body)
```

### Time Filter (Fast) Proto Distance
A version of `Time Filter (Fast) Proto` endpoint that also returns distance information. Request parameters are even more limited than `Time Filter (Fast) Proto`.

This endpoint is not enabled by default, please [contact us](https://traveltime.com/contact-us) if you wish to obtain access.

Body attributes:
* origin: Origin point.
* destinations: Destination points. Cannot be more than 200,000.
* transport: Transportation type.
* travelTime: Time limit;
* country: Return the results that are within the specified country

```ruby
origin = {
lat: 51.508930,
lng: -0.131387,
}

destinations = [{
lat: 51.508824,
lng: -0.167093,
}]

response = client.time_filter_fast_proto_distance(
country: 'UK',
origin: origin,
destinations: destinations,
transport: 'driving+ferry',
traveltime: 7200
)
puts(response.body)
```


### [Time Filter (Postcode Districts)](https://traveltime.com/docs/api/reference/postcode-district-filter)
Find districts that have a certain coverage from origin (or to destination) and get statistics about postcodes within such districts.
Currently only supports United Kingdom.
Expand Down
9 changes: 9 additions & 0 deletions lib/travel_time/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ def time_filter_fast_proto(country:, origin:, destinations:, transport:, travelt
end
end

def time_filter_fast_proto_distance(country:, origin:, destinations:, transport:, traveltime:)
message = ProtoUtils.make_proto_message(origin, destinations, transport, traveltime, properties: [1])
payload = ProtoUtils.encode_proto_message(message)
perform_request_proto do
proto_connection.post("https://proto-with-distance.api.traveltimeapp.com/api/v2/#{country}/time-filter/fast/#{transport}",
payload)
end
end

def time_filter_postcodes(departure_searches: nil, arrival_searches: nil)
payload = {
departure_searches: departure_searches,
Expand Down
14 changes: 14 additions & 0 deletions spec/travel_time/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@
it_behaves_like 'an endpoint method'
end

describe '#time_filter_fast_proto_distance' do
country = 'uk'
transport = 'driving+ferry'
subject(:response) do
client.time_filter_fast_proto_distance(country: country, origin: {}, destinations: {}, transport: transport,
traveltime: 0)
end

let(:url) { "https://proto-with-distance.api.traveltimeapp.com/api/v2/#{country}/time-filter/fast/#{transport}" }
let(:stub) { stub_request(:post, url) }

it_behaves_like 'an endpoint method'
end

describe '#time_filter_postcodes' do
subject(:response) { client.time_filter_postcodes(arrival_searches: []) }

Expand Down

0 comments on commit 402039e

Please sign in to comment.