Skip to content

Commit

Permalink
Update from Mashape to RapidAPI (#1450)
Browse files Browse the repository at this point in the history
Switch from Mashape URL to RapidAPI

The Mashape API proxy URL has been deprecated and replaced with the RapidAPI proxy URL.
  • Loading branch information
alexwalling committed Apr 30, 2020
1 parent ef1afc5 commit b723d0f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README_API_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ IP Address Lookups
* **Region**: world
* **SSL support**: yes
* **Languages**: English
* **Documentation**: https://market.mashape.com/fcambus/telize
* **Documentation**: https://rapidapi.com/fcambus/api/telize
* **Terms of Service**: ?
* **Limitations**: ?
* **Notes**: To use Telize set `Geocoder.configure(ip_lookup: :telize, api_key: "your_api_key")`. Or configure your self-hosted telize with the `host` option: `Geocoder.configure(ip_lookup: :telize, telize: {host: "localhost"})`.
Expand Down
2 changes: 1 addition & 1 deletion lib/geocoder/lookups/telize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def query_url(query)
if configuration[:host]
"#{protocol}:https://#{configuration[:host]}/location/#{query.sanitized_text}"
else
"#{protocol}:https://telize-v1.p.mashape.com/location/#{query.sanitized_text}?mashape-key=#{api_key}"
"#{protocol}:https://telize-v1.p.rapidapi.com/location/#{query.sanitized_text}?rapidapi-key=#{api_key}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/lookup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_geocoder_ca_showpostal
def test_telize_api_key
Geocoder.configure(:api_key => "MY_KEY")
g = Geocoder::Lookup::Telize.new
assert_match "mashape-key=MY_KEY", g.query_url(Geocoder::Query.new("232.65.123.94"))
assert_match "rapidapi-key=MY_KEY", g.query_url(Geocoder::Query.new("232.65.123.94"))
end

def test_ipinfo_io_api_key
Expand Down
10 changes: 5 additions & 5 deletions test/unit/lookups/telize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def setup
def test_query_url
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{^https://telize-v1\.p\.mashape\.com/location/74\.200\.247\.59}, lookup.query_url(query)
assert_match %r{^https://telize-v1\.p\.rapidapi\.com/location/74\.200\.247\.59}, lookup.query_url(query)
end

def test_includes_api_key_when_set
Geocoder.configure(api_key: "api_key")
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{/location/74\.200\.247\.59\?mashape-key=api_key}, lookup.query_url(query)
assert_match %r{/location/74\.200\.247\.59\?rapidapi-key=api_key}, lookup.query_url(query)
end

def test_uses_custom_host_when_set
Expand All @@ -38,7 +38,7 @@ def test_requires_https_when_not_custom_host
Geocoder.configure(use_https: false)
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{^https://telize-v1\.p\.mashape\.com}, lookup.query_url(query)
assert_match %r{^https://telize-v1\.p\.rapidapi\.com}, lookup.query_url(query)
end

def test_result_on_ip_address_search
Expand Down Expand Up @@ -83,7 +83,7 @@ def test_cache_key_strips_off_query_string
query = Geocoder::Query.new("8.8.8.8")
qurl = lookup.send(:query_url, query)
key = lookup.send(:cache_key, query)
assert qurl.include?("mashape-key")
assert !key.include?("mashape-key")
assert qurl.include?("rapidapi-key")
assert !key.include?("rapidapi-key")
end
end

0 comments on commit b723d0f

Please sign in to comment.