0.0
No commit activity in last 3 years
No release in over 3 years
Ruby Gem wrapper for the University of Waterloo Open Data API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

uwaterlooapi

Build Status Code Climate Test Coverage

RubyGem wrapper for the University of Waterloo OpenData API

Installation

Add this line to your application's Gemfile:

gem 'uwaterlooapi'

And then run:

$ bundle

Usage

To use this gem, you must first get an API key from http://api.uwaterloo.ca/.

# Require the gem at the top of your ruby file
require 'uwaterlooapi'

# Initialize a new instance of the UWaterlooAPI
api = UWaterlooAPI.new '<your-api-key-goes-here>'

# Store an API query into a variable
current_weather = api.weather.current # '/weather/current'
uni_holidays = api.events.holidays # '/events/holidays'
info_sessions = api.terms.term(1149).infosessions # '/terms/1149/infosessions'
my_favorite_course = api.courses.subject('CS').catalog_number(247) # '/courses/CS/247'
my_favorite_course_schedule = my_favorite_course.schedule # '/courses/CS/247/schedule'

# Use the get method to manually retrieve the data and parse it
current_weather.get.temperature_24hr_max_c

# Or it will do it automatically for you
current_weather.temperature_24hr_max_c # does the same as above
uni_holidays.each do |holiday|
  puts holiday.name
end # this will print out every holiday
uni_holidays[0].name # this will print out the first holiday

# Requests will only be performed once for each query
my_favorite_course.title # => 'Software Engineering Principles'
my_favorite_course.url # => 'http://www.ucalendar.uwaterloo.ca/1415/COURSE/course-CS.html#CS247'

# Check metadata of request
my_favorite_course_schedule.get # Retrieves data from server
if my_favorite_course_schedule.meta(:status) == 204
  puts 'The schedule for this course cannot be found!'
end

For details regarding all API endpoints, go here: https://github.com/uWaterloo/api-documentation

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new pull request