aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/tom_tom.rb16
-rw-r--r--lib/tom_tom/batch.rb15
2 files changed, 18 insertions, 13 deletions
diff --git a/lib/tom_tom.rb b/lib/tom_tom.rb
index 2947961c3..97f914f28 100644
--- a/lib/tom_tom.rb
+++ b/lib/tom_tom.rb
@@ -1,2 +1,18 @@
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.batch(way_costs)
+ TomTom::Batch.new(@connection).batch(way_costs)
+ end
end
diff --git a/lib/tom_tom/batch.rb b/lib/tom_tom/batch.rb
index 4d590a945..f947cced8 100644
--- a/lib/tom_tom/batch.rb
+++ b/lib/tom_tom/batch.rb
@@ -1,18 +1,7 @@
module TomTom
class Batch
- BASE_URL = 'https://api.tomtom.com'
- API_KEY = Rails.application.secrets.tomtom_api_key
-
- def initialize
- @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 initialize(connection)
+ @connection = connection
end
def batch(way_costs)