2 * ================================================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ================================================================================
\r
21 * Created by robertlo on 10/10/2016.
\r
26 class ContactUsService {
\r
27 constructor($q, $log, $http, conf, uuid) {
\r
35 // this.$log.info('ContactUsService::getListOfavailableApps: get all app list');
\r
36 let deferred = this.$q.defer();
\r
37 // this.$log.info('ContactUsService::getListOfavailableApps: ', this.conf.api.listOfApp);
\r
40 url: this.conf.api.availableApps,
\r
43 // If response comes back as a redirected HTML page which IS NOT a success
\r
44 // this.$log.info('ContactUsService::getListOfavailableApps availableApps response: ', res);
\r
45 if (Object.keys(res).length == 0) {
\r
46 deferred.reject("ContactUsService::getListOfavailableApps: Failed");
\r
48 // this.$log.debug('ContactUsService::getListOfavailableApps: Succeeded results: ', res);
\r
49 deferred.resolve(res);
\r
51 }).catch( status => {
\r
52 this.$log.error('ContactUsService::getListOfavailableApps: query error: ',status);
\r
53 deferred.reject(status);
\r
55 return deferred.promise;
\r
59 let deferred = this.$q.defer();
\r
60 // this.$log.info('ContactUsService::get all Contact Us list');
\r
62 url: this.conf.api.getContactUS,
\r
66 'X-ECOMP-RequestID':this.uuid.generate()
\r
69 // If response comes back as a redirected HTML page which IS NOT a success
\r
70 if (Object.keys(res.data).length == 0) {
\r
71 deferred.reject("ContactUsService::getContactUs Failed");
\r
73 deferred.resolve(res.data);
\r
77 deferred.reject(status);
\r
79 return deferred.promise;
\r
82 getAppsAndContacts() {
\r
83 let deferred = this.$q.defer();
\r
84 // this.$log.info('ContactUsService::getAppsAndContacts');
\r
86 url: this.conf.api.getAppsAndContacts,
\r
90 'X-ECOMP-RequestID':this.uuid.generate()
\r
93 // If response comes back as a redirected HTML page which IS NOT a success
\r
94 if (Object.keys(res.data).length == 0) {
\r
95 deferred.reject("ContactUsService::getAppsAndContacts Failed");
\r
97 deferred.resolve(res.data);
\r
101 deferred.reject(status);
\r
103 return deferred.promise;
\r
106 getContactUSPortalDetails(){
\r
107 let deferred = this.$q.defer();
\r
108 // this.$log.info('ContactUsService::get all Contact Us Portal Details');
\r
110 url: this.conf.api.getContactUSPortalDetails,
\r
114 'X-ECOMP-RequestID':this.uuid.generate()
\r
117 // If response comes back as a redirected HTML page which IS NOT a success
\r
118 if (Object.keys(res.data).length == 0) {
\r
119 deferred.reject("ContactUsService::getContactUSPortalDetails Failed");
\r
121 deferred.resolve(res.data);
\r
125 deferred.reject(status);
\r
127 return deferred.promise;
\r
130 getAppCategoryFunctions(){
\r
131 let deferred = this.$q.defer();
\r
132 // this.$log.info('ContactUsService::get all App Category Functions');
\r
134 url: this.conf.api.getAppCategoryFunctions,
\r
138 'X-ECOMP-RequestID':this.uuid.generate()
\r
141 // If response comes back as a redirected HTML page which IS NOT a success
\r
142 if (Object.keys(res.data).length == 0) {
\r
143 deferred.reject("ContactUsService::getAppCategoryFunctions Failed");
\r
145 deferred.resolve(res.data);
\r
149 deferred.reject(status);
\r
151 return deferred.promise;
\r
154 addContactUs(newContactUs) {
\r
155 // this.$log.info('ContactUsService::add a new Contact Us');
\r
156 // this.$log.info(newContactUs)
\r
157 let deferred = this.$q.defer();
\r
158 // this.$log.info('ContactUsService:: add Contact Us' + JSON.stringify(newContactUs));
\r
161 appId:newContactUs.app.value,
\r
162 appName:newContactUs.app.title,
\r
163 description:newContactUs.desc,
\r
164 contactName:newContactUs.name,
\r
165 contactEmail:newContactUs.email,
\r
166 url:newContactUs.url,
\r
169 url: this.conf.api.saveContactUS,
\r
173 'X-ECOMP-RequestID':this.uuid.generate()
\r
177 // this.$log.info('ContactUsService:: add Contact Us res' ,res);
\r
178 // If response comes back as a redirected HTML page which IS NOT a success
\r
179 if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {
\r
180 deferred.reject("Add Contact Us failed");
\r
181 this.$log.error('ContactUsService:: add Contact Us failed');
\r
183 deferred.resolve(res.data);
\r
185 }).catch(errRes => {
\r
186 deferred.reject(errRes);
\r
188 return deferred.promise;
\r
191 modifyContactUs(contactUsObj) {
\r
192 // this.$log.info('ContactUsService::edit Contact Us',contactUsObj);
\r
193 let deferred = this.$q.defer();
\r
195 url: this.conf.api.saveContactUS,
\r
199 'X-ECOMP-RequestID':this.uuid.generate()
\r
203 // this.$log.info('ContactUsService:: edit Contact Us res' ,res);
\r
204 // If response comes back as a redirected HTML page which IS NOT a success
\r
205 if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {
\r
206 deferred.reject("Edit Contact Us failed");
\r
207 this.$log.error('ContactUsService:: edit Contact Us failed');
\r
209 deferred.resolve(res.data);
\r
211 }).catch(errRes => {
\r
212 deferred.reject(errRes);
\r
214 return deferred.promise;
\r
217 removeContactUs(id) {
\r
218 let deferred = this.$q.defer();
\r
219 let url = this.conf.api.deleteContactUS + '/' + id;
\r
220 // this.$log.info('ContactUsService:: remove Contact Us');
\r
227 'X-ECOMP-RequestID':this.uuid.generate()
\r
230 // If response comes back as a redirected HTML page which IS NOT a success
\r
231 // this.$log.info("ContactUsService::removeContactUs res",res);
\r
232 deferred.resolve(res.data);
\r
233 if (Object.keys(res.data).length == 0) {
\r
234 deferred.reject("ContactUsService::removeContactUs Failed");
\r
236 deferred.resolve(res.data);
\r
238 }).catch(errRes => {
\r
239 deferred.reject(errRes);
\r
242 return deferred.promise;
\r
245 ContactUsService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4'];
\r
246 angular.module('ecompApp').service('contactUsService', ContactUsService)
\r