import axios from 'axios';
import { API_URL } from '@/shared/api/urls';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  ExtensionSmsListParams,
  ExtensionSmsListResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionSmsList = (params: ExtensionSmsListParams) => {
  return resultify(
    axios.post<ExtensionSmsListResponse>(API_URL.extensionSmsList(), params),
  );
};

export const useExtensionSmsListMutation = (options?: UseMutationOptions<ExtensionSmsListResponse, CBDCAxiosError, ExtensionSmsListParams>) => {
  const mutation = useMutation<ExtensionSmsListResponse, CBDCAxiosError, ExtensionSmsListParams>({
    ...options,
    mutationFn: (params: ExtensionSmsListParams) => extensionSmsList(params),
  });

  return {
    ...mutation,
  };
};
