Class: OpenFec::Resources::Contributions

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

Overview

Itemized contribution records (Schedule A). Uses seek/cursor-based pagination (not offset-based).

Examples:

Get PAC contributions to a committee

OpenFec.contributions.from_pacs(committee_id: 'C00213512', cycle: 2024)

Paginate all contributions

OpenFec.contributions.each_page(committee_id: 'C00213512') do |page|
  page.each { |c| puts c['contributor_name'] }
end

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#all_contributions(**params) ⇒ Array<Hash>

Fetch all itemized contributions (seek-based). Use with caution on large result sets.

Parameters:

  • params (Hash)

    filters

Returns:

  • (Array<Hash>)

    all contribution records



50
51
52
# File 'lib/open_fec/resources/contributions.rb', line 50

def all_contributions(**params)
  client.all_seek('schedules/schedule_a/', params)
end

#each_page(**params) {|OpenFec::Response| ... } ⇒ Object

Paginate through itemized contributions (seek/cursor-based).

Parameters:

  • params (Hash)

    filters

Yields:



41
42
43
# File 'lib/open_fec/resources/contributions.rb', line 41

def each_page(**params, &)
  client.paginate_seek('schedules/schedule_a/', params, &)
end

#from_pacs(committee_id:, cycle: nil, **params) ⇒ OpenFec::Response

PAC contributions to a committee (entity_type=COM).

Parameters:

  • committee_id (String)

    FEC committee ID

  • cycle (Integer, nil) (defaults to: nil)

    election cycle year

  • params (Hash)

    additional filters

Returns:



31
32
33
34
35
# File 'lib/open_fec/resources/contributions.rb', line 31

def from_pacs(committee_id:, cycle: nil, **params)
  merged = params.merge(committee_id: committee_id, entity_type: 'COM')
  merged[:two_year_transaction_period] = cycle if cycle
  get('schedules/schedule_a/', merged)
end

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

List itemized contributions (Schedule A).

Parameters:

  • params (Hash)

    filters (:committee_id, :contributor_name, :entity_type, :two_year_transaction_period, :sort, etc.)

Returns:



21
22
23
# File 'lib/open_fec/resources/contributions.rb', line 21

def list(**params)
  get('schedules/schedule_a/', params)
end