'use strict';

function GenericApiService() {

    this.getArticles = function () {
        return [{"title": "article1", "content": "Content 1"}];
    }

}

(function () {
    angular
        .module('cms.services')
        .service('GenericApiService', GenericApiService);
}());
@@ -39,112 +39,2450 @@
 ice(
-) %7B%0A%0A    this.getArticles = function () %7B%0A        return %5B%7B%22title%22: %22article1%22, %22content%22: %22Content 1%22%7D%5D
+$http, $log) %7B%0A%0A    var apiEndPoint = '/api';%0A%0A    var printError = function (error) %7B%0A        // TODO: make a generic version of this%0A        // TODO: set log level for information to debug in $logProvider%0A        $log.error('%5B' + error.config.method + '%5D ' + error.status + ' %22' + error.statusText + '%22 %22' + error.config.url + '%22');%0A    %7D;%0A%0A    this.get = function (objectIdentifier) %7B%0A        return $http.get(apiEndPoint + '/' + objectIdentifier)%0A            .then(function (response) %7B%0A                return response.data;%0A            %7D).catch(function (error) %7B%0A                printError(error);%0A            %7D);%0A    %7D;%0A%0A    this.getObject = function (objectIdentifier, objectId) %7B%0A        return $http.get(apiEndPoint + '/' + objectIdentifier + '/' + objectId)%0A            .then(function (response) %7B%0A                return response.data;%0A            %7D).catch(function (error) %7B%0A                printError(error);%0A            %7D);%0A    %7D;%0A%0A    this.getEmptyObject = function (objectIdentifier) %7B%0A        return $http.get(apiEndPoint + '/empty/' + objectIdentifier )%0A            .then(function (response) %7B%0A                return response.data;%0A            %7D).catch(function (error) %7B%0A                printError(error);%0A            %7D);%0A    %7D;%0A%0A    this.post = function (objectIdentifier, object) %7B%0A        return $http(%7B%0A            headers: %7B'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'%7D,%0A            url: apiEndPoint + '/' + objectIdentifier,%0A            method: 'POST',%0A            data: object%0A        %7D).then(function (response) %7B%0A            return response.data;%0A        %7D).catch(function (error) %7B%0A            printError(error);%0A        %7D);%0A    %7D;%0A%0A    this.put = function (objectIdentifier, object) %7B%0A        return $http(%7B%0A            headers: %7B'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'%7D,%0A            url: apiEndPoint + '/' + objectIdentifier + '/' + object.id,%0A            method: 'PUT',%0A            data: object%0A        %7D).then(function (response) %7B%0A            return response.data;%0A        %7D).catch(function (error) %7B%0A            printError(error);%0A        %7D);%0A    %7D%0A%0A    this.remove = function (objectIdentifier, objectId) %7B%0A        return $http.delete(apiEndPoint + '/' + objectIdentifier + '/' + objectId)%0A            .then(function (response) %7B%0A                return response.data;%0A            %7D).catch(function (error) %7B%0A                printError(error);%0A            %7D)
 ;%0A  
@@ -2605,14 +2605,71 @@
 ervice);
+%0A%0A        GenericApiService.$inject = %5B '$http', '$log'%5D;
 %0A%7D());

Add GenericApiService