Class: OpenCivicData::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/open_civic_data/client.rb

Constant Summary

Constants included from Connection

OpenCivicData::Connection::ENDPOINT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Request

#get

Constructor Details

#initialize(key) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/open_civic_data/client.rb', line 11

def initialize(key)
  fail ArgumentError, 'API key required' if key.nil?
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/open_civic_data/client.rb', line 9

def key
  @key
end

Instance Method Details

#bills(options = {}) ⇒ Hashie::Rash

Fetches legislative documents and their history

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.bills

Returns:

  • (Hashie::Rash)

    Bill's type, legislative body, session, name, chamber, title, type, subject and summary.



72
73
74
# File 'lib/open_civic_data/client.rb', line 72

def bills(options = {})
  get('/bills/', options)
end

#divisions(options = {}) ⇒ Hashie::Rash

Fetches political geographies such as a state, county or congressional district

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.divisions

Returns:

  • (Hashie::Rash)

    Division's geometries and list of child jurisdiction ids.



32
33
34
# File 'lib/open_civic_data/client.rb', line 32

def divisions(options = {})
  get('/divisions/', options)
end

#events(options = {}) ⇒ Hashie::Rash

Fetches legislative event, such as a meeting or hearing

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.events

Returns:

  • (Hashie::Rash)

    Event's type, name, description, when, end, status, location, and linked entities.



62
63
64
# File 'lib/open_civic_data/client.rb', line 62

def events(options = {})
  get('/events/', options)
end

#jurisdictions(options = {}) ⇒ Hashie::Rash

Fetches governing bodies that exist within a division

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.jurisdictions

Returns:

  • (Hashie::Rash)

    Jurisdiction's name, url, chambers, terms, and session details.



22
23
24
# File 'lib/open_civic_data/client.rb', line 22

def jurisdictions(options = {})
  get('/jurisdictions/', options)
end

#organizations(options = {}) ⇒ Hashie::Rash

Fetches groups of people, such as a city council, state senate or committee

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.organizations

Returns:

  • (Hashie::Rash)

    Organization's name, classification, parent id, contact details, links and posts.



52
53
54
# File 'lib/open_civic_data/client.rb', line 52

def organizations(options = {})
  get('/organizations/', options)
end

#people(options = {}) ⇒ Hashie::Rash

Fetches people, typically politicians or gov officials

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.people

Returns:

  • (Hashie::Rash)

    Person's name, image, contact details, and links.



42
43
44
# File 'lib/open_civic_data/client.rb', line 42

def people(options = {})
  get('/people/', options)
end

#votes(options = {}) ⇒ Hashie::Rash

Fetches the record of vote taken on motions

Examples:

OpenCivicData.key = YOUR_SUNLIGHT_API_KEY
OpenCivicData.votes

Returns:

  • (Hashie::Rash)

    Vote's organization, session, chamber, date, motion, type and passed or not.



82
83
84
# File 'lib/open_civic_data/client.rb', line 82

def votes(options = {})
  get('/votes/', options)
end