import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
// import { BehaviorSubject } from 'rxjs';
import { HousePoints } from './HousePoints';
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'application/json'
  })
};

@Injectable({
  providedIn: 'root'
})
export class HousePointsRemoteService {

  url : string;

  constructor(private http: HttpClient) {
    this.url = "https://api.myjson.com/bins/l1mki";
   }

  getPoints$(): Observable<HousePoints>  {
    return this.http.get<HousePoints>(this.url);
  }

  updatePoints$(points: HousePoints): Observable<HousePoints>  {
    return this.http.put<HousePoints>(this.url, points, httpOptions);
  }
}
