ShortTermForecast by Registration date

Get short term forecast by Cap Id and registration date

by CAPDev

HTML

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/highlight.js/8.7/styles/agate.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/highlight.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
<div class="container body-content">
    
<h3>Short Term Forecast</h3>

    <p>Get short term forecast by cap id and registration date</p>
    <div ng-controller="shortTermForecastRegistrationDateCtrl as vm">
        <div>
            <div class="form-group">
                <label>Authentication Token</label>
                <textarea class="form-control" cols="15" rows="9" ng-model="vm.token" placeholder="authentication token" required></textarea>
            </div>
            <div class="form-group">
                <label>Cap Id</label>
                <input type="text" class="form-control" placeholder="cap id" ng-model="vm.capId" required>
            </div>
            <div class="form-group">
            <label>Registration Date</label>
            <input type="text" class="form-control" placeholder="registration date" ng-model="vm.registrationDate" required>
        </div>
            <div class="form-group">
    <label>Mileage</label>
    <input type="text" class="form-control" placeholder="mileage" ng-model="vm.mileage" required>
</div>
<div class="form-group">
    <label>Valuation Date</label>
    <input type="text" class="form-control" placeholder="Valuation Date" ng-model="vm.valuationDate" required>
</div>
<div class="form-inline" style="margin-top: 20px;">
    <div class="form-group">
        <label>Month From</label>
        <input type="text" class="form-control" placeholder="Month From" ng-model="vm.monthFrom">
    </div>
    <div class="form-group">
        <label>Month To</label>
        <input type="text" class="form-control" placeholder="Month To" ng-model="vm.monthTo">
    </div>
</div>
 ...

CSS

body {
    padding-top:0;
    padding-bottom: 20px;
}
.body-content {
    padding-left: 15px;
    padding-right: 15px;
}
input, select, textarea {
    max-width: 280px;
}
pre, code {
    max-height: 400px;
}
p {
    font-size:16px;
}

JavaScript

angular.module('capApiDemo', []);

angular.module('capApiDemo').directive('ngHighlight', function () {    
    return {
        restrict: 'A',
        link: function ($scope, element, attrs) {
            $scope.$watch(attrs.ngHighlight, function (newValue) {
                element.text(newValue);
                hljs.highlightBlock(element[0]);
            });
        }
    };
});

angular
        .module('capApiDemo')
        .controller('shortTermForecastRegistrationDateCtrl', shortTermForecastRegistrationDateCtrl);

    shortTermForecastRegistrationDateCtrl.$inject = ['$http'];
    function shortTermForecastRegistrationDateCtrl($http) {
        var vm = this;
        vm.token = '';
        vm.capId = '';
        vm.registrationDate = '';        
        vm.shortTermForecast = '';
        vm.selectedFormat = 'application/json';

        vm.getShortTermForecast = getShortTermForecast;

        function getShortTermForecast() {
            vm.shortTermForecast = '';
            var options = getOptions();
            var requestUrl = 'https://services.cap.co.uk/ShortTermForecast/v1/1/ByRegistrationDate?capId=' + vm.capId + '&registrationDate=' + vm.registrationDate + options;
            $http({
                method: 'GET', url: requestUrl, headers: {
                    'Authorization': 'Bearer ' + vm.token,
                    'Accept': vm.selectedFormat
                }
            })
                .then(function (response) {
                    vm.resultAvailable = true;
                    if (vm.selectedFormat === 'application/json') {
                        vm.shortTermForecast = JSON.stringify(response.data, undefined, 2);
                    } else {
                        vm.shortTermForecast = response.data;
                    }
                })
                .catch(function (errResponse) {
                    vm.resultAvailable = true;
                    if (vm.selectedFormat === 'application/json') {
                       ...