using Hotline.CallCenter.Configs;
using Hotline.CallCenter.Tels;
using Hotline.Share.Dtos.CallCenter;
using Hotline.Share.Enums.CallCenter;

namespace Hotline.CallCenter.Devices
{
    public interface INewRockDeviceManager
    {
        #region 查询

        /// <summary>
        /// 查询分机
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<TelDto> QueryTelAsync(NewRockConfiguration newRockConfiguration, string TelNo, CancellationToken cancellationToken);

        /// <summary>
        /// 查询分机状态
        /// </summary>
        /// <param name="TelNo"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<ETelStatus> QueryTelState(NewRockConfiguration newRockConfiguration, string TelNo, CancellationToken cancellationToken);

        /// <summary>
        /// 查询所有分机
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<List<Tel>> QueryTelsAsync(NewRockConfiguration newRockConfiguration, CancellationToken cancellationToken);

        /// <summary>
        /// 查询所有分机组
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<List<TelGroup>> QueryTelGroupsAsync(NewRockConfiguration newRockConfiguration, CancellationToken cancellationToken);

        /// <summary>
        /// 查询语音文件
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<string> VoiceQueryListAsync(NewRockConfiguration newRockConfiguration, CancellationToken cancellationToken);
        #endregion

        #region 配置

        /// <summary>
        /// 分机休息
        /// </summary>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task TelRestAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 分机结束休息
        /// </summary>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task TelEndRestAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);


        /// <summary>
        /// 上班/下班
        /// </summary>
        /// <param name="telNo"></param>
        /// <param name="staffNo"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task UpdateStaffNoAsync(NewRockConfiguration newRockConfiguration, string telNo, string staffNo, string lineId, CancellationToken cancellationToken);

        /// <summary>
        /// 删除语音文件
        /// </summary>
        /// <param name="voiceName"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task RemoveVoiceFileAsync(NewRockConfiguration newRockConfiguration, string voiceName, CancellationToken cancellationToken);

        /// <summary>
        /// 配置语音菜单
        /// </summary>
        /// <param name="menuId"></param>
        /// <param name="voiceFile"></param>
        /// <param name="repeat"></param>
        /// <param name="infoLength"></param>
        /// <param name="exit"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task AssginConfigMenuAsync(NewRockConfiguration newRockConfiguration, string menuId, string voiceFile, string repeat, string infoLength, string exit,
            CancellationToken cancellationToken);

        /// <summary>
        /// 配置分机组
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="voiceFile"></param>
        /// <param name="distribution"></param>
        /// <param name="ext"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task AssginConfigGroupAsync(NewRockConfiguration newRockConfiguration, string groupId, EDistribution distribution, List<string> ext, string? voiceFile = "", CancellationToken cancellationToken = default);

        /// <summary>
        /// 更新分机组
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="ext"></param>
        /// <param name="cancellationToken"></param>
        /// <param name="isAdd"></param>
        /// <returns></returns>
        Task ModifyGroupExtAsync(NewRockConfiguration newRockConfiguration, string groupId, EDistribution distribution, string voicefile = "", string extId = "", bool isAdd = true, CancellationToken cancellationToken = default);
        #endregion

        #region 通话控制

        /// <summary>
        /// 保持通话
        /// </summary>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task HoldAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 恢复通话(解除hold状态)
        /// </summary>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task UnHoldAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 开启静音
        /// </summary>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task MuteAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 解除静音命令
        /// </summary>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task UnMuteAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 强拆分机
        /// </summary>
        /// <param name="extId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task ClearExtAsync(NewRockConfiguration newRockConfiguration, string extId, CancellationToken cancellationToken);

        /// <summary>
        /// 强拆来电
        /// </summary>
        /// <param name="visitorId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task ClearVisitorAsync(NewRockConfiguration newRockConfiguration, string visitorId, CancellationToken cancellationToken);

        /// <summary>
        /// 强拆去电
        /// </summary>
        /// <param name="outerId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task ClearOuterAsync(NewRockConfiguration newRockConfiguration, string outerId, CancellationToken cancellationToken);

        /// <summary>
        /// 来电受理
        /// </summary>
        /// <param name="visitorId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task AcceptVisitorAsync(NewRockConfiguration newRockConfiguration, string visitorId, CancellationToken cancellationToken);
        #endregion

        #region 连接/呼叫

        /// <summary>
        /// 分机呼分机
        /// </summary>
        /// <param name="from">主叫分机号</param>
        /// <param name="to">被叫分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task ExtToExtAsync(NewRockConfiguration newRockConfiguration, string from, string to, CancellationToken cancellationToken);

        /// <summary>
        /// 分机呼外部电话
        /// </summary>
        /// <param name="from">分机号</param>
        /// <param name="to">外部电话，外地电话加拨0</param>
        /// <param name="cancellationToken"></param>
        /// <param name="trunkid">指定中继线路（可为空），为空时默认由OM分配</param>
        /// <returns></returns>
        Task ExtToOuterAsync(NewRockConfiguration newRockConfiguration, string from, string to, CancellationToken cancellationToken, string trunkid = "");

