import { DefaultResponse, Paginate, ParamsType, Country, City, Area } from "@/types/global";
import fetcher from "@/lib/fetcher";
import { buildUrlQueryParams } from "@/utils/build-url-query-params";

export const countryService = {
  getAll: (params?: ParamsType) =>
    fetcher<Paginate<Country>>(buildUrlQueryParams("v1/rest/countries", params)),
  get: (id: number, params?: ParamsType) =>
    fetcher<DefaultResponse<Country>>(buildUrlQueryParams(`v1/rest/countries/${id}`, params)),
};

export const cityService = {
  get: (id: number, params?: ParamsType) =>
    fetcher<DefaultResponse<City>>(buildUrlQueryParams(`v1/rest/cities/${id}`, params)),
};

export const areaService = {
  get: (id: number, params?: ParamsType) =>
    fetcher<DefaultResponse<Area>>(buildUrlQueryParams(`v1/rest/areas/${id}`, params)),
};
