class OpenSecrets::Base
Public Class Methods
new(apikey = nil)
click to toggle source
OpenSecrets
Base
constructor. All OpenSecrets
API classes inherit from this one which provides the common initialization function. For convenience you can skip providing an ‘apikey’ to the constructor if you instead export a OPENSECRETS_API_KEY environment variable which is set to the value of your API key.
@option options [String] apikey (nil) an OpenSecrets
API Key, this can also be provided in an OPENSECRETS_API_KEY shell environment variable for security and convenience.
# File lib/opensecrets.rb, line 19 def initialize(apikey = nil) key = apikey ||= ENV['OPENSECRETS_API_KEY'] raise ArgumentError, 'You must provide an API Key' if key.nil? || key.empty? self.class.default_params :apikey => key end