All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.endercrest.uwaterlooapi.foodservices.FoodServicesAPI Maven / Gradle / Ivy

package com.endercrest.uwaterlooapi.foodservices;

import com.endercrest.uwaterlooapi.data.ApiRequest;
import com.endercrest.uwaterlooapi.foodservices.models.*;
import com.google.gson.reflect.TypeToken;

import java.util.List;

/**
 * Created by Thomas Cordua-von Specht on 11/25/2016.
 */
public class FoodServicesAPI {

    private final String apiKey;

    private static final String MENU_ENDPOINT = "foodservices/menu";
    private static final String NOTES_ENDPOINT = "foodservices/notes";
    private static final String DIETS_ENDPOINT = "foodservices/diets";
    private static final String OUTLETS_ENDPOINT = "foodservices/outlets";
    private static final String LOCATIONS_ENDPOINT = "foodservices/locations";
    private static final String WATCARD_ENDPOINT = "foodservices/watcard";
    private static final String ANNOUNCEMENT_ENDPOINT = "foodservices/announcements";
    private static final String PRODUCT_ENDPOINT = "foodservices/products/%s";
    private static final String MENU_DATE_ENDPOINT = "foodservices/%s/%s/menu";
    private static final String NOTES_DATE_ENDPOINT = "foodservices/%s/%s/notes";
    private static final String ANNOUNCEMENT_DATE_ENDPOINT = "foodservices/%s/%s/announcements";

    public FoodServicesAPI(String apiKey){
        this.apiKey = apiKey;
    }

    /**
     * Retrieve all menu items from all outlets for the current week.
     * @return {@link FoodServiceMenu}
     */
    public ApiRequest getAllMenus(){
        return ApiRequest.createApiRequest(MENU_ENDPOINT, apiKey,
                new TypeToken>(){}.getType());
    }

    /**
     * Retrieve all notes for the current week.
     * @return {@link FoodServiceNote}
     */
    public ApiRequest> getAllNotes(){
        return ApiRequest.createApiRequest(NOTES_ENDPOINT, apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Get all the available diets.
     * @return {@link FoodServiceDiet}
     */
    public ApiRequest> getAllDiets(){
        return ApiRequest.createApiRequest(DIETS_ENDPOINT, apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Retrieve all outlets.
     * @return {@link FoodServiceOutlet}
     */
    public ApiRequest> getAllOutlets(){
        return ApiRequest.createApiRequest(OUTLETS_ENDPOINT, apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Retrieve all food services locations from "/foodservices/locations"
     * @return {@link FoodServiceLocation}
     */
    public ApiRequest> getAllLocations(){
        return ApiRequest.createApiRequest(LOCATIONS_ENDPOINT, apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Retrieve all watcard vendors for food services, from
     * "/foodservices/watcard"
     * @return {@link FoodServiceWatcardVendor}
     */
    public ApiRequest> getAllWatcardVendor(){
        return ApiRequest.createApiRequest(WATCARD_ENDPOINT, apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Retrieve all announcements for food services for the current week
     * from "foodservices/announcements"
     * @return {@link FoodServiceAnnouncement}
     */
    public ApiRequest> getAllAnnouncements(){
        return ApiRequest.createApiRequest(ANNOUNCEMENT_ENDPOINT, apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Get all details for a specific product from food services.
     * @param productId The id of the product.
     * @return {@link FoodServiceProduct}
     */
    public ApiRequest getProductDetails(String productId){
        return ApiRequest.createApiRequest(String.format(PRODUCT_ENDPOINT, productId), apiKey,
                new TypeToken>(){}.getType());
    }

    /**
     * Get a weeks specific menu for any given year and month.
     * @param year Must be a number. IE. "2016"
     * @param week Must be a number. IE. "22"
     * @return {@link FoodServiceMenu}
     */
    public ApiRequest getAllMenus(String year, String week){
        return ApiRequest.createApiRequest(String.format(MENU_DATE_ENDPOINT, year, week), apiKey,
                new TypeToken>(){}.getType());
    }

    /**
     * Get a weeks specific notes for any given year and month.
     * @param year Must be a number. IE. "2016"
     * @param week Must be a number. IE. "22"
     * @return {@link FoodServiceNote}
     */
    public ApiRequest> getAllNotes(String year, String week){
        return ApiRequest.createApiRequest(String.format(NOTES_DATE_ENDPOINT, year, week), apiKey,
                new TypeToken>>(){}.getType());
    }

    /**
     * Get a weeks specific announcement for any given year and month.
     * @param year Must be a number. IE. "2016"
     * @param week Must be a number. IE. "22"
     * @return {@link FoodServiceNote}
     */
    public ApiRequest> getAllAnnouncements(String year, String week){
        return ApiRequest.createApiRequest(String.format(ANNOUNCEMENT_DATE_ENDPOINT, year, week), apiKey,
                new TypeToken>>(){}.getType());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy