class GoogleCivic::Client

Public Class Methods

new(options={}) click to toggle source
# File lib/google-civic/client.rb, line 6
def initialize(options={})
  @key = options[:key]
end

Public Instance Methods

elections(options={}) click to toggle source

Gets a list of elections in the API

@return [Hashie::Mash] A list of current elections in the API @see developers.google.com/civic-information/docs/us_v1/elections/electionQuery @example List the current elections

GoogleCivic.elections
# File lib/google-civic/client.rb, line 19
def elections(options={})
  get("elections", options)
end
representative_info(address, options={}) click to toggle source

Looks up political geography and (optionally) representative information based on an address

@param address [String] The address to search on. @param options [Hash] A customizable set of options. @return [Hashie::Mash] A list of current information about representatives @see developers.google.com/civic-information/docs/us_v1/representatives/representativeInfoQuery @example List information about the representatives

GoogleCivic.representative_info('1263 Pacific Ave. Kansas City KS')
# File lib/google-civic/client.rb, line 44
def representative_info(address, options={})
  post("representatives/lookup", {address: address}, options)
end
voter_info(election_id, address, options={}) click to toggle source

Looks up information relevant to a voter based on the voter's registered address.

@param election_id [Integer] The id of the election found in .elections @param address [String] The address to search on. @param options [Hash] A customizable set of options. @return [Hashie::Mash] A list of current information around the voter @see developers.google.com/civic-information/docs/us_v1/elections/voterInfoQuery @example List information around the voter

GoogleCivic.voter_info(200, '1263 Pacific Ave. Kansas City KS')
# File lib/google-civic/client.rb, line 32
def voter_info(election_id, address, options={})
  post("voterinfo/#{election_id}/lookup", {address: address}, options)
end