API DEMO

Full list of API calls available here



JS CODE

        var accesstoken = null;
        var authHeaders = null;
        var login = function () {
            $.ajax({
                url: '/Token',
                type: 'POST',
                data: { grant_type: 'password', username: $('#user').val(), password: $('#pass').val() },
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                success: function (data) {
                    sessionStorage.setItem('userName', data.userName);
                    sessionStorage.setItem('accessToken', data.access_token);
                    sessionStorage.setItem('refreshToken', data.refresh_token);
                    accesstoken = sessionStorage.getItem('accessToken');
                    authHeaders = {};
                    if (accesstoken) {
                        authHeaders.Authorization = 'Bearer ' + accesstoken;
                    }
                    $('#GetPackages').show();
                    $('#GetTaps').show();
                }
            });
        };
        var GetPackages = function () {
            $('#TokenShow').hide();
            $.ajax({
                url: '/api/Packages',
                type: 'GET',
                headers: authHeaders,
                success: function (resp) {
                    $('#TokenShow').show();
                    $('#TokenShow').text(JSON.stringify(resp, null, 2));
                }
            });
        };
        var GetTaps = function () {
            $('#TokenShow').hide();
            $.ajax({
                url: '/api/Taps',
                type: 'GET',
                headers: authHeaders,
                success: function (resp) {
                    $('#TokenShow').show();
                    $('#TokenShow').text(JSON.stringify(resp, null, 2));
                }
            });
        };
        //Once you are ready to log a drink it would look something like this.
        var Drink = {
            DrinkID: 0,
            PackageID: 103,
            Time: "2017-05-18T17:55:24.006Z",
            MeasurementID: 4,
            MeasurementQuantity: 1,
            DrinkerID: 7,
            Comment: "",
            Rate: 0
        };
        var PostDrink = function () {
            $('#TokenShow').hide();
            $.ajax({
                url: '/api/Drinks?Checkin=false',
                type: 'POST',
                headers: authHeaders,
                data: Drink,
                success: function (resp) {
                    $('#TokenShow').show();
                    $('#TokenShow').text(JSON.stringify(resp, null, 2));
                }
            });
        };