campaign_cash 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +27 -0
- data/lib/campaign_cash/electioneering_communication.rb +34 -0
- data/lib/campaign_cash/filing_summary.rb +1 -1
- data/lib/campaign_cash/independent_expenditure.rb +7 -3
- data/lib/campaign_cash/version.rb +1 -1
- data/lib/campaign_cash.rb +1 -1
- data/test/campaign_cash/test_electioneering_communication.rb +22 -0
- data/test/test_helper.rb +1 -1
- metadata +7 -4
data/README.rdoc
CHANGED
@@ -188,6 +188,33 @@ There's also the option to retrieve the 20 most recent IEs for the presidential
|
|
188
188
|
|
189
189
|
The IE responses also accept an optional offset argument, using multiples of 20.
|
190
190
|
|
191
|
+
== Individual Contributions
|
192
|
+
|
193
|
+
IndividualContribution objects are line items from committees' receipt filings. You can get them in three ways, by an FEC committee ID, a filing ID or an FEC candidate ID in groups of 20. These will be returned from newest to oldest. Note: in IndividualContribution responses, <tt>pac_name</tt> refers to any institutional donation, not just donations from other PACs.
|
194
|
+
|
195
|
+
IndividualContribution.committee("C00490045") # Restore Our Future
|
196
|
+
#=> [#<CampaignCash::IndividualContribution:0x102fd3948 @display_name=nil, @fec_form_type=nil, @aggregate_amount=100000.0, @zip="94129", @zip5="94129", @state="CA", @middle_name=nil, @conduit_state=nil, @conduit_address_one=nil, @conduit_name=nil, @memo_code=nil, @last_name=nil, @candidate_id=nil, @back_ref_sched_name=nil, @conduit_zip=nil, @committee_id=133, @suffix=nil, @donor_cmte_id=nil, @flag_orgind="ORG", @back_ref_tran_id=nil, @city="San Francisco", @amended_cd=nil, @donor_district=nil, @id=4571002, @exclude=nil, @donor_candidate=nil, @prigen=nil, @donor_cand_id=nil, @donor_office=nil, @occupation=nil, @tran_id="SA11AI.4427", @lng=nil, @prefix=nil, @memo_text=nil, @lat=nil, @employer=nil, @pac_name="Wendt Family Trust", @amount=100000.0, @increased_limit=nil, @transaction_description=nil, @donor_state=nil, @date="2011-12-31", @filing_id=764828, @system_code=nil, @first_name=nil, @address_one="1 Muir Loop", @transaction_type=nil, @conduit_city=nil, @linenumber="SA11AI", @full_name=nil, @address_two=nil, @conduit_address_two=nil>, ...]
|
197
|
+
|
198
|
+
IndividualContribution.candidate("P80003338") # Barack Obama
|
199
|
+
IndividualContribution.filing(762683) # Obama for America's 2011 year-end filing
|
200
|
+
|
201
|
+
If you're just interested in grabbing the contributions from a certain filing or date-range, but don't know that filing ID, get it via <tt>Committee#filings</tt>. Here's how to find the 2011 year-end filing ID for Restore Our Future, which you can then pass to IndividualContributions.
|
202
|
+
|
203
|
+
Committee.find("C00490045", 2012).filings.select do |q|
|
204
|
+
q.date_coverage_to == "2011-12-31".to_date && q.report_title == "YEAR-END"
|
205
|
+
end
|
206
|
+
|
207
|
+
== Electioneering Communications
|
208
|
+
|
209
|
+
Electioneering Communications are broadcast ads funded by third party groups that mention one or more candidates, but don't specifically support or oppose one. <tt>ElectioneeringCommunication</tt> objects are available newest first, or by committee ID or date (all in groups of 20). Within each object is an array of <tt>electioneering_communication_candidates</tt> mentioned in the ad.
|
210
|
+
|
211
|
+
ElectioneeringCommunication.latest
|
212
|
+
#=> [#<CampaignCash::ElectioneeringCommunication:0x10370a180 @payee_suffix=nil, @cycle=2012, @communication_date="2012-02-06", @committee_name="Crossroads Grassroots Policy Strategies", @purpose="TV/Media Production (Every Level)", @payee_address_2=nil, @electioneering_communication_candidates=[{"candidate_state"=>"HI", "electioneering_communication_id"=>847, "filing_id"=>764901, "transaction_id"=>"C.", "amended_from"=>nil, "back_reference_tran_id_number"=>"E.1", "candidate_name"=>"OBAMA, BARACK", "fec_candidate_id"=>"P80003338", "candidate_district"=>nil}], @back_reference_tran_id_number=nil, @unique_id="1116aadc5d5b7c793f0d0adfebb503709da1029f", @payee_middle_name=nil, @amended_from=nil, @back_reference_sched_name=nil, @payee_organization="Upgrade Films", @payee_state="DC", @transaction_id="E.1", @election_code="P2012", @payee_city="Washington", @payee_address_1="3299 K Street NW, Ste 200", @amount=65, @entity_type="ORG", @payee_first_name=nil, @filing_id=764901, @filed_date="2012-02-07", @payee_last_name=nil, @fec_committee_id="C30001655", @expenditure_date="2012-01-30", @payee_zip="20007">, ...]
|
213
|
+
|
214
|
+
ElectioneeringCommunication.committee("C30001655") # Crossroads GPS
|
215
|
+
ElectioneeringCommunication.date("02/06/2012") # EC's from February 6, 2012
|
216
|
+
|
217
|
+
|
191
218
|
== Note on Patches/Pull Requests
|
192
219
|
|
193
220
|
* Fork the project.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module CampaignCash
|
2
|
+
class ElectioneeringCommunication < Base
|
3
|
+
attr_reader :payee_zip, :committee_name, :entity_type, :filing_id, :payee_organization, :electioneering_communication_candidates, :amount, :fec_committee_id, :payee_city, :transaction_id, :amended_from, :communication_date, :payee_first_name, :payee_state, :back_reference_tran_id_number, :expenditure_date, :cycle, :payee_address_1, :back_reference_sched_name, :payee_address_2, :payee_last_name, :election_code, :payee_middle_name, :payee_suffix, :purpose, :unique_id, :filed_date
|
4
|
+
|
5
|
+
def initialize(params={})
|
6
|
+
params.each_pair do |k,v|
|
7
|
+
instance_variable_set("@#{k}", v)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(params={})
|
12
|
+
self.new(params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.latest(offset = nil)
|
16
|
+
cycle = CURRENT_CYCLE
|
17
|
+
results = invoke("#{cycle}/electioneering_communications", {:offset => offset})['results']
|
18
|
+
results.map {|obj| ElectioneeringCommunication.create(obj["electioneering_communication"])}
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.committee(committee_id, offset = nil)
|
22
|
+
cycle = CURRENT_CYCLE
|
23
|
+
results = invoke("#{cycle}/committees/#{committee_id}/electioneering_communications", {:offset => offset})['results']
|
24
|
+
results.map {|obj| ElectioneeringCommunication.create(obj["electioneering_communication"])}
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.date(date, offset = nil)
|
28
|
+
cycle = CURRENT_CYCLE
|
29
|
+
d = Date.strptime(date, '%m/%d/%Y')
|
30
|
+
results = invoke("#{cycle}/electioneering_communications/#{d.year}/#{d.month}/#{d.day}", {:offset => offset})['results']
|
31
|
+
results.map {|obj| ElectioneeringCommunication.create(obj["electioneering_communication"])}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CampaignCash
|
2
2
|
class FilingSummary < Base
|
3
3
|
|
4
|
-
attr_reader :pac_contributions_period, :
|
4
|
+
attr_reader :pac_contributions_period, :contributions_2500, :party_contributions_cycle, :fundraising_offsets_period, :primary_general, :pac_refunds_cycle, :party_refunds_cycle, :fundraising_expenses_period, :net_party_contributions, :num_contributions_200_499, :individual_refunds_cycle, :candidate_contributions_period, :legal_offsets_cycle, :num_contributions_500_1499, :net_operating_expenses, :total_debts_owed, :refunds_200_499, :refunds_1500_2499, :transfers_out_period, :net_primary, :liquidate_period, :contributions_200_499, :operating_offsets_cycle, :num_contributions_1500_2499, :candidate_loan_repayments_period, :committee_uri, :federal_funds_cycle, :net_candidate_contributions, :candidate_loans_period, :filing_id, :net_pac_contributions, :num_refunds_200_499, :candidate_loan_repayments_cycle, :total_offsets_cycle, :party_contributions_period, :net_individual_contributions, :num_refunds_1500_2499, :net_general, :total_receipts_cycle, :federal_funds_period, :transfers_out_cycle, :cycle, :other_loan_repayments_period, :contributions_500_1499, :legal_offsets_period, :date_coverage_from, :contributions_less_than_200, :fec_form_type, :candidate_contributions_cycle, :cash_on_hand_beginning, :individual_refunds_period, :fundraising_expenses_cycle, :num_refunds_500_1499, :cash_on_hand_close, :num_contributions_less_than_200, :total_loans_cycle, :candidate_uri, :contributions_1500_2499, :refunds_2500, :flag_most_current_report, :total_loan_repayments_period, :other_loans_period, :operating_expenditures_cycle, :other_disbursements_period, :total_loans_period, :transfers_in_period, :transfers_in_cycle, :report, :legal_expenses_period, :candidate_loans_cycle, :individual_contributions_period, :other_disbursements_cycle, :total_disbursements_period, :other_loans_cycle, :net_transfers_in, :net_disbursements, :operating_expenditures_period, :fundraising_offsets_cycle, :date_coverage_to, :total_loan_repayments_cycle, :total_disbursements_cycle, :party_refunds_period, :individual_contributions_cycle, :net_total_contributions, :other_loan_repayments_cycle, :total_refunds_cycle, :total_receipts_period, :total_offsets_period, :total_contributions_period, :total_contributions_cycle, :refunds_500_1499, :pac_refunds_period, :flag_valid_report, :legal_expenses_cycle, :num_refunds_less_than_200, :refunds_less_than_200, :pac_contributions_cycle, :net_legal_expenses, :net_fundraising_expenses, :num_contributions_2500, :total_refunds_period, :operating_offsets_period, :num_refunds_2500
|
5
5
|
|
6
6
|
def initialize(params={})
|
7
7
|
params.each_pair do |k,v|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CampaignCash
|
2
2
|
class IndependentExpenditure < Base
|
3
3
|
|
4
|
-
attr_reader :committee, :district, :state, :committee_name, :purpose, :candidate, :candidate_name, :support_or_oppose, :date, :amount, :office, :amendment, :date_received, :payee, :fec_uri, :transaction_id
|
4
|
+
attr_reader :committee, :district, :state, :committee_name, :purpose, :candidate, :candidate_name, :support_or_oppose, :date, :amount, :office, :amendment, :date_received, :payee, :fec_uri, :transaction_id, :unique_id
|
5
5
|
|
6
6
|
def initialize(params={})
|
7
7
|
params.each_pair do |k,v|
|
@@ -26,8 +26,12 @@ module CampaignCash
|
|
26
26
|
:amendment => params['amendment'],
|
27
27
|
:transaction_id => params['transaction_id'],
|
28
28
|
:candidate_name => params['candidate_name'],
|
29
|
-
|
30
|
-
:
|
29
|
+
:filing_id => params['filing_id'],
|
30
|
+
:amended_from => params['amended_from'], # <= original filing ID will be nil if amendment is false
|
31
|
+
# unique_id is a SHA1 of filing_id and transaction_id
|
32
|
+
# If the expenditure is amended, the unique_id will be amended_from + transaction_id
|
33
|
+
# so it can be used as an overrideable unique key
|
34
|
+
:unique_id => params['unique_id']
|
31
35
|
end
|
32
36
|
|
33
37
|
def self.latest(offset=nil)
|
data/lib/campaign_cash.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
%w(base candidate committee contribution individual_contribution filing filing_summary form independent_expenditure president).each do |f|
|
1
|
+
%w(base candidate committee contribution individual_contribution filing filing_summary form independent_expenditure president electioneering_communication).each do |f|
|
2
2
|
require File.join(File.dirname(__FILE__), '../lib/campaign_cash', f)
|
3
3
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestCampaignCash::TestElectioneeringCommunication < Test::Unit::TestCase
|
4
|
+
include CampaignCash
|
5
|
+
|
6
|
+
context "get electioneering communications" do
|
7
|
+
objs_collection = []
|
8
|
+
objs_collection << ElectioneeringCommunication.latest
|
9
|
+
objs_collection << ElectioneeringCommunication.committee("C30001655")
|
10
|
+
objs_collection << ElectioneeringCommunication.date("02/06/2012")
|
11
|
+
|
12
|
+
objs_collection.each do |objs|
|
13
|
+
should "return a list of objects of the ElectioneeringCommunication type or an empty list" do
|
14
|
+
if objs.size > 0
|
15
|
+
assert_kind_of(ElectioneeringCommunication, objs.first)
|
16
|
+
else
|
17
|
+
assert_equal([], objs)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -4,7 +4,7 @@ require 'shoulda'
|
|
4
4
|
require 'json'
|
5
5
|
require 'ostruct'
|
6
6
|
|
7
|
-
%w(base candidate committee contribution individual_contribution filing filing_summary form independent_expenditure president).each do |f|
|
7
|
+
%w(base candidate committee contribution individual_contribution filing filing_summary form independent_expenditure president electioneering_communication).each do |f|
|
8
8
|
require File.join(File.dirname(__FILE__), '../lib/campaign_cash', f)
|
9
9
|
end
|
10
10
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campaign_cash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Derek Willis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-15 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/campaign_cash/candidate.rb
|
101
101
|
- lib/campaign_cash/committee.rb
|
102
102
|
- lib/campaign_cash/contribution.rb
|
103
|
+
- lib/campaign_cash/electioneering_communication.rb
|
103
104
|
- lib/campaign_cash/filing.rb
|
104
105
|
- lib/campaign_cash/filing_summary.rb
|
105
106
|
- lib/campaign_cash/form.rb
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- lib/campaign_cash/version.rb
|
110
111
|
- test/campaign_cash/test_candidate.rb
|
111
112
|
- test/campaign_cash/test_committee.rb
|
113
|
+
- test/campaign_cash/test_electioneering_communication.rb
|
112
114
|
- test/campaign_cash/test_filing.rb
|
113
115
|
- test/campaign_cash/test_filing_summary.rb
|
114
116
|
- test/campaign_cash/test_form.rb
|
@@ -155,6 +157,7 @@ summary: Following the money.
|
|
155
157
|
test_files:
|
156
158
|
- test/campaign_cash/test_candidate.rb
|
157
159
|
- test/campaign_cash/test_committee.rb
|
160
|
+
- test/campaign_cash/test_electioneering_communication.rb
|
158
161
|
- test/campaign_cash/test_filing.rb
|
159
162
|
- test/campaign_cash/test_filing_summary.rb
|
160
163
|
- test/campaign_cash/test_form.rb
|