import {
  APIUrlGenerator,
  httpDeleteRequest,
  httpGetRequest,
} from "@/utils/baseHttpService";
import { API_ROUTES } from "@/constant/routes";
import {
  ContactUsFilters,
  ContactUsListResponse,
  DeleteContactUsResponse,
} from "./_models";

export const getContactUsMessages = async (filters?: ContactUsFilters) => {
  const limitValue = filters?.limit ?? 20;
  const queryParams: Record<string, string | number | null> = {
    limit: limitValue,
    offset: filters?.offset ?? 0,
  };

  const response = await httpGetRequest<ContactUsListResponse>(
    APIUrlGenerator(API_ROUTES.GET_CONTACT_US_MESSAGES, queryParams)
  );
  return response.data;
};

export const deleteContactUsMessage = async (id: string | number) => {
  const response = await httpDeleteRequest<DeleteContactUsResponse>(
    APIUrlGenerator(API_ROUTES.DELETE_CONTACT_US_MESSAGE(id.toString()))
  );
  return response.data;
};
