Skip to content
Snippets Groups Projects
Commit b1784938 authored by Jez Stephens's avatar Jez Stephens
Browse files

Allow Mapquest API version to be specified

parent c740bbb7
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,8 @@ module Geocoder::Lookup
def query_url(query)
domain = configuration[:licensed] ? "www" : "open"
url = "#{protocol}://#{domain}.mapquestapi.com/geocoding/v1/#{search_type(query)}?"
version = configuration[:version] || 1
url = "#{protocol}://#{domain}.mapquestapi.com/geocoding/v#{version}/#{search_type(query)}?"
url + url_query_string(query)
end
......
......@@ -281,11 +281,11 @@ class ServicesTest < Test::Unit::TestCase
end
def test_api_route_licensed
Geocoder.configure(:lookup => :mapquest, :api_key => "abc123", :mapquest => {:licensed => true})
Geocoder.configure(:lookup => :mapquest, :api_key => "abc123", :mapquest => {:licensed => true, :version => 2})
lookup = Geocoder::Lookup::Mapquest.new
query = Geocoder::Query.new("Bluffton, SC")
res = lookup.query_url(query)
assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC",
assert_equal "http://www.mapquestapi.com/geocoding/v2/address?key=abc123&location=Bluffton%2C+SC",
res
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment