
(function () {
    'use strict';
    angular.module('Monitour.pages.invoice')
        .factory('InvoiceService', InvoiceService);


    function InvoiceService($http, $localStorage) {
        var service = {};
        service.GetAll = GetAll;
        service.GetById = GetById;
        service.Create = Create;
        service.Update = Update;
        service.Count = Count;
        service.Delete = Delete;
        service.GetFilters = GetFilters;

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

        function Count() {
            return $http.get(domain + 'invoices/count');
        }
        function Me() {
			return $http.get(domain + '/users/me');
		}

        function GetAll(pagenumber, itemsPerPage) {
            return $http.get(domain + 'invoices?page=' + pagenumber + '&limit=' + itemsPerPage);
        }

        function GetFilters(client, site, pagenumber, itemsPerPage) {
            return $http.get(domain + 'invoices?client=' + client + '&site_id=' + site + '&page=' + pagenumber + '&limit=' + itemsPerPage);
        }

        function GetById(id) {
            return $http.get(domain + 'invoices/' + id);
        }

  

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

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

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