Class: Congress::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/congress/client.rb

Constant Summary

Constants included from Connection

Congress::Connection::ENDPOINT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Request

#get

Constructor Details

#initialize(key) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/congress/client.rb', line 11

def initialize(key)
  fail ArgumentError, 'API key required' if key.nil?
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/congress/client.rb', line 9

def key
  @key
end

Instance Method Details

#bills(options = {}) ⇒ Hashie::Rash

Legislation in the House and Senate, back to 2009. Updated daily.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.bills

Returns:



66
67
68
# File 'lib/congress/client.rb', line 66

def bills(options = {})
  get('/bills', options)
end

#bills_search(options = {}) ⇒ Hashie::Rash

ull text search over legislation.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.bills_search

Returns:



76
77
78
# File 'lib/congress/client.rb', line 76

def bills_search(options = {})
  get('/bills/search', options)
end

#committees(options = {}) ⇒ Hashie::Rash

Current committees, subcommittees, and their membership.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.committees

Returns:



56
57
58
# File 'lib/congress/client.rb', line 56

def committees(options = {})
  get('/committees', options)
end

#districts_locate(*args) ⇒ Hashie::Rash

Find congressional districts for a latitude/longitude, zip, or address.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.districts_locate(94107)
Congress.districts_locate(37.775, -122.418)
Congress.districts_locate('2169 Mission Street, San Francisco, CA 94110')

Returns:



46
47
48
# File 'lib/congress/client.rb', line 46

def districts_locate(*args)
  get('/districts/locate', extract_location(args))
end

#floor_updates(options = {}) ⇒ Hashie::Rash

To-the-minute updates from the floor of the House and Senate.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.floor_updates

Returns:



96
97
98
# File 'lib/congress/client.rb', line 96

def floor_updates(options = {})
  get('/floor_updates', options)
end

#hearings(options = {}) ⇒ Hashie::Rash

Committee hearings in Congress. Updated as hearings are announced.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.hearings

Returns:



106
107
108
# File 'lib/congress/client.rb', line 106

def hearings(options = {})
  get('/hearings', options)
end

#legislators(options = {}) ⇒ Hashie::Rash

Current legislators' names, IDs, biography, and social media.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.legislators

Returns:



22
23
24
# File 'lib/congress/client.rb', line 22

def legislators(options = {})
  get('/legislators', options)
end

#legislators_locate(*args) ⇒ Hashie::Rash

Find representatives and senators for a latitude/longitude, zip, or address.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.legislators_locate(94107)
Congress.legislators_locate(37.775, -122.418)
Congress.legislators_locate('2169 Mission Street, San Francisco, CA 94110')

Returns:



34
35
36
# File 'lib/congress/client.rb', line 34

def legislators_locate(*args)
  get('/legislators/locate', extract_location(args))
end

#upcoming_bills(options = {}) ⇒ Hashie::Rash

Bills scheduled for debate in the future, as announced by party leadership.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.upcoming_bills

Returns:



116
117
118
# File 'lib/congress/client.rb', line 116

def upcoming_bills(options = {})
  get('/upcoming_bills', options)
end

#votes(options = {}) ⇒ Hashie::Rash

Roll call votes in Congress, back to 2009. Updated within minutes of votes.

Examples:

Congress.key = YOUR_SUNLIGHT_API_KEY
Congress.votes

Returns:



86
87
88
# File 'lib/congress/client.rb', line 86

def votes(options = {})
  get('/votes', options)
end