import {Injectable} from '@angular/core';
import {Http, Response, Headers, } from "@angular/http";
import {AuthenticationService} from "../authentication/authentication.service";
import { Observable } from 'rxjs';
import {MenuEntries} from './models/menu-entries.request';
import { Request } from 'src/app/hmg-common/services/models/request';
//import {Request} from '../models/request';
import {MenuResponse} from './models/menu-response'
import { ConnectorService } from '../connector/connector.service';
@Injectable()
export class MenuService {
  public static getMenu ='Services/ERP.svc/REST/GET_MENU';
  public static getMenuEntries = 'Services/ERP.svc/REST/GET_MENU_ENTRIES';
  public static getMyTeam = 'Services/ERP.svc/REST/GET_EMPLOYEE_SUBORDINATES';
  public static getNotCount='Services/ERP.svc/REST/GET_OPEN_NOTIFICATIONS_NUM';
  public static disableSession="Services/ERP.svc/REST/DisableSession";
  public static detectLanguage='Services/ERP.svc/REST/Get_LanguageAvailable';
    constructor(
      public authService: AuthenticationService,
      public con:ConnectorService
  
    ) { }
  
    public getMenu(onError?: any, errorLabel?: string): Observable<MenuResponse> {
      const request = new Request();
      this.authService.authenticateRequest(request);
      return this.con.post(MenuService.getMenu, request, onError, errorLabel);
    }
    public getMenuEntires(menuEntries:any, onError?: any, errorLabel?: string): Observable<MenuResponse> {
      const request = menuEntries;
      this.authService.authenticateRequest(request);
      return this.con.post(MenuService.getMenuEntries, request, onError, errorLabel);
    }
    public getNotificationCount(req:any, onError?: any, errorLabel?: string): Observable<any> {
      const request = req;
      this.authService.authenticateRequest(request);
      return this.con.post(MenuService.getNotCount, request, onError, errorLabel);
    }

    public disableSession(req:any, onError?: any, errorLabel?: string): Observable<any> {
      const request = req;
      this.authService.authenticateRequest(request);
      return this.con.post(MenuService.disableSession, request, onError, errorLabel);
    } 

    public getAppLanguages(req:any, onError?: any, errorLabel?: string): Observable<any> {
      const request = req;
      this.authService.authenticateRequest(request);
      return this.con.post(MenuService.detectLanguage, request, onError, errorLabel);
    } 
}