Skip to content

Update from Mashape to RapidAPI#1450

Merged
alexreisner merged 4 commits intoalexreisner:masterfrom
alexwalling:patch-1
Apr 30, 2020
Merged

Update from Mashape to RapidAPI#1450
alexreisner merged 4 commits intoalexreisner:masterfrom
alexwalling:patch-1

Conversation

@alexwalling
Copy link
Copy Markdown
Contributor

The Mashape API proxy has been deprecated and needs to be replaced with RapidAPI proxy URL to work reliably.

The Mashape API proxy URL has been deprecated and replaced with the RapidAPI proxy URL. These changes will update the code to work with the new URL
The Mashape URL has recently been deprecated so for reliable use of Telize you will need to use the RapidAPI URL instead.
assert qurl.include?("mashape-key")
assert !key.include?("mashape-key")
assert qurl.include?("rapidapi-key")
assert !key.include?("rapidapi-key")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

key = lookup.send(:cache_key, query)
assert qurl.include?("mashape-key")
assert !key.include?("mashape-key")
assert qurl.include?("rapidapi-key")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [82/80]

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [94/80]

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [108/80]

Comment thread test/unit/lookup_test.rb
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"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [89/80]

"#{protocol}://#{configuration[:host]}/location/#{query.sanitized_text}"
else
"#{protocol}://telize-v1.p.mashape.com/location/#{query.sanitized_text}?mashape-key=#{api_key}"
"#{protocol}://telize-v1.p.rapidapi.com/location/#{query.sanitized_text}?rapidapi-key=#{api_key}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [105/80]

@timrwilliams
Copy link
Copy Markdown
Contributor

To add some more detail this change is required to fix the hosted Telize lookup service which is currently broken for all versions of this gem.

We're currently having to remediate this via a monkey patch in our initializer:

#config/initializers/geocoder.rb
Geocoder::Lookup::Telize.class_eval do
  def query_url(query)
    "#{protocol}://telize-v1.p.rapidapi.com/location/#{query.sanitized_text}?rapidapi-key=#{api_key}"
  end
end

@alexreisner
Copy link
Copy Markdown
Owner

Thanks for this (and sorry for the Hound auto-comments--I've yet to configure it). The code looks good and I'd like to get this merged. The only obstacle is getting an API key so I can test it. I tried the contact form on RapidAPI.com but it wouldn't submit ("Submission failed, please try again later."). Any thoughts on how I might run a few test queries from my local machine? Is there someone I can contact directly?

@timrwilliams
Copy link
Copy Markdown
Contributor

I've sent you one to use via the contact form on your website.

@alexwalling
Copy link
Copy Markdown
Contributor Author

If you have any issues with the key sent to you by Tim, just shoot an email to support@rapidapi.com and they can help you there.

@alexreisner alexreisner merged commit b723d0f into alexreisner:master Apr 30, 2020
@alexreisner
Copy link
Copy Markdown
Owner

The key worked great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants