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 { 
  ExtensionAlimtalkDetailParams,
  ExtensionAlimtalkDetailResponse
} from '../../model/alimtalk/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionAlimtalkDetail = (params: ExtensionAlimtalkDetailParams) => {
  return resultify(
    axios.post<ExtensionAlimtalkDetailResponse>(API_URL_ADDITIONAL_SERVICE.extensionArsDetail(), params),
  );
};

export const useExtensionAlimtalkDetailMutation = (options?: UseMutationOptions<ExtensionAlimtalkDetailResponse, CBDCAxiosError, ExtensionAlimtalkDetailParams>) => {
  const mutation = useMutation<ExtensionAlimtalkDetailResponse, CBDCAxiosError, ExtensionAlimtalkDetailParams>({
    ...options,
    mutationFn: (params: ExtensionAlimtalkDetailParams) => extensionAlimtalkDetail(params),
  });

  return {
    ...mutation,
  };
};
