Class: GoogleCivic::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/google-civic/client.rb

Instance Method Summary collapse

Methods included from Request

#get, #post

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/google-civic/client.rb', line 6

def initialize(options={})
  @key = options[:key]
end

Instance Method Details

#elections(options = {}) ⇒ Hashie::Mash

Gets a list of elections in the API

Examples:

List the current elections

GoogleCivic.elections

Returns:

  • (Hashie::Mash)

    A list of current elections in the API

See Also:



19
20
21
# File 'lib/google-civic/client.rb', line 19

def elections(options={})
  get("elections", options)
end

#representative_info(address, options = {}) ⇒ Hashie::Mash

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

Examples:

List information about the representatives

GoogleCivic.representative_info('1263 Pacific Ave. Kansas City KS')

Parameters:

  • address (String)

    The address to search on.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hashie::Mash)

    A list of current information about representatives

See Also:



44
45
46
# 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 = {}) ⇒ Hashie::Mash

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

Examples:

List information around the voter

GoogleCivic.voter_info(200, '1263 Pacific Ave. Kansas City KS')

Parameters:

  • election_id (Integer)

    The id of the election found in .elections

  • address (String)

    The address to search on.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hashie::Mash)

    A list of current information around the voter

See Also:



32
33
34
# File 'lib/google-civic/client.rb', line 32

def voter_info(election_id, address, options={})
  post("voterinfo/#{election_id}/lookup", {address: address}, options)
end