Class: OpenFec::Resources::Elections

Inherits:
Base
  • Object
show all
Defined in:
lib/open_fec/resources/elections.rb

Overview

Election results and candidate comparisons for a specific race. Shows all candidates who ran in a district with financial totals side by side.

Examples:

Get all candidates who ran for VA-08 in 2024

OpenFec.elections.list(state: 'VA', district: '08', cycle: 2024, office: 'house')

Election summary for a race

OpenFec.elections.summary(cycle: 2024, office: 'house', state: 'VA', district: '08')

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from OpenFec::Resources::Base

Instance Method Details

#list(**params) ⇒ OpenFec::Response

List all candidates in a specific election with financial totals. Returns candidate_name, party, total_receipts, total_disbursements, cash_on_hand_end_period, etc.

Parameters:

  • params (Hash)

    filters (:state, :district, :cycle, :office — “house” or “senate”)

Returns:



20
21
22
# File 'lib/open_fec/resources/elections.rb', line 20

def list(**params)
  get('elections/', params)
end

#search(**params) ⇒ OpenFec::Response

Search for elections by state, office, and cycle.

Parameters:

  • params (Hash)

    filters (:state, :office, :cycle, :district, :zip)

Returns:



28
29
30
# File 'lib/open_fec/resources/elections.rb', line 28

def search(**params)
  get('elections/search/', params)
end

#summary(**params) ⇒ OpenFec::Response

Election summary with aggregate spending data.

Parameters:

  • params (Hash)

    filters (:cycle, :office, :state, :district, :election_full)

Returns:



36
37
38
# File 'lib/open_fec/resources/elections.rb', line 36

def summary(**params)
  get('elections/summary/', params)
end