# Get yo' rep! This is the companion [gem](https://rubygems.org/gems/get_your_rep) for the [Phone Your Rep API] (https://github.com/thecristen/phone-your-rep-api) This gem sends requests to the Google Civic Information API and the OpenStates.org API for info on your representatives and parses the JSON responses into Ruby objects. ## Installation Add this line to your application's Gemfile: ```ruby gem 'get_your_rep' ``` And then execute: $ bundle Or install it yourself as: $ gem install get_your_rep ## You must use your own Google API key activated for use with the [Civic Information API](https://developers.google.com/civic-information/). Add this line to your ~/.bashrc or ~/.bash_profile `export GOOGLE_API_KEY=""` ## Usage Send queries like this `reps = GetYourRep.all_reps(address)` to gather a Delegation of Representatives. This will get federal legislators from Google and state legislators form OpenStates.org `address` is your address. You can use just a zip code, but use a full address for the best results. Don't worry about commas, spaces, character case, or `.`s (`"123 1/2 main St., anywhere CA 12345"` is A-OK) Some queries will return `nil` when using only a zip code because not every zip code can be directly mapped to a voting district. I strongly recommend using a full address. Add Delegations together with `delegation.merge(other_delegation)`. This will add the other delegation's reps to the method caller, without altering the other. You can iterate over a Delegation's reps like so: `delegetion.reps.each { |rep| rep.name }`. There is also a shortcut for that: `delegation.each { |rep| rep.name }`. There is also a shortcut for that: `delegation.names`. Also works with `#first_names`, `#last_names`, and `#office_locations`. Get Federal and State executives and legislators with `GetYourRep::Google.all_reps(address)`. Get Congress only with `GetYourRep::Google.all_reps(address, congress_only: true)`. Get state legislators only with `GetYourRep::OpenStates.all_reps(address)`. ## Development After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Add `export GOOGLE_API_KEY=""` to your `.bashrc` or `.bash_profile` and then `bundle exec rake_test`. ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/msimonborg/get_your_rep. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).