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

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

  requestUrl;
  constructor(
    public http: HttpClient
  ) {
    super('/report/Test/summary_candidates_absentees_passers', http)
    super.fullUrl = `${environment.storeApi}/api/report/Test/summary_candidates_absentees_passers`
  }

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