import { apiGet, apiPost } from "../client";

export const areasApi = {
  list(options) {
    return apiGet("/api/v1/areas/list", options);
  },

  innerList(areaId, options) {
    return apiGet(`/api/v1/areas/id/${encodeURIComponent(String(areaId))}/list`, options);
  },

  newArea(payload) {
    return apiPost("/api/v1/areas/new-area", payload);
  },

  remove(areaId) {
    return apiGet(`/api/v1/areas/id/${encodeURIComponent(String(areaId))}/remove`);
  },

  devices(areaId, options) {
    return apiGet(`/api/v1/areas/id/${encodeURIComponent(String(areaId))}/devices`, options);
  },

  scripts(areaId, options) {
    return apiGet(`/api/v1/areas/id/${encodeURIComponent(String(areaId))}/scripts`, options);
  },

  updateDisplayName(payload) {
    return apiPost("/api/v1/areas/update-display-name", payload);
  },

  updateAlias(payload) {
    return apiPost("/api/v1/areas/update-alias", payload);
  },

  placeInArea(payload) {
    return apiPost("/api/v1/areas/place-in-area", payload);
  },

  unassign(areaId) {
    return apiGet(`/api/v1/areas/id/${encodeURIComponent(String(areaId))}/unassign-from-area`);
  },
};
