import axios from 'axios';
import { API_URL_PAYMENT } from '@/shared/api/api-url-payment';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  PaymentNotificationDataParams,
  PaymentNotificationDataResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const paymentNotificationData = (params: PaymentNotificationDataParams) => {
  return resultify(
    axios.post<PaymentNotificationDataResponse>(API_URL_PAYMENT.paymentNotificationData(), params),
  );
};

export const usePaymentNotificationDataMutation = (options?: UseMutationOptions<PaymentNotificationDataResponse, CBDCAxiosError, PaymentNotificationDataParams>) => {
  const mutation = useMutation<PaymentNotificationDataResponse, CBDCAxiosError, PaymentNotificationDataParams>({
    ...options,
    mutationFn: (params: PaymentNotificationDataParams) => paymentNotificationData(params),
  });

  return {
    ...mutation,
  };
};