blob: 2703a50fc3ce331145f21fc867da5dba9537bbfe [file] [log] [blame]
Michael Landoed64b5e2017-06-09 03:19:04 +03001'use strict';
2import {IAppConfigurtaion, IApi} from "../models/app-config";
3
4interface IEcompHeaderService {
5 getMenuItems(userId):ng.IPromise<Array<any>>;
6}
7
8export class EcompHeaderService implements IEcompHeaderService {
9 static '$inject' = ['$http', '$q', 'sdcConfig'];
10 private api:IApi;
11
12 constructor(private $http:ng.IHttpService,
13 private $q:ng.IQService,
14 private sdcConfig:IAppConfigurtaion) {
15 this.api = sdcConfig.api;
16 }
17
18 getMenuItems = (userId):ng.IPromise<Array<any>> => {
19 let defer = this.$q.defer<Array<any>>();
20 //defer.resolve(this.mockData);
21 this.$http.get(this.api.root + this.api.GET_ecomp_menu_items.replace(':userId', userId))
22 .then((response:any) => {
23 defer.resolve(response.data);
24 }, (response) => {
25 defer.reject(response.data);
26 });
27
28 return defer.promise;
29 };
30}