0.0
No commit activity in last 3 years
No release in over 3 years
A simple API wrapper for Ed-Fi ODS access.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 0.11
~> 10.0
~> 3.0

Runtime

~> 0.1
 Project Readme

EdFi::Client Gem Version

A utility class for authenticating to and making CRUD calls against an Ed-Fi ODS API.

Installation

Add this line to your application's Gemfile:

gem 'ed_fi_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ed_fi_client

Using EdFi::Client

Basic Usage: Reading Data

## Establish a connection to an Ed-Fi ODS / API.
## (We'll use the Alliance-hosted Ed-Fi ODS / API sandbox instance.)

sandbox = EdFi::Client.new(
  'https://api.ed-fi.org/api/',
  client_id: 'RvcohKz9zHI4',
  client_secret: 'E1iEFusaNf81xzCxwHfbolkC'
)

sandbox = sandbox.v2(2017)  ## For purposes of these samples, we're only
                            ## concerned with 2017-2018 school-year data.


## Let's pull some assorted values!

sandbox.get('schools', query: { school_id: 255901001 })  ## Get school 255901001.

sandbox.get('disciplineIncidents')  ## Get all discipline incidents.
sandbox.get('disciplineIncidents').sample.school  ## A random incident's school.

all_schools = sandbox.get('schools')  ## All schools.
all_schools.sample.name_of_institution  ## A random school's name.
all_schools.map { |i| [i.id, i.school_id] }.to_h  ## Maps ODS IDs to school IDs.

Basic Usage: Writing Data

sandbox = EdFi::Client.new(
  'https://api.ed-fi.org/api/',
  client_id: 'RvcohKz9zHI4',
  client_secret: 'E1iEFusaNf81xzCxwHfbolkC'
).v2(2017)

school = sandbox.get('schools').sample
original_name = school.name_of_institution  ## So we can leave it like we found it.


## Via PUT ...

school.name_of_institution = 'New Name, via PUT'
sandbox.put("schools/#{school.id}", payload: school)
sandbox.get("schools/#{school.id}").name_of_institution  ## => "New Name, via PUT"


## Via POST ...

school.name_of_institution = 'New Name, via POST'
sandbox.post("schools", payload: school.except(:id))
sandbox.get("schools/#{school.id}").name_of_institution  ## => "New Name, via POST"


## Let's leave things like we found them.

school.name_of_institution = original_name
sandbox.put("schools/#{school.id}", payload: school)

Consult the repo docs for the full EdFi::Client documentation.

Feature Roadmap / Future Development

Additional features/options coming in the future:

  • Cleaner handling of non-body-returning calls.
  • Use the given base endpoint's Swagger API definition file (if present) to make collections/resources more easily reachable: #schools, #discipline_incidents, etc.
  • Allow for easier manipulation of resources via AR-like methods (#find, #find_by, #where, #create, #update, etc).

Contribution / Development

Bug reports and pull requests are welcome on GitHub at https://github.com/nestor-custodio/ed_fi_client.

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Linting is courtesy of Rubocop and documentation is built using Yard. Neither is included in the Gemspec; you'll need to install these locally (gem install rubocop yard) to take advantage.

License

The gem is available as open source under the terms of the MIT License.