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

/**
 * The Backups -> Config object
 */
export const Config = {
    get: async ( variable ) => {
      return authenticatedRequest(
          "/backups/config?variable=" + variable,
          "GET")
    },
    get_all: async () => {
      return authenticatedRequest(
          "/backups/config",
          "GET")
    },
    set: async ( variable, value ) => {
      return authenticatedRequest(
          "/backups/config",
          "POST",
          {
            variable: variable,
            value: value
          })
    },
    keys: {
      examplevariable1: {
        get: async () => {
          return Config.get("example_var1")
        },
        set: async (value) => {
          return Config.set("example_var1", value);
        },
      },
    },
    enabled: {
      get: async () => {
        return Config.get("enabled");
      },
      set: async (enabled) => {
        return Config.set("enabled", enabled);
      },
  },
};

</script>