import axios from "@/config/axios";
import type {
  CreateRestaurantPaymentMethodType,
  GetRestaurantPaymentMethodsParams,
  RestaurantPaymentMethodResponse,
  RestaurantPaymentMethodsResponse,
} from "../types/Types";

export const getRestaurantPaymentMethods = async (
  params?: GetRestaurantPaymentMethodsParams
): Promise<RestaurantPaymentMethodsResponse> => {
  const { data } = await axios.get<RestaurantPaymentMethodsResponse>(
    "/admin/payments/methods",
    { params }
  );
  return data;
};

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

export const createRestaurantPaymentMethod = async (
  params: CreateRestaurantPaymentMethodType
) => {
  const { data } = await axios.post("/admin/payments/methods", params);
  return data;
};

export const getRestaurantPaymentMethod = async (
  id: string
): Promise<RestaurantPaymentMethodResponse> => {
  const { data } = await axios.get<RestaurantPaymentMethodResponse>(
    `/admin/payments/methods/${id}`
  );
  return data;
};

export const updateRestaurantPaymentMethod = async (
  id: string,
  params: CreateRestaurantPaymentMethodType
) => {
  const { data } = await axios.patch(`/admin/payments/methods/${id}`, params);
  return data;
};
