Code Monkey home page Code Monkey logo

uwaterloo-api's Introduction

uwaterloo-api

Android wrapper for the UWaterloo Open Data API

Download

uwaterloo-api can easily be included in your app via Gradle. Because I'm too lazy to manage a maven repository and all that nonsense, you can just pull it in via jitpack:

repositories {
    maven {
        url 'https://jitpack.io'
    }
}

dependencies {
    compile 'com.github.cdeange:uwaterloo-api:1.0.0'
}

uwaterloo-api requires at minimum Java 7 and Android 4.1 Jelly Bean (API 16).

Sample

This library usage is being demonstrated by a sample app available on Google Play. If you'd like to try out the app and see what features you can use, download the sample app.

Get it on Google Play

Usage

If you haven't registered an API key yet, you'll need to do that first. Visit the Open Data API homepage and register an API key with your name and email. There are no usage limits with the key, but you are still subject to the UWaterloo Open Data API's terms of use and license agreement.

UWaterlooApi api = new UWaterlooApi("YOUR_API_KEY");

Each API is accessible via one of the members of a UWaterlooApi.

Each API method will return a Retrofit Call object. Calls may be executed synchronously with call.execute(), or asynchronously with call.enqueue(). For more information on how to interact with Calls, refer to the Retrofit reference here.

Examples

// Don't actually do this, you should always be checking for errors
public <T> T perform(Call<T> call) throws IOException {
    return call.execute().body();
}

Reading the current temperature:

WeatherReading reading = perform(api.Weather.getWeather()).getData();
Log.v(TAG, "The current temperature is " + reading.getTemperature() + "˚C");

Getting information about a food spot on campus:

List<Location> locations = perform(api.FoodServices.getLocations()).getData();
for (Location location : locations) {
    Log.v(TAG, location.getName() + " is currently " + (location.isOpenNow() ? "open" : "closed"));
}

Preparing for your morning walk to class:

List<GooseNest> nests = perform(api.Resources.getGeeseNests()).getData();
for (GooseNest nest : nests) {
    Log.v(TAG, "Goose nest reported! " + nest.getLocationDescription());
}

Full Method Reference

Food Services

Method Return Type Endpoint
getWeeklyMenu() MenuInfo /foodservices/menu
getNotes() List<Note> /foodservices/notes
getDiets() List<Diet> /foodservices/diets
getOutlets() List<Outlet> /foodservices/outlets
getLocations() List<Location> /foodservices/locations
getWatcardVendors() List<WatcardVendor> /foodservices/watcard
getAnnouncements() List<Announcement> /foodservices/announcements
getProduct() Product /foodservices/products/{product_id}
getWeeklyMenu() MenuInfo /foodservices/{year}/{week}/menu
getNotes() List<Note> /foodservices/{year}/{week}/notes
getAnnouncements() List<Announcement> /foodservices/{year}/{week}/announcements

Courses

Method Return Type Endpoint
getCourseInfo() List<Course> /courses/{subject}
getCourseInfo() CourseInfo /courses/{course_id}
getCourseSchedule() List<CourseSchedule> /courses/{class_number}/schedule
getCourseSchedule() List<CourseSchedule> /courses/{class_number}/schedule?term={term}
getCourseInfo() CourseInfo /courses/{subject}/{catalog_number}
getCourseSchedule() List<CourseSchedule> /courses/{subject}/{catalog_number}/schedule
getCourseSchedule() List<CourseSchedule> /courses/{subject}/{catalog_number}/schedule?term={term}
getPrerequisites() PrerequisiteInfo /courses/{subject}/{catalog_number}/prerequisites
getExamSchedule() ExamInfo /courses/{subject}/{catalog_number}/examschedule

Events

Method Return Type Endpoint
getEvents() List<Event> /events
getEvents() List<Event> /events/{site}
getEvent() EventInfo /events/{site}/{id}

News

Method Return Type Endpoint
getNews() List<NewsDetails> /news
getNews() List<NewsDetails> /news/{site}
getNews() NewsArticle /news/{site}/{id}

Weather

Method Return Type Endpoint
getWeather() WeatherReading /weather/current

Weather (Legacy)

Method Return Type Endpoint
getWeather() LegacyWeatherReading /weather/waterloo_weather_station_data.xml

Terms

Method Return Type Endpoint
getTermList() TermInfo /terms/list
getExamSchedule() List<ExamInfo> /terms/{term}/examschedule
getSchedule() List<CourseSchedule> /terms/{term}/{subject}/schedule
getSchedule() List<CourseSchedule> /terms/{term}/{subject}/{catalog_number}/schedule
getInfoSessions() List<InfoSession> /terms/{term}/infosessions

Resources

Method Return Type Endpoint
getSites() List<Site> /resources/sites
getTutors() List<Tutor> /resources/tutors
getPrinters() List<Printer> /resources/printers
getInfoSessions() List<InfoSession> /resources/infosessions
getGeeseNests() List<GooseNest> /resources/goosewatch
getSunshineList() List<Sunshiner> /resources/sunshinelist

Buildings

Method Return Type Endpoint
getBuildings() List<Building> /buildings/list
getBuilding() Building /buildings/{building_code}
getClassroomCourses() List<ClassroomCourses> /buildings/{building_code}/{room}/courses

Parking

Method Return Type Endpoint
getParkingInfo() List<ParkingLot> /parking/watpark

Points Of Interest

Method Return Type Endpoint
getATMs() List<ATM> /poi/atms
getGreyhoundStops() List<GreyhoundStop> /poi/greyhound
getPhotospheres() List<Photosphere> /poi/photospheres
getHelplines() List<Helpline> /poi/helplines
getLibraries() List<Library> /poi/libraries
getDefibrillators() List<Defibrillator> /poi/defibrillators

Watcard

Method Return Type Endpoint
balances() Watcard (external)
transactions() Transactions (external)

Contributing

Feel free to submit any pull requests or issues to this repository as you please. However, please keep it limited to things that directly address something directly provided by either the uwaterloo-api library or the sample app. If there is an issue with the actual data being returned by the API, please refer to the lovely maintainers over at the Open Data API documentation.

License

Copyright (c) 2017 Christian De Angelis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

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.