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

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

  requestUrl;
  constructor(
    public http: HttpClient
  ) {
    super('/report/testing_subject', 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;
  }
}
