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

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

</script>