import axios from "@/config/axios";
import type {
  CreateShipmentMethodType,
  GetRestaurantShipmentMethodsResponseType,
  GetRestaurantShipmentMethodResponseType,
  GetRestaurantShipmentMethodsParams,
} from "../types/Types";

export const getRestaurantShipmentMethods = async (
  params?: GetRestaurantShipmentMethodsParams
): Promise<GetRestaurantShipmentMethodsResponseType> => {
  const { data } = await axios.get("/admin/delivery-methods/restaurant", {
    params,
  });
  return data;
};

export const createRestaurantShipmentMethod = async (
  params: CreateShipmentMethodType
) => {
  const { data } = await axios.post(
    "/admin/delivery-methods/restaurant",
    params
  );
  return data;
};

export const deleteRestaurantShipmentMethod = async (id: string) => {
  const { data } = await axios.delete(
    `/admin/delivery-methods/restaurant/${id}`
  );
  return data;
};

export const getRestaurantShipmentMethod = async (
  id: string
): Promise<GetRestaurantShipmentMethodResponseType> => {
  const { data } = await axios.get(`/admin/delivery-methods/restaurant/${id}`);
  return data;
};

export const updateRestaurantShipmentMethod = async (
  id: string,
  params: CreateShipmentMethodType
) => {
  const { data } = await axios.patch(
    `/admin/delivery-methods/restaurant/${id}`,
    params
  );
  return data;
};
