import {Injectable} from '@angular/core';

@Injectable()
export class RoomsService {

  smartTableData = [
    {
      Name: "93692657-f9c0-4a5e-a89f-f5058743b6c4",
      Description: "Bonusprint 2",
      Floor: 2,
      Sensors: [],
      Indicators: []
    },
    {
      Name: "93632657-f9c0-4a5e-a89f-f5058743b6c4",
      Description: "Bonusprint 1",
      Floor: 1,
      Sensors: [],
      Indicators: []
      const request = new XMLHttpRequest();

      request.responseType = "json";
      request.addEventListener("load", () => {
        resolve(request.response);
      });
      request.open("GET", `http://10.41.60.221/stahplight/api/v1/rooms`);
      request.send();
    });
  }

  static createRoom(data) {
    const request = new XMLHttpRequest();
    request.responseType = "json";
    request.open("POST", `http://10.41.60.221/stahplight/api/v1/rooms`);
    request.setRequestHeader('Content-Type', 'application/json');
    request.send(JSON.stringify(data));
  }

  static updateRoom(data) {
    const request = new XMLHttpRequest();
    request.responseType = "json";
    request.open("PUT", `http://10.41.60.221/stahplight/api/v1/rooms`);
    request.setRequestHeader('Content-Type', 'application/json');
    request.send(JSON.stringify(data));
  }

  static deleteRoom(data) {
    const request = new XMLHttpRequest();
    request.responseType = "json";
    request.open("DELETE", `http://10.41.60.221/stahplight/api/v1/rooms`);
    request.setRequestHeader('Content-Type', 'application/json');
    request.send(JSON.stringify(data));
  }
}
    }
  ];

  getData(): Promise<any> {
    return new Promise((resolve, reject) => {