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);
  }
  getDataForWizard(agentId: number) {
    let params = {};

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

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

  upload(formData) {
    return this.httpClient.post<any>(this.serviceURL + '/file-upload', formData, {
      reportProgress: true,
      observe: 'events'
    });
  }

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

  synchronize(id: number) {
    return this.httpClient.get(this.serviceURL + '/synchronize/' + id);
  }

}
