import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Pump } from 'src/app/models/pump';
import { Sensor } from 'src/app/models/sensor';
import { SensorPump } from 'src/app/models/sensorPump';
import { environment } from 'src/environments/environment';

@Injectable({
  providedIn: 'root'
})
export class WerfFormThreeService {
  url = environment.url;

  constructor(private httpClient: HttpClient) { }

  getPumps(): Observable<Pump[]> {
    return this.httpClient.get<Pump[]>(this.url + '/Pump/getPumps');
  }

  getSensors(): Observable<Sensor[]> {
    return this.httpClient.get<Sensor[]>(this.url + '/Sensor/getSensors');
  }

  postSensorPump(sensorPump: SensorPump): Observable<SensorPump> {
    let headers = new HttpHeaders();
    headers = headers.set('Content-Type', 'application/json; charset=utf-8');

    return this.httpClient.post<SensorPump>(this.url + '/SensorPump/addSensorPumps', sensorPump, {headers: headers});
  }
}
