import { Injectable } from '@angular/core';
import { DynaDataService } from '@xdf/gallery';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class AgentService extends DynaDataService {

  serviceURL = './service/agent';

  constructor(private httpClient: HttpClient) {
    super(httpClient);
  }

  isExternalSystemWithDeliverableConnection() {
    return this.httpClient.get(this.serviceURL + '/isExternalSystemWithDeliverableConnection');
  }

  existEntityTableWithTableName(tablename: string) {
    return this.httpClient.get(this.serviceURL + '/existEntityTableWithTableName', {
      params: {
        tablename: tablename
      }
    });
  }

  getDataForWizard(agentId: number) {
    let params = {};

    if (agentId) {
      params = {
        id: agentId
      };
    }
    return this.httpClient.get(this.serviceURL + '/connection/data', {
      params: params
    });
  }

  validateQuartz(value: string) {
    return this.httpClient.get(this.serviceURL + '/connection/validate/quartz?param=' + value);
  } 

}
