import { Injectable } from "@angular/core"; import { HttpClient, HttpHeaders } from "@angular/common/http"; import { Observable } from "rxjs"; @Injectable({ providedIn: "root", }) export class BuildingService { constructor(private http: HttpClient) {} postLogin(data: any): Observable { const url = `https://kapi.absys.ninja/hemat/users/login`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.post(url, data, { headers }); } listBuilding(): Observable { const url = `https://kapi.absys.ninja/hemat/building/dashboard/list`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getBuildingData(page: number = 1, limit: number = 10): Observable { const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`; // const headers = new HttpHeaders().set('Content-Type', 'application/json'); const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getRoomByBuildingId(buildingId: any): Observable { const url = `https://kapi.absys.ninja/hemat/room-building/list/byIds?buildingId=${buildingId}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getDeviceData(page: number = 1, limit: number = 10): Observable { const url = `https://kapi.absys.ninja/hemat/devices?page=${page}&limit=${limit}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getSyncDeviceData(page: number = 1, limit: number = 10): Observable { const url = `https://kapi.absys.ninja/hemat/devices/Synchronization`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getDeviceById(deviceId: any): Observable { const url = `https://kapi.absys.ninja/hemat/devices/${deviceId}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getMasterData(page: number = 1, limit: number = 10): Observable { const url = `https://kapi.absys.ninja/hemat/header-param?page=${page}&limit=${limit}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getMasterBuildingData(page: number = 1, limit: number = 100): Observable { const url = `https://kapi.absys.ninja/hemat/building?page=${page}&limit=${limit}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } getMasterRoomData(page: number = 1, limit: number = 100): Observable { const url = `https://kapi.absys.ninja/hemat/room?page=${page}&limit=${limit}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.get(url, { headers }); } postHeaderDetailParam(data: any): Observable { const url = `https://kapi.absys.ninja/hemat/header-detail-param`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.post(url, data, { headers }); } putHeaderDetailParam(data: any, id: any): Observable { const url = `https://kapi.absys.ninja/hemat/header-detail-param/${id}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.put(url, data, { headers }); } deleteHeaderDetailParam(id: any): Observable { const url = `https://kapi.absys.ninja/hemat/header-detail-param/${id}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.delete(url, { headers }); } postMasterBuildingParam(data: any): Observable { const url = `https://kapi.absys.ninja/hemat/building`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.post(url, data, { headers }); } putMasterBuildingParam(data: any, id: any): Observable { const url = `https://kapi.absys.ninja/hemat/building/${id}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.put(url, data, { headers }); } postMasterRoomParam(data: any): Observable { const url = `https://kapi.absys.ninja/hemat/room`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.post(url, data, { headers }); } putMasterRoomParam(data: any, id: any): Observable { const url = `https://kapi.absys.ninja/hemat/room/${id}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json', 'x-api-key': 'j2yaYvPSQcsEEmHh3NEobfiXyyXmmnHT' }); return this.http.put(url, data, { headers }); } }