import { createCachedApi } from "./cacheService";

const api = createCachedApi("country");

export const getCountry = async (id) => {
  const { data } = await api.get("/country/" + id);
  return data.payload;
};

export const getCountries = async () => {
  const { data } = await api.get("/country");
  return data.payload;
};

export const createCountry = async (country) => {
  const data = await api.post("/country", country);
  return data.payload;
};

export const updateCountry = async (country, id) => {
  const data = await api.put(`/country/${id}`, country);
  return data.payload;
};

export const deleteCountry = async (id) => {
  const data = await api.del(`/country/${id}`);
  return data.payload;
};
