import {catchError, tap, map} from 'rxjs/operators'; /** * @Service:Logging Service * @Creation Date: Aug 3, 2017 * @Author: sbaireddy * @Version: 1.0 : */ import { Injectable } from '@angular/core'; // import { HttpClient, Headers, RequestOptions, Response } from '@angular/_http'; import { HttpClient } from '@angular/common/http'; // import { Observable } from 'rxjs/observable'; import { Observable } from 'rxjs/Rx'; // for debugging import { apiProxy } from '../generated/endpoints'; import Utils from '../shared/utils'; import { BaseService } from './base.service'; import * as ServiceConstants from '../shared/service.constants'; /** * This class provides the Lookup Service with methods to lookup customer and orders. */ @Injectable({providedIn:'root'}) export class LoggingService extends BaseService { /** * Creates a new UserService with the injected HttpClient. * @param {HttpClient} _http - The injected HttpClient. * @constructor */ constructor(public _http: HttpClient) { super(); } /** * Returns an Observable for the HTTP GET request for the JSON resource. * @return {any} The Observable for the HTTP request. */ addLogging(requestParams: any): Observable { if (ServiceConstants.LOGGING) { console.log('[start]-LoggingService.addLogging ()'); } // getting the request options // const headers = new Headers({ 'Content-Type': 'application/json' }); // const options = { withCredentials: true, headers: headers }; const options = this.httpOptions(); const url = apiProxy + '/frontline/ui/telemetry'; // service calling return this._http.post(url, requestParams, options).pipe( map((res: any) => res), tap(data => { if (ServiceConstants.LOGGING) { console.log('[end]-LoggingService.addLogging ()'); } }), // for debug catchError(this.handleError)); } }