import { adminRequest } from "@/lib/admin-http";


import type {
  AdminCurrencyCreatePayload,
  AdminCurrencyDeleteResult,
  AdminCurrencyListData,
  AdminCurrencyRow,
  AdminCurrencyUpdatePayload,
} from "@/types/api/admin-currency";

const A = `/admin`;

export async function getAdminCurrencies(): Promise<AdminCurrencyListData> {
  return adminRequest.get<AdminCurrencyListData>(`${A}/currencies`);
}

export async function postAdminCurrency(body: AdminCurrencyCreatePayload): Promise<AdminCurrencyRow> {
  return adminRequest.post<AdminCurrencyRow>(`${A}/currencies`, body);
}

export async function putAdminCurrency(
  code: string,
  body: AdminCurrencyUpdatePayload,
): Promise<AdminCurrencyRow> {
  return adminRequest.put<AdminCurrencyRow>(`${A}/currencies/${encodeURIComponent(code)}`, body);
}

export async function deleteAdminCurrency(code: string): Promise<AdminCurrencyDeleteResult> {
  return adminRequest.delete<AdminCurrencyDeleteResult>(`${A}/currencies/${encodeURIComponent(code)}`);
}
