travel_time 0.5.5 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/travel_time/client.rb +14 -3
- data/lib/travel_time/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7a2b13991042791d77578dc894e869564b289137381fc5c8b319fd37efb2b11
|
4
|
+
data.tar.gz: 587fac0cd53502b30c3834c7320e9b66dce1589dcb3d8757e8f0f1c7356ef920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cd13c389968b3b96684d9f36002dcc783f23c01cc90968af58e3ffb671dfb1ea6eed776e60cc7791bb15d78005753b5bc6fb5fa0574f58c0f6b92aa14157949
|
7
|
+
data.tar.gz: 6720fd0d83332a628d44743381c27c3d63f981c46f667fa228ca1fbb4ae015a84d127627a0acf91d76742d850c8794532fe0fae07e0cfc29ad2ff2c7adc10c45
|
data/README.md
CHANGED
@@ -68,6 +68,14 @@ departure_search = {
|
|
68
68
|
client.time_map(departure_searches: [departure_search])
|
69
69
|
```
|
70
70
|
|
71
|
+
### Rate Limiting
|
72
|
+
|
73
|
+
You may specify an optional rate limit when initializing your client. The `rate_limit` parameter sets a cap on the number of requests that can be made to the API in 60 seconds. Requests are balanced at equal intervals.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
client = TravelTime::Client.new(rate_limit = 60)
|
77
|
+
```
|
78
|
+
|
71
79
|
### [Isochrones (Time Map)](https://traveltime.com/docs/api/reference/isochrones)
|
72
80
|
Given origin coordinates, find shapes of zones reachable within corresponding travel time.
|
73
81
|
Find unions/intersections between different searches.
|
data/lib/travel_time/client.rb
CHANGED
@@ -3,15 +3,28 @@
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'travel_time/middleware/authentication'
|
5
5
|
require 'travel_time/middleware/proto'
|
6
|
+
require 'limiter'
|
6
7
|
|
7
8
|
module TravelTime
|
8
9
|
# The Client class provides the main interface to interact with the TravelTime API
|
9
10
|
class Client # rubocop:disable Metrics/ClassLength
|
11
|
+
extend Limiter::Mixin
|
10
12
|
API_BASE_URL = 'https://api.traveltimeapp.com/v4/'
|
11
13
|
|
12
14
|
attr_reader :connection, :proto_connection
|
13
15
|
|
14
|
-
def initialize
|
16
|
+
def initialize(rate_limit = nil)
|
17
|
+
init_connection
|
18
|
+
init_proto_connection
|
19
|
+
|
20
|
+
return unless rate_limit
|
21
|
+
|
22
|
+
%i[perform_request perform_request_proto].each do |method_name|
|
23
|
+
self.class.limit_method method_name, balanced: true, rate: rate_limit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_connection
|
15
28
|
@connection = Faraday.new(API_BASE_URL) do |f|
|
16
29
|
f.request :json
|
17
30
|
f.response :raise_error if TravelTime.config.raise_on_failure
|
@@ -20,8 +33,6 @@ module TravelTime
|
|
20
33
|
f.use TravelTime::Middleware::Authentication
|
21
34
|
f.adapter TravelTime.config.http_adapter || Faraday.default_adapter
|
22
35
|
end
|
23
|
-
|
24
|
-
init_proto_connection
|
25
36
|
end
|
26
37
|
|
27
38
|
def init_proto_connection
|
data/lib/travel_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travel_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TravelTime Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +64,20 @@ dependencies:
|
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 3.21.9
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: ruby-limiter
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.2.2
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.2.2
|
67
81
|
description: TravelTime SDK for Ruby programming language
|
68
82
|
email:
|
69
83
|
- support@traveltime.com
|