Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame^] | 1 | 'use strict'; |
| 2 | import {IAppConfigurtaion, IApi} from "../models/app-config"; |
| 3 | |
| 4 | interface IEcompHeaderService { |
| 5 | getMenuItems(userId):ng.IPromise<Array<any>>; |
| 6 | } |
| 7 | |
| 8 | export 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 | } |