Created
March 18, 2017 19:06
-
-
Save dwillis/2b1bcfdec363709a4b8bc966b5d03625 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 self.locate(address) | |
url = "https://www.googleapis.com/civicinfo/v2/representatives?address=#{address}&includeOffices=true&levels=country&roles=legislatorUpperBody&roles=legislatorLowerBody&key=APIKEY" | |
result = JSON.parse(open(url).read) | |
state = result['normalizedInput']['state'] | |
house = result['offices'].detect{|o| o['roles'].include?('legislatorLowerBody')} | |
house_district = house['divisionId'].split(":").last if house | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment