'use strict';
define(function() {
  var RestrictionFactory = function($http, $rootScope) {
    var RestrictionFactory = [];

    function setRestriction(restrictions) {
      RestrictionFactory = [];
      RestrictionFactory = angular.copy(restrictions);
    }

    function getRestriction() {
      return RestrictionFactory;
    }

    function getAllRestrictions() {
      var promise = $http.get(
        '/services/{portalid}/restrictions/configuration/getAllRestrictions?f=json'
      );
      promise.then(
        function(res) {},
        function() {}
      );
      return promise;
    }


    function addRestriction(o) {
      return $http.post(
        '/services/{portalid}/restrictions/configuration/add?f=json',
        o
      );
    }


    function updateRestriction(o) {
      var promise = $http.post(
        '/services/{portalid}/restrictions/configuration/update?f=json',
        o
      );
      promise.then(
        function(res) {},
        function() {}
      );
      return promise;
    }

    function removeRestriction(o) {
      var promise = $http.post(
        '/services/{portalid}/restrictions/configuration/remove?f=json',
        o
      );
      promise.then(
        function(res) {},
        function() {}
      );
      return promise;
    }

    function savedatastore(o) {
      var promise = $http.post(
        '/services/{portalid}/restrictions/configuration/savedatastore?f=json',
        o
      );
      promise.then(
        function(res) {},
        function() {}
      );
      return promise;
    }

    function getDatastore() {
      var promise = $http.get(
        '/services/{portalid}/restrictions/configuration/getDatastore?f=json'
      );
      promise.then(
        function(res) {
          //
        },
        function() {}
      );
      return promise;
    }

    return {
      RestrictionFactory: RestrictionFactory,
      setRestriction: setRestriction,
      getRestriction: getRestriction,
      getDatastore: getDatastore,
      savedatastore: savedatastore,
      getAllRestrictions: getAllRestrictions,
      addRestriction: addRestriction,
      updateRestriction: updateRestriction,
      removeRestriction: removeRestriction,
    };
  };
  RestrictionFactory.$inject = ['$http', '$rootScope'];
  return RestrictionFactory;
});
