Blame view

app/partials/accountSetting/accountSetting.Service.js 4.12 KB
f746aee1b   Anchit Jindal   account settingsc...
1
2
3
4
5
6
  (function() {
  	'use strict';
  	angular.module('acufuel').service(
  			'AccountSettingService',
  			[ '$rootScope', '$q', '$http', '$state', 'BASE_URL',
  					AccountSettingService ]);
3a9f4472b   Rishav   Implement contact...
7

f746aee1b   Anchit Jindal   account settingsc...
8
  	function AccountSettingService($rootScope, $q, $http, $state, BASE_URL) {
3a9f4472b   Rishav   Implement contact...
9

f746aee1b   Anchit Jindal   account settingsc...
10
  		this.getProducts = function() {
3a9f4472b   Rishav   Implement contact...
11

f746aee1b   Anchit Jindal   account settingsc...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  			var deferred = $q.defer();
  			$http({
  				method : 'GET',
  				url : BASE_URL.url + '/user/products',
  				headers : {
  					'Content-Type' : 'application/json'
  				},
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
3a9f4472b   Rishav   Implement contact...
27

f746aee1b   Anchit Jindal   account settingsc...
28
  		this.updateProducts = function(data) {
bb639860c   Rishav   account setting p...
29

f746aee1b   Anchit Jindal   account settingsc...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  			var deferred = $q.defer();
  			$http({
  				method : 'PUT',
  				url : BASE_URL.url + '/fuelPricing/product',
  				data : data,
  				headers : {
  					'Content-Type' : 'application/json'
  				},
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
bb639860c   Rishav   account setting p...
46

f746aee1b   Anchit Jindal   account settingsc...
47
  		this.loginUserData = function(id) {
bb639860c   Rishav   account setting p...
48

f746aee1b   Anchit Jindal   account settingsc...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  			var deferred = $q.defer();
  			$http({
  				method : 'GET',
  				url : BASE_URL.url + '/account/user/' + id,
  				headers : {
  					'Content-Type' : 'application/json'
  				},
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
3e6e9e0f4   Anchit Jindal   validate user exists
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  		
  		this.checkEmail = function(email) {
  
  			var deferred = $q.defer();
  			$http({
  				method : 'GET',
  				url : BASE_URL.url + '/user/email/status?email=' + email,
  				headers : {
  					'Content-Type' : 'application/json'
  				},
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
f746aee1b   Anchit Jindal   account settingsc...
82
83
  
  		this.updateUserProfile = function(data) {
bb639860c   Rishav   account setting p...
84

f746aee1b   Anchit Jindal   account settingsc...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  			var deferred = $q.defer();
  			$http({
  				method : 'PUT',
  				url : BASE_URL.url + '/account/updateProfile',
  				headers : {
  					'Content-Type' : 'application/x-www-form-urlencoded'
  				},
  				data : data
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
bb639860c   Rishav   account setting p...
101

f746aee1b   Anchit Jindal   account settingsc...
102
103
104
105
106
107
108
109
110
111
112
113
114
  		this.addAdditionalAccount = function(data) {
  			console.log('----$scope.accountdata--', data);
  			var deferred = $q.defer();
  			$http({
  				method : 'POST',
  				url : BASE_URL.url + '/additionalAccount',
  				headers : {
  					'Content-Type' : 'application/json'
  				},
  				data : data
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
f746aee1b   Anchit Jindal   account settingsc...
115
116
117
118
119
120
121
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
  		
  		
  		this.getAdditionalAccounts = function() {
bb639860c   Rishav   account setting p...
122
123
            var deferred = $q.defer();
            $http({
f746aee1b   Anchit Jindal   account settingsc...
124
125
126
                method : 'GET',
                url : BASE_URL.url +'/user/additionalAccount',
                headers : {'Content-Type': 'application/json'},
bb639860c   Rishav   account setting p...
127
128
129
130
131
132
133
134
135
            })
            .then(function (result){
                deferred.resolve(result.data);
            },function (result){
              //console.log(result.data)
                deferred.resolve(result.data);
            })
            return deferred.promise;
          }
f746aee1b   Anchit Jindal   account settingsc...
136
137
  		
  		this.updateStatus = function(data) {
bb639860c   Rishav   account setting p...
138

f746aee1b   Anchit Jindal   account settingsc...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
  			var deferred = $q.defer();
  			$http({
  				method : 'PUT',
  				url : BASE_URL.url + '/additionalAccount',
  				headers : {
  					'Content-Type' : 'application/x-www-form-urlencoded'
  				},
  				data : data
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
  		
  		this.deleteAccount = function(id) {
ae523d5ef   Mr. Hot Foods   account setting m...
157

f746aee1b   Anchit Jindal   account settingsc...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  			var deferred = $q.defer();
  			$http({
  				method : 'DELETE',
  				url : BASE_URL.url + '/additionalAccount/'+id,
  				headers : {
  					'Content-Type' : 'application/x-www-form-urlencoded'
  				}
  			}).then(function(result) {
  				deferred.resolve(result.data);
  			}, function(result) {
  				//console.log(result.data)
  				deferred.resolve(result.data);
  			})
  			return deferred.promise;
  		}
ae523d5ef   Mr. Hot Foods   account setting m...
173

f746aee1b   Anchit Jindal   account settingsc...
174
  	}
ae523d5ef   Mr. Hot Foods   account setting m...
175

3a9f4472b   Rishav   Implement contact...
176
  })();