Class: CivicInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/civic_info.rb

Instance Method Summary collapse

Constructor Details

#initializeCivicInfo

Returns a new instance of CivicInfo.



30
31
32
33
# File 'lib/civic_info.rb', line 30

def initialize
  raise if ENV['GOOGLE_API_KEY'].nil?
  @google_api = GoogleAPI.new(ENV['GOOGLE_API_KEY'], '/civicinfo/us_v1/')
end

Instance Method Details

#electionsObject



35
36
37
38
# File 'lib/civic_info.rb', line 35

def elections
  call_string = 'elections'
  @google_api.get(call_string)
end

#voter_info(election_id, address) ⇒ Object



40
41
42
43
44
45
# File 'lib/civic_info.rb', line 40

def voter_info(election_id, address)
  call_string = "voterinfo/#{election_id}/lookup"
  body = { :address => address }

  @google_api.post(call_string, body)
end