Module: OpenStates::Api

Included in:
OpenStates
Defined in:
lib/openstates/api.rb

Instance Method Summary collapse

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(options = {})
  url = "bills/"
  if options[:state] && options[:session] && options[:bill_id]
    url << "#{options[:state]}/#{options[:session]}/#{options[:bill_id]}/"
    [:state, :session, :bill_id].each do |key|
      options.delete(key)
    end
  end

  get(url, options)
end

#committees(options = {}) ⇒ Object



34
35
36
37
38
39
# File 'lib/openstates/api.rb', line 34

def committees(options = {})
  url = "committees/"
  url << "#{options[:committee_id]}/" if options[:committee_id]

  get(url, options)
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(options = {})
  return [] if !options[:state]

  url = "districts/"
  url << "#{options[:state]}/"
  url << "#{options[:chamber]}/" if options[:chamber]

  get(url, options)
end

#events(options = {}) ⇒ Object



41
42
43
44
45
46
# File 'lib/openstates/api.rb', line 41

def events(options = {})
  url = "events/"
  url << "#{options[:event_id]}/" if options[:event_id]

  get(url, options)
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(options = {})
  url = "legislators/"
  url << "#{options[:leg_id]}/" if options[:leg_id]

  get(url, options)
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