
(function () {
    'use strict';
    angular.module('Monitour.pages.sites')
        .factory('SitesService', SitesService);


    function SitesService($http, $localStorage) {


        var service = {};

        service.GetClientsSites = GetClientsSites;
        service.GetCheckpointsSites = GetCheckpointsSites;
        service.GetAll = GetAll;
        service.GetById = GetById;
        service.Create = Create;
        service.Update = Update;
        service.Delete = Delete;


        var domain  = 'https://api.callio.com.au/public/';

        return service;


        function GetAll(pageNumber, itemsPerPage) {
            return $http.get(domain + 'sites?page=' + pageNumber + '&limit=' + itemsPerPage);
        }
        function GetById(id) {
            return $http.get(domain + 'sites/' + id);
        }

        function GetClientsSites(id) {
            return $http.get(domain + 'sites?client=' + id);
        }

        function GetCheckpointsSites(id) {
            return $http.get(domain + 'checkpoints?site_id=' + id);
        }


        function Create(site) {
            return $http.post(domain + 'sites', site);
        }

        function Update(site, id) {
            return $http.patch(domain + 'sites/' + id, site);
        }

        function Delete(id) {
            return $http.delete(domain + 'sites/' + id);
        }


    }

})();