import { apiClient, getDataOrThrow } from "@/lib/api";
import { FALLBACK_CURRENCY, type WhmcsCurrency } from "@customer-portal/domain/billing";

export { FALLBACK_CURRENCY };

export const currencyService = {
  async getDefaultCurrency(): Promise<WhmcsCurrency> {
    const response = await apiClient.GET<WhmcsCurrency>("/api/currency/default");
    return getDataOrThrow(response, "Failed to get default currency");
  },

  async getAllCurrencies(): Promise<WhmcsCurrency[]> {
    const response = await apiClient.GET<WhmcsCurrency[]>("/api/currency/all");
    return getDataOrThrow(response, "Failed to get currencies");
  },
};
