aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tom_tom.rb
diff options
context:
space:
mode:
authorAlban Peignier2018-03-15 17:09:34 +0100
committerGitHub2018-03-15 17:09:34 +0100
commitf011f7e9806ffeaaba3ad73510bc818211f55dbd (patch)
treeb59a6a71f82b7121fb3a0ffa3a65b9d7cedaa3aa /lib/tom_tom.rb
parentd3d3c0f40c37d716cfccbf9297bfbdc98c692521 (diff)
parent9291d45e825edbaf52cb556c102498366985496f (diff)
downloadchouette-core-f011f7e9806ffeaaba3ad73510bc818211f55dbd.tar.bz2
Merge pull request #379 from af83/6095-route--calculate-distance-and-time-cost-between-stops
Calculate distance and time cost between Route stops. Refs #6095
Diffstat (limited to 'lib/tom_tom.rb')
-rw-r--r--lib/tom_tom.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/tom_tom.rb b/lib/tom_tom.rb
new file mode 100644
index 000000000..a1a2bda43
--- /dev/null
+++ b/lib/tom_tom.rb
@@ -0,0 +1,22 @@
+module TomTom
+ BASE_URL = 'https://api.tomtom.com'
+ @api_key = Rails.application.secrets.tomtom_api_key
+
+ @connection = Faraday.new(
+ url: BASE_URL,
+ params: {
+ key: @api_key
+ }
+ ) do |faraday|
+ faraday.use FaradayMiddleware::FollowRedirects, limit: 1
+ faraday.adapter Faraday.default_adapter
+ end
+
+ def self.enabled?
+ @api_key.present?
+ end
+
+ def self.batch(way_costs)
+ TomTom::Batch.new(@connection).batch(way_costs)
+ end
+end