<script>
import {authenticatedRequest} from "@/components/session/authenticatedRequest.vue";
import {handleEconomicError} from "@/components/request/HandleEconomicError.vue";
import { Config } from "@/components/session/token/superUser/modules/fxratesapi/Config.vue";

/**
 * The FXRatesAPI object
 */
export const FXRatesAPI = {
  meta: {
    title: "FXRatesAPI",
    icon: "fas fa-car",
    description: "FXRatesAPI, som bruges til at hente valutakurser",
    endpoint: "/modules/fxratesapi",
    config_endpoint: "/configuration/fxratesapi",
    labels: {
      single: "fxratesapi",
      multiple: "fxratesapi"
    }
  },
  config: Config,
  functions: {
    conversion_rate: async (base = 'DKK', target = 'EUR') => {
      return authenticatedRequest(
          "/modules/fxratesapi/rate",
          "GET",
          {
            base: base,
            target: target
          })
    },
    conversion_rates: async (base = 'DKK') => {
      return authenticatedRequest(
          "/modules/fxratesapi/rates",
          "GET",
          {
            base: base
          })
    },
  }
};

</script>