2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
21 * Created by wl849v on 12/14/2016.
25 class RecommendationService {
26 constructor($q, $log, $http, conf, uuid,utilsService) {
32 this.recommendationCount = {count:0};
33 this.refreshCount = 0;
35 this.utilsService = utilsService;
37 getRecommendationCount() {
38 return this.recommendationCount;
40 setRecommendationCount(count) {
41 this.recommendationCount.count = count;
44 return this.refreshCount;
46 setRefreshCount(count){
47 this.refreshCount = count;
49 setMaxRefreshCount(count){
50 this.maxCount = count;
52 decrementRefreshCount(){
53 this.refreshCount = this.refreshCount - 1;
58 let deferred = this.$q.defer();
62 url: this.conf.api.getRecommendations,
64 'X-ECOMP-RequestID':this.uuid.generate()
68 // If response comes back as a redirected HTML page which IS NOT a success
69 if (this.utilsService.isValidJSON(res.data)=== false) {
70 this.$log.error('NotificationService::getRecommendations Failed');
71 deferred.reject("NotificationService::getRecommendations Failed");
73 deferred.resolve(res);
77 this.$log.error('NotificationService::getRecommendations Failed', status);
78 deferred.reject(status);
81 return deferred.promise;
86 RecommendationService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4','utilsService'];
87 angular.module('ecompApp').service('recommendationService', RecommendationService)