import { Injectable } from '@angular/core'; import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service'; import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class OfferDiscountService { public static offersDiscountData = 'Services/COCWS.svc/REST/GetOfferDiscountsConfigData'; public static getSuborinateStatus = 'Services/ERP.svc/REST/GET_SUBORDINATES_ATTD_STATUS'; public static categoryList = 'Services/COCWS.svc/REST/Mohemm_ITG_GetCategories'; public static selected_offers = 'selected-offers'; public static related_offers = 'related-offers'; public static selected_filters = 'selected-filters'; public static categories = 'categories'; public static getCategories = 'Services/COCWS.svc/REST/Mohemm_ITG_GetCategories'; constructor( public con: ConnectorService, private authService: AuthenticationService, public cs: CommonService ) { this.cs.sharedService.getSharedData(OfferDiscountService.selected_offers, false); } getOffers(offer_request, onError, errorLabel, pageNo?: number, categoryId?) { let catId = categoryId; var request = this.authService.getAuthenticatedRequest(); request['EmployeeNumber'] = request.UserName; request['ItgIsActive'] = true; request['ItgPageSize'] = 5; request['ItgPageNo'] = pageNo; if (catId) { request['ItgCategoryID'] = categoryId; } return this.con.postNoLoad(OfferDiscountService.offersDiscountData, request, onError, errorLabel); } getCategories(request: any, onError?: any, errorLabel?: string): Observable { this.authService.authenticateRequest(request); request['EmployeeNumber'] = request.UserName; request['ItgChannelId'] = 3; request['ItgIsActive'] = true; request['ItgPageSize'] = 100; request['ItgPageNo'] = 1; request['ItgId'] = 0; request['ItgCategoryName_en'] = ''; request['ItgCategoryName_ar'] = ''; return this.con.postNoLoad( OfferDiscountService.getCategories, request, onError, errorLabel ); } }