Created
December 16, 2016 14:30
-
-
Save progapandist/98062626ccb501dba1456347f32c8c13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_parsed_response(url, query) | |
# Use HTTParty gem to make a get request | |
response = HTTParty.get(url + query) | |
# Parse the resulting JSON so it's now a Ruby Hash | |
parsed = JSON.parse(response.body) | |
# Return nil if we got no results from the API. | |
parsed['status'] != 'ZERO_RESULTS' ? parsed : nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment