import { generateNestParams, handleError, handleSuccess } from '.';
import axios from '../lib/axios';

const BASE_URL = 'send-message-histories';

export const getSendMessageHistories = async (params: Record<string, string | number>) => {
    return await axios({
        url: BASE_URL,
        params: generateNestParams(params),
        withCredentials: true,
        method: 'GET',
    });
};

export const sendMessageHistoryTest = async () => {
    try {
        const { data } = await axios({
            url: `${BASE_URL}/send-test`,
            withCredentials: true,
            method: 'POST',
        });

        handleSuccess(data);

        return data;
    } catch (error) {
        handleError(error);
    }
};
