import { request } from '@/plugins/http-fetch';

/**
 * UDMVOIP用户重载数据
 * @param neId 网元ID
 * @returns object
 */
export function resetUDMVOIP(neId: string) {
  return request({
    url: `/neData/udm/voip/resetData/${neId}`,
    method: 'PUT',
    timeout: 180_000,
  });
}

/**
 * UDMVOIP用户列表
 * @param query 查询参数
 * @returns object
 */
export function listUDMVOIP(query: Record<string, any>) {
  return request({
    url: '/neData/udm/voip/list',
    method: 'GET',
    params: query,
    timeout: 30_000,
  });
}

/**
 * UDMVOIP用户信息
 * @param neId 网元ID
 * @param username username
 * @returns object
 */
export function getUDMVOIP(neId: string, username: string) {
  return request({
    url: `/neData/udm/voip/${neId}/${username}`,
    method: 'GET',
  });
}

/**
 * UDMVOIP用户新增
 * @param data VOIP对象
 * @returns object
 */
export function addUDMVOIP(
  neId: string,
  data: { username: string; password: string }
) {
  return request({
    url: `/neData/udm/voip/${neId}`,
    method: 'POST',
    data: data,
    timeout: 180_000,
  });
}

/**
 * UDMVOIP用户批量新增
 * @param data VOIP对象
 * @param num 数量
 * @returns object
 */
export function batchAddUDMVOIP(
  neId: string,
  data: { username: string; password: string },
  num: number
) {
  return request({
    url: `/neData/udm/voip/${neId}/${num}`,
    method: 'POST',
    data: data,
    timeout: 180_000,
  });
}

/**
 * UDMVOIP用户删除
 * @param data VOIP对象
 * @returns object
 */
export function delUDMVOIP(neId: string, username: string) {
  return request({
    url: `/neData/udm/voip/${neId}/${username}`,
    method: 'DELETE',
    timeout: 180_000,
  });
}

/**
 * UDMVOIP用户批量删除
 * @param neId 网元ID
 * @param username username
 * @param num 数量
 * @returns object
 */
export function batchDelUDMVOIP(neId: string, username: string, num: number) {
  return request({
    url: `/neData/udm/voip/${neId}/${username}/${num}`,
    method: 'DELETE',
    timeout: 180_000,
  });
}

/**
 * UDMVOIP用户导出
 * @param data 数据参数
 * @returns bolb
 */
export function exportUDMVOIP(data: Record<string, any>) {
  return request({
    url: '/neData/udm/voip/export',
    method: 'GET',
    params: data,
    responseType: 'blob',
    timeout: 180_000,
  });
}

/**
 * UDMVOIP用户导入
 * @param data 表单数据对象
 * @returns object
 */
export function importUDMVOIP(data: Record<string, any>) {
  return request({
    url: `/neData/udm/voip/import`,
    method: 'POST',
    data,
    timeout: 180_000,
  });
}
