Class: OpenSecretsApi
- Inherits:
-
GenericApi
- Object
- GenericApi
- OpenSecretsApi
- Includes:
- HTTParty
- Defined in:
- lib/apis/open_secrets_api.rb
Instance Method Summary collapse
- #get_cand_info(method_name, crpID, cycle) ⇒ Object
- #get_cand_pfd_assets(crpID, cycle = "") ⇒ Object
- #get_cand_pfd_positions_held(crpID, cycle = "") ⇒ Object
- #get_cand_pfd_transactions(crpID, cycle = "") ⇒ Object
- #get_cand_summary_for_crpID(crpID, cycle = "") ⇒ Object
- #key=(key) ⇒ Object
Methods inherited from GenericApi
Instance Method Details
#get_cand_info(method_name, crpID, cycle) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/apis/open_secrets_api.rb', line 36 def get_cand_info(method_name, crpID, cycle) query_hash = {:method => method_name} begin result = OpenSecretsApi.get("", :query => query_hash.merge({:cid => crpID, :cycle => cycle})) rescue Net::HTTPServerException => exception puts "EXCEPTION: from Opensecrets! #{method_name}: #{exception.response.body}" return nil end end |
#get_cand_pfd_assets(crpID, cycle = "") ⇒ Object
51 52 53 54 |
# File 'lib/apis/open_secrets_api.rb', line 51 def get_cand_pfd_assets(crpID, cycle = "") result = get_cand_info("memPFDprofile", crpID, cycle) result["response"]["member_profile"]["assets"]["asset"] end |
#get_cand_pfd_positions_held(crpID, cycle = "") ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/apis/open_secrets_api.rb', line 61 def get_cand_pfd_positions_held(crpID, cycle = "") result = get_cand_info("memPFDprofile", crpID, cycle) result = result["response"]["member_profile"] if result.has_key?("positions") result["positions"]["position"] else nil end end |
#get_cand_pfd_transactions(crpID, cycle = "") ⇒ Object
56 57 58 59 |
# File 'lib/apis/open_secrets_api.rb', line 56 def get_cand_pfd_transactions(crpID, cycle = "") result = get_cand_info("memPFDprofile", crpID, cycle) result["response"]["member_profile"]["transactions"]["transaction"] end |
#get_cand_summary_for_crpID(crpID, cycle = "") ⇒ Object
46 47 48 49 |
# File 'lib/apis/open_secrets_api.rb', line 46 def get_cand_summary_for_crpID(crpID, cycle = "") result = get_cand_info("candSummary", crpID, cycle) result["response"]["summary"] end |
#key=(key) ⇒ Object
31 32 33 34 |
# File 'lib/apis/open_secrets_api.rb', line 31 def key=(key) @api_key = key OpenSecretsApi.default_params :apikey => key end |