import { Injectable } from '@angular/core';
import {map} from 'rxjs/operators';
import {BaseService} from '../../../base/base-service';
import {HttpClient} from '@angular/common/http';
import {environment} from '../../../../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class TestingRoomService extends BaseService {

  requestUrl;
  constructor(
    public http: HttpClient
  ) {
    super('/report/testing_room', http)
  }

  getPdfReport(testing_information_uid) {
    this.requestUrl = `${this.fullUrl}/${testing_information_uid}/pdf`;
    return this.http.get(this.requestUrl, { responseType: 'blob', observe: 'response'}).pipe(
      map((res: any) => {
        return new Blob([res.body], { type: 'application/pdf' });
      })
    );
  }

  getExcelReport(testing_information_uid){
    this.requestUrl = `${this.fullUrl}/${testing_information_uid}`;
    window.open(this.requestUrl);
    return this.requestUrl;
  }

}
