import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  ExtensionSmsPaymentListParams,
  ExtensionSmsPaymentListResponse
} from '../../model/sms-payment/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionSmsList = (params: ExtensionSmsPaymentListParams) => {
  return resultify(
    axios.post<ExtensionSmsPaymentListResponse>(API_URL_ADDITIONAL_SERVICE.extensionSmsList(), params),
  );
};

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

  return {
    ...mutation,
  };
};
