2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 * Created by robertlo on 10/10/2016.
44 class ContactUsService {
45 constructor($q, $log, $http, conf, uuid) {
53 // this.$log.info('ContactUsService::getListOfavailableApps: get all app list');
54 let deferred = this.$q.defer();
55 // this.$log.info('ContactUsService::getListOfavailableApps: ', this.conf.api.listOfApp);
58 url: this.conf.api.availableApps,
61 // If response comes back as a redirected HTML page which IS NOT a success
62 // this.$log.info('ContactUsService::getListOfavailableApps availableApps response: ', res);
63 if (Object.keys(res).length == 0) {
64 deferred.reject("ContactUsService::getListOfavailableApps: Failed");
66 // this.$log.debug('ContactUsService::getListOfavailableApps: Succeeded results: ', res);
67 deferred.resolve(res);
70 this.$log.error('ContactUsService::getListOfavailableApps: query error: ',status);
71 deferred.reject(status);
73 return deferred.promise;
77 let deferred = this.$q.defer();
78 // this.$log.info('ContactUsService::get all Contact Us list');
80 url: this.conf.api.getContactUS,
84 'X-ECOMP-RequestID':this.uuid.generate()
87 // If response comes back as a redirected HTML page which IS NOT a success
88 if (Object.keys(res.data).length == 0) {
89 deferred.reject("ContactUsService::getContactUs Failed");
91 deferred.resolve(res.data);
95 deferred.reject(status);
97 return deferred.promise;
100 getAppsAndContacts() {
101 let deferred = this.$q.defer();
102 // this.$log.info('ContactUsService::getAppsAndContacts');
104 url: this.conf.api.getAppsAndContacts,
108 'X-ECOMP-RequestID':this.uuid.generate()
111 // If response comes back as a redirected HTML page which IS NOT a success
112 if (Object.keys(res.data).length == 0) {
113 deferred.reject("ContactUsService::getAppsAndContacts Failed");
115 deferred.resolve(res.data);
119 deferred.reject(status);
121 return deferred.promise;
124 getContactUSPortalDetails(){
125 let deferred = this.$q.defer();
126 // this.$log.info('ContactUsService::get all Contact Us Portal Details');
128 url: this.conf.api.getContactUSPortalDetails,
132 'X-ECOMP-RequestID':this.uuid.generate()
135 // If response comes back as a redirected HTML page which IS NOT a success
136 if (Object.keys(res.data).length == 0) {
137 deferred.reject("ContactUsService::getContactUSPortalDetails Failed");
139 deferred.resolve(res.data);
143 deferred.reject(status);
145 return deferred.promise;
148 getAppCategoryFunctions(){
149 let deferred = this.$q.defer();
150 // this.$log.info('ContactUsService::get all App Category Functions');
152 url: this.conf.api.getAppCategoryFunctions,
156 'X-ECOMP-RequestID':this.uuid.generate()
159 // If response comes back as a redirected HTML page which IS NOT a success
160 if (Object.keys(res.data).length == 0) {
161 deferred.reject("ContactUsService::getAppCategoryFunctions Failed");
163 deferred.resolve(res.data);
167 deferred.reject(status);
169 return deferred.promise;
172 addContactUs(newContactUs) {
173 // this.$log.info('ContactUsService::add a new Contact Us');
174 // this.$log.info(newContactUs)
175 let deferred = this.$q.defer();
176 // this.$log.info('ContactUsService:: add Contact Us' + JSON.stringify(newContactUs));
179 appId:newContactUs.app.value,
180 appName:newContactUs.app.title,
181 description:newContactUs.desc,
182 contactName:newContactUs.name,
183 contactEmail:newContactUs.email,
184 url:newContactUs.url,
187 url: this.conf.api.saveContactUS,
191 'X-ECOMP-RequestID':this.uuid.generate()
195 // this.$log.info('ContactUsService:: add Contact Us res' ,res);
196 // If response comes back as a redirected HTML page which IS NOT a success
197 if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {
198 deferred.reject("Add Contact Us failed");
199 this.$log.error('ContactUsService:: add Contact Us failed');
201 deferred.resolve(res.data);
204 deferred.reject(errRes);
206 return deferred.promise;
209 modifyContactUs(contactUsObj) {
210 // this.$log.info('ContactUsService::edit Contact Us',contactUsObj);
211 let deferred = this.$q.defer();
213 url: this.conf.api.saveContactUS,
217 'X-ECOMP-RequestID':this.uuid.generate()
221 // this.$log.info('ContactUsService:: edit Contact Us res' ,res);
222 // If response comes back as a redirected HTML page which IS NOT a success
223 if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {
224 deferred.reject("Edit Contact Us failed");
225 this.$log.error('ContactUsService:: edit Contact Us failed');
227 deferred.resolve(res.data);
230 deferred.reject(errRes);
232 return deferred.promise;
235 removeContactUs(id) {
236 let deferred = this.$q.defer();
237 let url = this.conf.api.deleteContactUS + '/' + id;
238 // this.$log.info('ContactUsService:: remove Contact Us');
245 'X-ECOMP-RequestID':this.uuid.generate()
248 // If response comes back as a redirected HTML page which IS NOT a success
249 // this.$log.info("ContactUsService::removeContactUs res",res);
250 deferred.resolve(res.data);
251 if (Object.keys(res.data).length == 0) {
252 deferred.reject("ContactUsService::removeContactUs Failed");
254 deferred.resolve(res.data);
257 deferred.reject(errRes);
260 return deferred.promise;
263 ContactUsService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4'];
264 angular.module('ecompApp').service('contactUsService', ContactUsService)