aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tom_tom.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tom_tom.rb')
-rw-r--r--lib/tom_tom.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/tom_tom.rb b/lib/tom_tom.rb
new file mode 100644
index 000000000..fcebcc7ac
--- /dev/null
+++ b/lib/tom_tom.rb
@@ -0,0 +1,26 @@
+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
+
+ def self.matrix(way_costs)
+ TomTom::Matrix.new(@connection).matrix(way_costs)
+ end
+end