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.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/tom_tom.rb b/lib/tom_tom.rb
index 58604c347..415bba54b 100644
--- a/lib/tom_tom.rb
+++ b/lib/tom_tom.rb
@@ -32,6 +32,21 @@ class TomTom
batchItems: batch_items
}.to_json
end
+
+ response = JSON.parse(response.body)
+
+ calculated_routes = response['batchItems']
+ calculated_routes.each_with_index do |route, i|
+ next if route['statusCode'] != 200
+
+ distance = route['response']['routes'][0]['summary']['lengthInMeters']
+ time = route['response']['routes'][0]['summary']['travelTimeInSeconds']
+
+ way_costs[i].distance = distance
+ way_costs[i].time = time
+ end
+
+ way_costs
end
def convert_way_costs_for_batch(way_costs)