import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment';
import { WorkFlowDefinition } from './workflowconfiguration';
let header = new HttpHeaders();
header = header.set('Content-Type', 'application/json; charset=utf-8');
@Injectable({
  providedIn: 'root'
})
export class WorkflowconfigurationService {
  baseUrl: string = environment.serviceUrl;
  constructor(private httpClient: HttpClient) { }
  GetById(data: WorkFlowDefinition): Observable<any> {
    return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/GetById'
    , data, { observe: 'response' });
  }
  getsupplementtype(): Observable<any> {
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.get<any>(this.baseUrl +
      'api/SupplementTypeApi/GetAll', { headers: header, observe: 'response' });
  }
  Post(data: WorkFlowDefinition): Observable<any> {
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/WorkFlowConfigurationApi/add',
    data, { headers: header, observe: 'response' });
  }

  UpdateStageMovement(data: WorkFlowDefinition[]): Observable<any> {
    return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/UpdateStageMovement',
     data, { headers: header, observe: 'response' });
  }
  Delete(data: WorkFlowDefinition) {
    return this.httpClient.post(this.baseUrl + 'api/WorkFlowConfigurationApi/activeordeactive',
    data, { observe: 'response' });
  }
  getFlowChart(data: WorkFlowDefinition): Observable<any> {
    return this.httpClient.post(this.baseUrl + 'api/WorkFlowConfigurationApi/GetFlowChart',
    data, { headers: header, observe: 'response' });
    }
    UpdateStageOrder(data: WorkFlowDefinition[]): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/UpdateStageOrder',
      data, { headers: header, observe: 'response' });
    }

    PostStageConfig(workFlowDefinition: WorkFlowDefinition): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/PostStageConfig',
      workFlowDefinition, { headers: header, observe: 'response' });
    }

    UpdateInOutFile(workFlowDefinition: any): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/UpdateInOutFile',
      workFlowDefinition, { headers: header, observe: 'response' });
    }
    GetByWfdId(workFlowDefinition: WorkFlowDefinition): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/GetByWfdId'
      , workFlowDefinition, { observe: 'response' });
    }
    IOGetByWfdId(inoutfile: WorkFlowDefinition): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/IOGetByWfdId'
      , inoutfile, { observe: 'response' });
    }
    UpdateInOutFileOnEmpty(inoutfile: any): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/UpdateInOutFileOnEmpty',
      inoutfile, { headers: header, observe: 'response' });
    }
    UpdateStageMetaFields(data: WorkFlowDefinition): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/WorkFlowConfigurationApi/UpdateStageMetaFields',
       data, { headers: header, observe: 'response' });
    }

}
