import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import {
  Http,
  Headers,
  RequestOptions,
} from '@angular/http';
import { CryptoService } from '../crypto/crypto.service';

@Injectable({
  providedIn: 'root',
})
export class ResultshowService {
  baseurl = environment.baseurl;
  constructor(public http: Http, private crypto: CryptoService) { }
  async FilterKnowQueResultShow(ass_id: number, user_id: number, token) {
    var data = {
      data: this.crypto.encrypt(JSON.stringify({
        ass_id: ass_id,
        user_id: user_id,
      }))
    };
    return new Promise((resolve) => {
      let headers = new Headers();
      headers.append('Accept', 'application/json');
      headers.append('Authorization', 'Bearer ' + token);
      let options = new RequestOptions({ headers: headers });
      var url = this.baseurl + environment.KNOW_ASS_QUES_FILTER_QUES;
      this.http.post(url, data, options).subscribe(
        (res) => {
          resolve([{ status: res.status, json: res['_body'] }]);
        },
        (err) => {
          resolve([{ status: err.status, json: err['_body'] }]);
        }
      );
    });
  }
}
