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

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

</script>