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

export const extensionAlimtalkSettingDetail = (params: ExtensionAlimtalkSettingDetailParams) => {
  return resultify(
    axios.post<ExtensionAlimtalkSettingDetailResponse>(API_URL_ADDITIONAL_SERVICE.extensionAlimtalkSettingDetail(), params),
  );
};

export const useExtensionAlimtalkSettingDetailMutation = (options?: UseMutationOptions<ExtensionAlimtalkSettingDetailResponse, CBDCAxiosError, ExtensionAlimtalkSettingDetailParams>) => {
  const mutation = useMutation<ExtensionAlimtalkSettingDetailResponse, CBDCAxiosError, ExtensionAlimtalkSettingDetailParams>({
    ...options,
    mutationFn: (params: ExtensionAlimtalkSettingDetailParams) => extensionAlimtalkSettingDetail(params),
  });

  return {
    ...mutation,
  };
};
