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

/**
 * The XLVask -> Config object
 */
export const Config = {
  get: async ( variable ) => {
    return authenticatedRequest(
        "/xlvask/config?variable=" + variable,
        "GET")
  },
  get_all: async () => {
    return authenticatedRequest(
        "/xlvask/config",
        "GET")
  },
  set: async ( variable, value ) => {
    return authenticatedRequest(
        "/xlvask/config",
        "POST",
        {
          variable: variable,
          value: value
        })
  },
  keys: {
    username: {
      get: async () => {
        return Config.get("username");
      },
      set: async (value) => {
        return Config.set("username", value);
      },
    },
    password: {
      get: async () => {
        return Config.get("password");
      },
      set: async (value) => {
        return Config.set("password", value);
      },
    },
  },
  enabled: {
    get: async () => {
      return Config.get("enabled");
    },
    set: async (enabled) => {
      return Config.set("enabled", enabled);
    },
  },
};
</script>