Skip to content

Commit

Permalink
OpenStates API updates:
Browse files Browse the repository at this point in the history
- new URL format (/api/v1)
- add committee support -- OpenStates::Committee.find/search
  • Loading branch information
tashian committed Sep 10, 2010
1 parent 7700310 commit 29f0dc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/gov_kit/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Configuration

def initialize
@openstates_apikey = @votesmart_apikey = @ftm_apikey = ''
@openstates_base_url = 'fiftystates-dev.sunlightlabs.com/api'
@openstates_base_url = 'openstates.sunlightlabs.com/api/v1/'
@votesmart_base_url = 'api.votesmart.org/'
@ftm_base_url = 'api.followthemoney.org/'
@opencongress_base_url = 'www.opencongress.org/'
Expand Down
21 changes: 17 additions & 4 deletions lib/gov_kit/open_states.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ module OpenStates

class State < OpenStatesResource
def self.find_by_abbreviation(abbreviation)
response = get("/#{abbreviation}/")
response = get("/metadata/#{abbreviation}/")
instantiate_record(response)
end
end

class Bill < OpenStatesResource
# http://fiftystates-dev.sunlightlabs.com/api/ca/20092010/lower/bills/AB667/
# http://openstates.sunlightlabs.com/api/v1/ca/20092010/lower/bills/AB667/
def self.find(state_abbrev, session, chamber, bill_id)
response = get("/#{state_abbrev}/#{session}/#{chamber}/bills/#{bill_id}/")
instantiate_record(response)
end

def self.search(query, options = {})
response = get('/bills/search/', :query => {:q => query}.merge(options))
response = get('/bills/', :query => {:q => query}.merge(options))
instantiate_collection(response)
end

Expand All @@ -42,10 +42,23 @@ def self.find(legislator_id)
end

def self.search(options = {})
response = get('/legislators/search/', :query => options)
response = get('/legislators/', :query => options)
instantiate_collection(response)
end
end

class Committee < OpenStatesResource
def self.find(committee_id)
response = get("/committees/#{committee_id}/")
instantiate_record(response)
end

def self.search(options = {})
response = get('/committees/', :query => options)
instantiate_collection(response)
end
end


class Role < OpenStatesResource; end

Expand Down

0 comments on commit 29f0dc0

Please sign in to comment.