Class: GovKit::OpenStatesResource
- Defined in:
- lib/gov_kit/open_states.rb
Overview
Parent class for OpenStates resources See openstates.sunlightlabs.com/api/
Direct Known Subclasses
GovKit::OpenStates::Action, GovKit::OpenStates::Address, GovKit::OpenStates::Bill, GovKit::OpenStates::Committee, GovKit::OpenStates::Legislator, GovKit::OpenStates::Role, GovKit::OpenStates::Source, GovKit::OpenStates::Sponsor, GovKit::OpenStates::State, GovKit::OpenStates::Version, GovKit::OpenStates::Vote
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.get_uri(uri, options = {}) ⇒ Object
Do a GET query, with optional parameters.
Methods inherited from Resource
#initialize, instantiate, instantiate_collection, parse, #to_md5, #unload
Constructor Details
This class inherits a constructor from GovKit::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GovKit::Resource
Class Method Details
.get_uri(uri, options = {}) ⇒ Object
Do a GET query, with optional parameters.
OpenStates returns a 404 error when a query returns nothing.
So, if a query result is a resource not found error, we return an empty set.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gov_kit/open_states.rb', line 15 def self.get_uri(uri, ={}) [:query] ||= {} [:query][:apikey] = GovKit::configuration.sunlight_apikey begin parse(get(URI.encode(uri), )) rescue ResourceNotFound [] end end |