Giter Club home page Giter Club logo

uwaterlooapi's Introduction

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

uwaterlooapi's People

Contributors

amsardesai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.