(function() {
    angular
        .module("bookmap")
        .service("StatsService", StatsService);

    StatsService.$inject = [
        "$http",
        "$q",
        "API"
    ];

    function StatsService($http, $q, API) {
        var API_URL = [API.URL, API.VERSION, "stats"].join("/");

        this.getStats = getStats;

        function getStats() {
            return $http.get(API_URL)
                .then(
                    function(response) {
                        return response.data;
                    },
                    function(httpError) {
                        throw httpError.status + ": " + httpError.data;
                    }
                );
        }
    }
})();
