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

/**
 * The GatewayAPI -> Config object
 */
export const Config = {
    get: async ( variable ) => {
      return authenticatedRequest(
          "/gatewayapi/config?variable=" + variable,
          "GET")
    },
    get_all: async () => {
      return authenticatedRequest(
          "/gatewayapi/config",
          "GET")
    },
    set: async ( variable, value ) => {
      return authenticatedRequest(
          "/gatewayapi/config",
          "POST",
          {
            variable: variable,
            value: value
          })
    },
    keys: {
      api_secret: {
        get: async () => {
          return Config.get("api_secret");
        },
        set: async (value) => {
          return Config.set("api_secret", value);
        },
      },
      api_key: {
        get: async () => {
          return Config.get("api_key");
        },
        set: async (value) => {
          return Config.set("api_key", value);
        },
      },
      api_token: {
        get: async () => {
          return Config.get("api_token");
        },
        set: async (value) => {
          return Config.set("api_token", value);
        },
      },
      sender: {
        get: async () => {
          return Config.get("sender");
        },
        set: async (value) => {
          return Config.set("sender", value);
        },
      },
    },
    enabled: {
      get: async () => {
        return Config.get("enabled");
      },
      set: async (enabled) => {
        return Config.set("enabled", enabled);
      },
  },
};

</script>