Skip to content

Commit

Permalink
Removed necessity of setting OpenCongress API Key
Browse files Browse the repository at this point in the history
  • Loading branch information
NateBarnes committed Jun 30, 2011
1 parent bd8f786 commit 7d0f5e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
14 changes: 9 additions & 5 deletions lib/gov_kit/configuration.rb
Expand Up @@ -25,10 +25,19 @@ def initialize
# Permant home for contribution category mappings
@transparency_data_categories_url = 'http://assets.transparencydata.org.s3.amazonaws.com/docs/catcodes.csv'
end

def opencongress_apikey= key
warn "[DEPRECATION] OpenCongress no longer requires an API Key. Ability to set it will be removed in future versions"
@opencongress_apikey = key
end
end

class << self
attr_accessor :configuration

def self.initalize
self.configuration = Configuration.new
end
end

# Configure GovKit in config/initializers/govkit.rb
Expand All @@ -41,9 +50,4 @@ def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end

def opencongress_apikey= key
warn "[DEPRECATION] OpenCongress no longer requires an API Key. Ability to set it will be removed in future versions"
@opencongress_apikey = key
end
end
19 changes: 8 additions & 11 deletions lib/gov_kit/open_congress.rb
Expand Up @@ -4,13 +4,13 @@
require 'CGI'

module GovKit::OpenCongress
autoload :Bill, 'gov_kit/open_congress/bill'
autoload :BlogPost, 'gov_kit/open_congress/blog_post'
autoload :NewsPost, 'gov_kit/open_congress/news_post'
autoload :VotingComparison, 'gov_kit/open_congress/voting_comparison'
autoload :Bill, 'gov_kit/open_congress/bill'
autoload :BlogPost, 'gov_kit/open_congress/blog_post'
autoload :NewsPost, 'gov_kit/open_congress/news_post'
autoload :VotingComparison, 'gov_kit/open_congress/voting_comparison'
autoload :RollCallComparison, 'gov_kit/open_congress/roll_call_comparison'
autoload :Person, 'gov_kit/open_congress/person'
autoload :PersonStat, 'gov_kit/open_congress/person_stat'
autoload :Person, 'gov_kit/open_congress/person'
autoload :PersonStat, 'gov_kit/open_congress/person_stat'

class OpenCongressObject

Expand All @@ -23,11 +23,8 @@ def initialize(obj, params)

def self.construct_url(api_method, params)
url = nil
if GovKit::configuration.opencongress_apikey == nil || GovKit::configuration.opencongress_apikey == ''
raise "Failed to provide OpenCongress API Key"
else
url = "http://#{GovKit::configuration.opencongress_base_url}api/#{api_method}?key=#{GovKit::configuration.opencongress_apikey}#{hash2get(params)}&format=json"
end
getkey = GovKit::configuration.opencongress_apikey.nil? ? GovKit::configuration.opencongress_apikey = "" : "&key=#{GovKit::configuration.opencongress_apikey}"
url = "http://#{GovKit::configuration.opencongress_base_url}api/#{api_method}?format=json#{hash2get(params)}#{getkey}"
return url
end

Expand Down

0 comments on commit 7d0f5e1

Please sign in to comment.