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

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

  requestUrl;
  constructor(
    public http: HttpClient
  ) {
    super('/report/Test/exam_result_subject', http)
    super.fullUrl = `${environment.storeApi}/api/report/Test/exam_total`
  }
  // ${this.fullUrl}
  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}/xls`;
    window.open(this.requestUrl);
    return this.requestUrl;
  }
}
