Module: OpenStates::Api
- Included in:
- OpenStates
- Defined in:
- lib/openstates/api.rb
Instance Method Summary collapse
- #bills(options = {}) ⇒ Object
- #committees(options = {}) ⇒ Object
- #district_boundaries(boundary_id) ⇒ Object
- #districts(options = {}) ⇒ Object
- #events(options = {}) ⇒ Object
- #geo_legislators(lat, lon) ⇒ Object
- #legislators(options = {}) ⇒ Object
- #metadata(state = nil) ⇒ Object
Instance Method Details
#bills(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/openstates/api.rb', line 9 def bills( = {}) url = "bills/" if [:state] && [:session] && [:bill_id] url << "#{[:state]}/#{[:session]}/#{[:bill_id]}/" [:state, :session, :bill_id].each do |key| .delete(key) end end get(url, ) end |
#committees(options = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/openstates/api.rb', line 34 def committees( = {}) url = "committees/" url << "#{[:committee_id]}/" if [:committee_id] get(url, ) end |
#district_boundaries(boundary_id) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/openstates/api.rb', line 58 def district_boundaries(boundary_id) return if !boundary_id url = "districts/boundary/#{boundary_id}/" get(url) end |
#districts(options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/openstates/api.rb', line 48 def districts( = {}) return [] if ![:state] url = "districts/" url << "#{[:state]}/" url << "#{[:chamber]}/" if [:chamber] get(url, ) end |
#events(options = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/openstates/api.rb', line 41 def events( = {}) url = "events/" url << "#{[:event_id]}/" if [:event_id] get(url, ) end |
#geo_legislators(lat, lon) ⇒ Object
28 29 30 31 32 |
# File 'lib/openstates/api.rb', line 28 def geo_legislators(lat, lon) url = "legislators/geo/" get(url, {:lat => lat, :long => lon}) end |
#legislators(options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/openstates/api.rb', line 21 def legislators( = {}) url = "legislators/" url << "#{[:leg_id]}/" if [:leg_id] get(url, ) end |
#metadata(state = nil) ⇒ Object
3 4 5 6 7 |
# File 'lib/openstates/api.rb', line 3 def (state = nil) url = "metadata/" url << "#{state}/" if state get(url) end |