Class: Sunlight::Filing
Constant Summary
Constants inherited from Base
Base::API_FORMAT, Base::API_URL
Instance Attribute Summary collapse
-
#client_contact_firstname ⇒ Object
Returns the value of attribute client_contact_firstname.
-
#client_contact_lastname ⇒ Object
Returns the value of attribute client_contact_lastname.
-
#client_contact_middlename ⇒ Object
Returns the value of attribute client_contact_middlename.
-
#client_contact_suffix ⇒ Object
Returns the value of attribute client_contact_suffix.
-
#client_country ⇒ Object
Returns the value of attribute client_country.
-
#client_description ⇒ Object
Returns the value of attribute client_description.
-
#client_name ⇒ Object
Returns the value of attribute client_name.
-
#client_ppb_country ⇒ Object
Returns the value of attribute client_ppb_country.
-
#client_ppb_state ⇒ Object
Returns the value of attribute client_ppb_state.
-
#client_senate_id ⇒ Object
Returns the value of attribute client_senate_id.
-
#client_state ⇒ Object
Returns the value of attribute client_state.
-
#filing_amount ⇒ Object
Returns the value of attribute filing_amount.
-
#filing_date ⇒ Object
Returns the value of attribute filing_date.
-
#filing_id ⇒ Object
Returns the value of attribute filing_id.
-
#filing_pdf ⇒ Object
Returns the value of attribute filing_pdf.
-
#filing_period ⇒ Object
Returns the value of attribute filing_period.
-
#filing_type ⇒ Object
Returns the value of attribute filing_type.
-
#filing_year ⇒ Object
Returns the value of attribute filing_year.
-
#issues ⇒ Object
Returns the value of attribute issues.
-
#lobbyists ⇒ Object
Returns the value of attribute lobbyists.
-
#registrant_address ⇒ Object
Returns the value of attribute registrant_address.
-
#registrant_country ⇒ Object
Returns the value of attribute registrant_country.
-
#registrant_description ⇒ Object
Returns the value of attribute registrant_description.
-
#registrant_name ⇒ Object
Returns the value of attribute registrant_name.
-
#registrant_ppb_country ⇒ Object
Returns the value of attribute registrant_ppb_country.
-
#registrant_senate_id ⇒ Object
Returns the value of attribute registrant_senate_id.
Class Method Summary collapse
-
.all_where(params) ⇒ Object
Search the filing database.
-
.get(id) ⇒ Object
Get a filing based on filing ID.
Instance Method Summary collapse
-
#initialize(params) ⇒ Filing
constructor
Takes in a hash where the keys are strings (the format passed in by the JSON parser).
Methods inherited from Base
api_key, api_key=, construct_url, get_json_data, hash2get
Constructor Details
#initialize(params) ⇒ Filing
Takes in a hash where the keys are strings (the format passed in by the JSON parser)
16 17 18 19 20 |
# File 'lib/sunlight/filing.rb', line 16 def initialize(params) params.each do |key, value| instance_variable_set("@#{key}", value) if Filing.instance_methods.include? key end end |
Instance Attribute Details
#client_contact_firstname ⇒ Object
Returns the value of attribute client_contact_firstname.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_contact_firstname @client_contact_firstname end |
#client_contact_lastname ⇒ Object
Returns the value of attribute client_contact_lastname.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_contact_lastname @client_contact_lastname end |
#client_contact_middlename ⇒ Object
Returns the value of attribute client_contact_middlename.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_contact_middlename @client_contact_middlename end |
#client_contact_suffix ⇒ Object
Returns the value of attribute client_contact_suffix.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_contact_suffix @client_contact_suffix end |
#client_country ⇒ Object
Returns the value of attribute client_country.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_country @client_country end |
#client_description ⇒ Object
Returns the value of attribute client_description.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_description @client_description end |
#client_name ⇒ Object
Returns the value of attribute client_name.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_name @client_name end |
#client_ppb_country ⇒ Object
Returns the value of attribute client_ppb_country.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_ppb_country @client_ppb_country end |
#client_ppb_state ⇒ Object
Returns the value of attribute client_ppb_state.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_ppb_state @client_ppb_state end |
#client_senate_id ⇒ Object
Returns the value of attribute client_senate_id.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_senate_id @client_senate_id end |
#client_state ⇒ Object
Returns the value of attribute client_state.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def client_state @client_state end |
#filing_amount ⇒ Object
Returns the value of attribute filing_amount.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_amount @filing_amount end |
#filing_date ⇒ Object
Returns the value of attribute filing_date.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_date @filing_date end |
#filing_id ⇒ Object
Returns the value of attribute filing_id.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_id @filing_id end |
#filing_pdf ⇒ Object
Returns the value of attribute filing_pdf.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_pdf @filing_pdf end |
#filing_period ⇒ Object
Returns the value of attribute filing_period.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_period @filing_period end |
#filing_type ⇒ Object
Returns the value of attribute filing_type.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_type @filing_type end |
#filing_year ⇒ Object
Returns the value of attribute filing_year.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def filing_year @filing_year end |
#issues ⇒ Object
Returns the value of attribute issues.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def issues @issues end |
#lobbyists ⇒ Object
Returns the value of attribute lobbyists.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def lobbyists @lobbyists end |
#registrant_address ⇒ Object
Returns the value of attribute registrant_address.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def registrant_address @registrant_address end |
#registrant_country ⇒ Object
Returns the value of attribute registrant_country.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def registrant_country @registrant_country end |
#registrant_description ⇒ Object
Returns the value of attribute registrant_description.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def registrant_description @registrant_description end |
#registrant_name ⇒ Object
Returns the value of attribute registrant_name.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def registrant_name @registrant_name end |
#registrant_ppb_country ⇒ Object
Returns the value of attribute registrant_ppb_country.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def registrant_ppb_country @registrant_ppb_country end |
#registrant_senate_id ⇒ Object
Returns the value of attribute registrant_senate_id.
4 5 6 |
# File 'lib/sunlight/filing.rb', line 4 def registrant_senate_id @registrant_senate_id end |
Class Method Details
.all_where(params) ⇒ Object
Search the filing database. At least one of client_name or registrant_name must be provided, along with an optional year. Note that year is recommended, as the full data set dating back to 1999 may be enormous.
See the API documentation:
wiki.sunlightlabs.com/index.php/Lobbyists.getFilingList
Returns:
An array of Filing objects that match the conditions
Usage:
filings = Filing.all_where(:client_name => "SUNLIGHT FOUNDATION")
filings.each do |filing|
...
filing.issues.each { |issue| ... }
filing.lobbyists.each { |issue| ... }
end
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/sunlight/filing.rb', line 84 def self.all_where(params) if params[:client_name].nil? and params[:registrant_name].nil? nil else url = construct_url("lobbyists.getFilingList", params) if (response = get_json_data(url)) filings = [] response["response"]["filings"].each do |result| filing = Filing.new(result["filing"]) filing.lobbyists = filing.lobbyists.map do |lobbyist| Lobbyist.new(lobbyist["lobbyist"]) end filing.issues = filing.issues.map do |issue| Issue.new(issue["issue"]) end filings << filing end if filings.empty? nil else filings end else nil end end # if params end |
.get(id) ⇒ Object
Get a filing based on filing ID.
See the API documentation:
wiki.sunlightlabs.com/index.php/Lobbyists.getFiling
Returns:
A Filing and corresponding Lobbyists and Issues matching the given ID, or nil if one wasn’t found.
Usage:
filing = Sunlight::Filing.get("29D4D19E-CB7D-46D2-99F0-27FF15901A4C")
filing.issues.each { |issue| ... }
filing.lobbyists.each { |lobbyist| ... }
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sunlight/filing.rb', line 40 def self.get(id) url = construct_url("lobbyists.getFiling", :id => id) if (response = get_json_data(url)) if (f = response["response"]["filing"]) filing = Filing.new(f) filing.lobbyists = filing.lobbyists.map do |lobbyist| Lobbyist.new(lobbyist["lobbyist"]) end filing.issues = filing.issues.map do |issue| Issue.new(issue["issue"]) end filing else nil end else nil end end |