<script>
import {authenticatedRequest} from "@/components/session/authenticatedRequest.vue";
import {handleEconomicError} from "@/components/request/HandleEconomicError.vue";

/**
 * The Entra -> Config object
 */
export const Config = {
    get: async ( variable ) => {
      return authenticatedRequest(
          "/entra/config?variable=" + variable,
          "GET")
    },
    get_all: async () => {
      return authenticatedRequest(
          "/entra/config",
          "GET")
    },
    set: async ( variable, value ) => {
      return authenticatedRequest(
          "/entra/config",
          "POST",
          {
            variable: variable,
            value: value
          })
    },
    keys: {
      entra_client_id: {
        get: async () => {
          return Config.get("entra_client_id");
        },
        set: async (value) => {
          return Config.set("entra_client_id", value);
        },
      },
      entra_client_secret: {
        get: async () => {
          return Config.get("entra_client_secret");
        },
        set: async (value) => {
          return Config.set("entra_client_secret", value);
        },
      },
      entra_tenant_id: {
        get: async () => {
          return Config.get("entra_tenant_id");
        },
        set: async (value) => {
          return Config.set("entra_tenant_id", value);
        },
      },
    },
    enabled: {
      get: async () => {
        return Config.get("enabled");
      },
      set: async (enabled) => {
        return Config.set("enabled", enabled);
      },
  },
};

</script>