import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Statistics } from './statistics'; import { Observable } from 'rxjs'; import { Aggregate } from './aggregate'; @Injectable({ providedIn: 'root' }) export class RestService { constructor(private http: HttpClient) { } getStatistics(): Observable { return this.http.get('https://vz.home.peper.info/rest-vz/stats?houseId=1&duration=P7D'); } getLatestData(houseId: Number, duration: Number): Observable { return this.http.get('https://vz.home.peper.info/rest-vz/latest-data', { params: { houseId: houseId + '', timeWindow: duration + '', } }); } getStatsFromTimeframe(houseId: number, start: Date, end: Date) : Observable { return this.http.get('https://vz.home.peper.info/rest-vz/stats', { params: { houseId: houseId + '', timestampStart: start.getTime() + '', timestampEnd: end.getTime() + '', } }); } getStatisticsWithDuration(duration: string | undefined, houseId: Number): Observable { if (duration) { return this.http.get('https://vz.home.peper.info/rest-vz/stats', { params: { houseId: houseId + '', duration: duration, } }); } else { return this.http.get('https://vz.home.peper.info/rest-vz/stats', { params: { houseId: houseId + '', } }); } } }