Class: OpenCivicData::Client
- Inherits:
-
Object
- Object
- OpenCivicData::Client
- Includes:
- Connection, Request
- Defined in:
- lib/open_civic_data/client.rb
Constant Summary collapse
- @@key_required =
rubocop:disable ClassVars
true- @@endpoint =
rubocop:disable ClassVars
'http://api.opencivicdata.org'
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
- .endpoint ⇒ Object
- .endpoint=(endpoint) ⇒ Object
-
.key_required ⇒ Boolean
Check if key is required.
-
.key_required=(bool) ⇒ Object
Disable ArgumentError if no api key is provided.
Instance Method Summary collapse
-
#bills(options = {}) ⇒ Hashie::Rash
Fetches legislative documents and their history.
-
#divisions(options = {}) ⇒ Hashie::Rash
Fetches political geographies such as a state, county or congressional district.
-
#events(options = {}) ⇒ Hashie::Rash
Fetches legislative event, such as a meeting or hearing.
-
#initialize(key) ⇒ Client
constructor
A new instance of Client.
-
#jurisdictions(options = {}) ⇒ Hashie::Rash
Fetches governing bodies that exist within a division.
-
#organizations(options = {}) ⇒ Hashie::Rash
Fetches groups of people, such as a city council, state senate or committee.
-
#people(options = {}) ⇒ Hashie::Rash
Fetches people, typically politicians or gov officials.
-
#votes(options = {}) ⇒ Hashie::Rash
Fetches the record of vote taken on motions.
Methods included from Request
Constructor Details
#initialize(key) ⇒ Client
Returns a new instance of Client.
14 15 16 17 |
# File 'lib/open_civic_data/client.rb', line 14 def initialize(key) fail ArgumentError, 'API key required' if key.nil? && @@key_required @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/open_civic_data/client.rb', line 9 def key @key end |
Class Method Details
.endpoint ⇒ Object
114 115 116 |
# File 'lib/open_civic_data/client.rb', line 114 def endpoint @@endpoint end |
.endpoint=(endpoint) ⇒ Object
110 111 112 |
# File 'lib/open_civic_data/client.rb', line 110 def endpoint=(endpoint) @@endpoint = endpoint end |
.key_required ⇒ Boolean
Check if key is required.
106 107 108 |
# File 'lib/open_civic_data/client.rb', line 106 def key_required @@key_required end |
.key_required=(bool) ⇒ Object
Disable ArgumentError if no api key is provided. Useful for using different endpoints.
96 97 98 |
# File 'lib/open_civic_data/client.rb', line 96 def key_required=(bool) @@key_required = bool # rubocop:disable ClassVars end |
Instance Method Details
#bills(options = {}) ⇒ Hashie::Rash
Fetches legislative documents and their history
75 76 77 |
# File 'lib/open_civic_data/client.rb', line 75 def bills( = {}) get('/bills/', ) end |
#divisions(options = {}) ⇒ Hashie::Rash
Fetches political geographies such as a state, county or congressional district
35 36 37 |
# File 'lib/open_civic_data/client.rb', line 35 def divisions( = {}) get('/divisions/', ) end |
#events(options = {}) ⇒ Hashie::Rash
Fetches legislative event, such as a meeting or hearing
65 66 67 |
# File 'lib/open_civic_data/client.rb', line 65 def events( = {}) get('/events/', ) end |
#jurisdictions(options = {}) ⇒ Hashie::Rash
Fetches governing bodies that exist within a division
25 26 27 |
# File 'lib/open_civic_data/client.rb', line 25 def jurisdictions( = {}) get('/jurisdictions/', ) end |
#organizations(options = {}) ⇒ Hashie::Rash
Fetches groups of people, such as a city council, state senate or committee
55 56 57 |
# File 'lib/open_civic_data/client.rb', line 55 def organizations( = {}) get('/organizations/', ) end |
#people(options = {}) ⇒ Hashie::Rash
Fetches people, typically politicians or gov officials
45 46 47 |
# File 'lib/open_civic_data/client.rb', line 45 def people( = {}) get('/people/', ) end |
#votes(options = {}) ⇒ Hashie::Rash
Fetches the record of vote taken on motions
85 86 87 |
# File 'lib/open_civic_data/client.rb', line 85 def votes( = {}) get('/votes/', ) end |