import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { Observable } from 'rxjs';
import { HttpHeaders, HttpClient } from '@angular/common/http';
import { WorkFlow } from './workflow';

@Injectable({
  providedIn: 'root'
})
export class WorkFlowService {
  baseUrl: string = environment.serviceUrl;

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/WorkFlowApi');
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/WorkFlowApi/GetActiveWorkFlow');
  }
  Post(workflow: any): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/WorkFlowApi/add', workflow, { headers: header, observe: 'response' });
  }
  Delete(workflow: WorkFlow) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/WorkFlowApi/activeordeactive', workflow, { headers: header, observe: 'response' });
  }
  Put(workflow: WorkFlow): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/WorkFlowApi/Update', workflow, { headers: header, observe: 'response' });
  }

}