        /// <summary>
        /// 来电转分机
        /// </summary>
        /// <param name="visitorId">来电会话ID</param>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VisitorToExtAsync(NewRockConfiguration newRockConfiguration, string visitorId, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 来电转外部电话
        /// </summary>
        /// <param name="visitorId">来电会话ID</param>
        /// <param name="outerPhoneNum">外部电话，外地电话加拨0</param>
        /// <param name="cancellationToken"></param>
        /// <param name="display">来电号码，用来透传主叫号码，使去电方的来电显示号码为实际来电号码。</param>
        /// <returns></returns>
        Task VisitorToOuterAsync(NewRockConfiguration newRockConfiguration, string visitorId, string outerPhoneNum, CancellationToken cancellationToken,
            string display = "");

        /// <summary>
        /// 来电转语音菜单
        /// </summary>
        /// <param name="visitorId">来电会话ID</param>
        /// <param name="menuId">菜单ID</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VisitorToMenuAsync(NewRockConfiguration newRockConfiguration, string visitorId, string menuId, CancellationToken cancellationToken);

        /// <summary>
        /// 来电转分机组
        /// </summary>
        /// <param name="visitorId"></param>
        /// <param name="groupId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VisitorToGroupAsync(NewRockConfiguration newRockConfiguration, string visitorId, string groupId, CancellationToken cancellationToken);

        /// <summary>
        /// 去电转分机
        /// </summary>
        /// <param name="outerId">去电会话ID</param>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task OuterToExtAsync(NewRockConfiguration newRockConfiguration, string outerId, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 去电转外部电话
        /// </summary>
        /// <param name="outerId">去电会话ID</param>
        /// <param name="outerPhoneNum">外部电话，外地电话加拨0</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task OuterToOuterAsync(NewRockConfiguration newRockConfiguration, string outerId, string outerPhoneNum, CancellationToken cancellationToken);

        /// <summary>
        /// 语音菜单呼叫分机
        /// </summary>
        /// <param name="menuId">语音菜单ID</param>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task MenuToExtAsync(NewRockConfiguration newRockConfiguration, string menuId, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 语音菜单呼外部电话
        /// </summary>
        /// <param name="menuId">语音菜单ID</param>
        /// <param name="outerPhoneNum">外部电话，外地电话加拨0</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task MenuToOuterAsync(NewRockConfiguration newRockConfiguration, string menuId, string outerPhoneNum, CancellationToken cancellationToken);

        /// <summary>
        /// 双向呼叫（回拨）
        /// </summary>
        /// <param name="outerOne">主叫外部电话，外地电话加拨0</param>
        /// <param name="outerTwo">被叫外部电话，外地电话加拨0</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task TwoWayOuterAsync(NewRockConfiguration newRockConfiguration, string outerOne, string outerTwo, CancellationToken cancellationToken);

        /// <summary>
        /// 语音插播（分机）
        /// </summary>
        /// <param name="voiceFileName">语音名称</param>
        /// <param name="telNo">分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VoiceNewsFlashExtAsync(NewRockConfiguration newRockConfiguration, string voiceFileName, string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 语音插播（来电）
        /// </summary>
        /// <param name="voiceFileName">语音名称</param>
        /// <param name="visitorId">来电会话ID</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VoiceNewsFlashVisitorAsync(NewRockConfiguration newRockConfiguration, string voiceFileName, string visitorId, CancellationToken cancellationToken);

        /// <summary>
        /// 语音插播（去电）
        /// </summary>
        /// <param name="voiceFileName">语音名称</param>
        /// <param name="outerId">去电会话ID</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task VoiceNewsFlashOuterAsync(NewRockConfiguration newRockConfiguration, string voiceFileName, string outerId, CancellationToken cancellationToken);

        /// <summary>
        /// 会议
        /// </summary>
        /// <param name="telNo">发起方分机号</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task ConferenceMeetingAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);

        #endregion

        #region 监听和插播

        /// <summary>
        /// 监听分机
        /// </summary>
        /// <param name="firstTelNo">监听方</param>
        /// <param name="secondTelNo">被监听方</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task MonitorExtAsync(NewRockConfiguration newRockConfiguration, string firstTelNo, string secondTelNo, CancellationToken cancellationToken);


        /// <summary>
        /// 从监听到插播状态变换
        /// 1. 已知：分机 A 在监听分机 B 与其通话方的通话；
        /// 2. 执行分机 A 的从监听到插播状态变换的 API；
        /// 3. 执行成功时，分机 A 与分机 B 建立通话，分机 B 的原通话方听保持音。
        /// </summary>
        /// <param name="telNo"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task MonitorExtToTalkAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);


        /// <summary>
        /// 从插播到监听状态变换
        /// 1. 已知：分机 A 在插播分机 B 的通话；
        /// 2. 执行分机 A 的从插播到监听状态变换的 API；
        /// 3. 执行成功时，分机 A 监听分机 B 及其原通话方的通话。
        /// </summary>
        /// <param name="telNo"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task MonitorExtToListenAsync(NewRockConfiguration newRockConfiguration, string telNo, CancellationToken cancellationToken);


        #endregion

        #region 强插

        /// <summary>
        /// 强插
        /// 1. 已知：分机 A 当前空闲，分机 B 正在通话中；
        /// 2. 执行分机 A 强插分机 B 的 API；
        /// 3. 执行成功时，分机 A 振铃，摘机后即可形成三方通话。
        /// </summary>
        /// <param name="firstTelNo"></param>
        /// <param name="secondTelNo"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task BargeinExtAsync(NewRockConfiguration newRockConfiguration, string firstTelNo, string secondTelNo, CancellationToken cancellationToken);

        #endregion
    }
}
