import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { environment } from '../../../environments/environment.dev';

@Injectable()
export class BulkUploadFileService {
  // _baseURL: string = 'http://localhost:xxxx/api/fileupload/'
  // _baseURL: String = ' https://3-playground.altimetrik.com/orchestrate/bulkOnboardCandidate'

  // Base Urls
  private baseURL = environment.apiUrl;
  constructor(private http: Http) {}

  EmployeUpload(files) {
    const headers = new Headers();
    const options = new RequestOptions({ headers: headers });
    // options.params = parameters;
    return this.http
      .post(this.baseURL + 'orchestrate/bulkOnboardEmployee', files, options)
      .map(res => res.json())
      .catch(error => Observable.throw(error));
  }

  upload(files, loggedInUser) {
    const headers = new Headers();
    headers.append('logged-in-user', loggedInUser);
    const options = new RequestOptions({ headers: headers });
    return this.http
      .post(this.baseURL + 'orchestrate/bulkOnboardCandidate', files, options)
      .map(res => res.json())
      .catch(error => Observable.throw(error));
  }
  getImages() {
    return this.http
      .get(this.baseURL + 'getimages')
      .map(response => response.json())
      .catch(error => Observable.throw(error));
  }
  allExperiencelevels() {
    return this.http
      .get(this.baseURL + 'orchestrate/getAllExperienceLevel/')
      .map(response => response.json())
      .catch(error => Observable.throw(error));
  }
  allSkilltrackMstrs() {
    return this.http
      .get(this.baseURL + 'orchestrate/getAllSkillTrackDtls')
      .map(response => response.json())
      .catch(error => Observable.throw(error));
  }
}
