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

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

</script>