import { createCachedApi } from "./cacheService";

const api = createCachedApi("city");

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

export const getCities = async () => {
  const { data } = await api.get("/selects/cities");
  return data.payload;
};

export const getCityByState = async (stateId) => {
  const { data } = await api.get("/selects/cities", { params: { state_id: stateId } });
  return data.payload;
};

export const getCityByCountry = async (countryId) => {
  const { data } = await api.get("/selects/cities", { params: { country_id: countryId } });
  return data.payload;
};
