/
customerService.js
43 lines (34 loc) · 1.17 KB
/
customerService.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
angular.module('app.services').service('customerService', [ '$http', '$q', 'propertiesConstant',
function ($http, $q, propertiesConstant) {
this.getCustomers = function () {
var d = $q.defer();
$http.get(propertiesConstant.API_URL + '/customer')
.then(function success(response) {
d.resolve(response.data);
}, function error(response) {
d.reject(response.status);
});
return d.promise;
};
this.deleteCustomer = function (id) {
var d = $q.defer();
$http.delete(propertiesConstant.API_URL + '/customer/' + id)
.then(function success(response) {
d.resolve(response.data);
}, function error() {
d.reject();
});
return d.promise;
};
this.saveCustomer = function (customer) {
var d = $q.defer();
$http.post(propertiesConstant.API_URL + '/customer', customer)
.then(function success(response) {
d.resolve(response.data);
}, function error() {
d.reject();
});
return d.promise;
};
}]);