import {
    DeliveryOrderReq,
    HdWRDealOrderReq,
    HdWROrderReq, PaymentArrearsReq, WarehouseRepurchaseReq, WrBargainNoAgreeReq,
    WRListingCancelOrderReq, WROutApplyCancelReq,
    WROutApplyReq, WROutCancelReq, WROutConfirmReq, WRTradeFinanceBuyCancelReq
} from "@/services/proto/warehousetrade/interface";
import { protoMiddleware } from "@/services/socket/protobuf/buildReq";
import { HeadEnum } from "@/services/socket/protobuf/protoHeader";


/**
 * 持仓单挂牌请求
 * @param param
 */
export const hdWROrder = (param: HdWROrderReq): Promise<any> => {
    return protoMiddleware<HdWROrderReq>(param, 'HdWROrderReq', 'HdWROrderRsp', HeadEnum.tradeMode17)
}

/**
 * 持仓单摘牌请求
 *
 * @param param
 * @constructor
 */
export const HdWRDealOrder = (param: HdWRDealOrderReq): Promise<any> => {
    return protoMiddleware<HdWRDealOrderReq>(param, 'HdWRDealOrderReq', 'HdWRDealOrderRsp', HeadEnum.tradeMode17)
}

/**
 * 出入库请求
 * @param param
 */
export const wROutApply = (param: WROutApplyReq): Promise<any> => {
    return protoMiddleware<WROutApplyReq>(param, 'WROutApplyReq', 'WROutApplyRsp', HeadEnum.tradeMode17)
}

/**
 * 挂牌撤单请求
 * @param param
 */
export const wRListingCancelOrder = (param: WRListingCancelOrderReq): Promise<any> => {
    return protoMiddleware<WRListingCancelOrderReq>(param, 'WRListingCancelOrderReq', 'WRListingCancelOrderRsp', HeadEnum.tradeMode17)
}


//  融资相关

/**
 * 仓单回购请求
 * @param param
 */
export const WarehouseRepurchase = (param: WarehouseRepurchaseReq): Promise<any> => {
    return protoMiddleware<WarehouseRepurchaseReq>(param, 'WarehouseRepurchaseReq', 'WarehouseRepurchaseRsp', HeadEnum.MarketID45201)
}


/**
 * 支付欠款请求
 * @param param
 */
export const PaymentArrears = (param: PaymentArrearsReq): Promise<any> => {
    return protoMiddleware<PaymentArrearsReq>(param, 'PaymentArrearsReq', 'PaymentArrearsRsp', HeadEnum.MarketID45201)
}


/**
 * 挂牌撤单请求
 * @param param
 */
export const WRTradeFinanceBuyCancel = (param: WRTradeFinanceBuyCancelReq): Promise<any> => {
    return protoMiddleware<WRTradeFinanceBuyCancelReq>(param, 'WRTradeFinanceBuyCancelReq', 'WRTradeFinanceBuyCancelRsp', HeadEnum.tradeMode17)
}

/**
 * 仓单出入库注销请求
 * @deprecated 该接口废弃
 * @param param
 */
export const WROutApplyCancel = (param: WROutApplyCancelReq): Promise<any> => {
    return protoMiddleware<WROutApplyCancelReq>(param, 'WROutApplyCancelReq', 'WROutApplyCancelRsp', HeadEnum.tradeMode17)
}

/**
 * 仓单出库确认请求
 * @param param
 * @constructor
 */
export const WROutConfirm = (param: WROutConfirmReq): Promise<any> => {
    return protoMiddleware<WROutConfirmReq>(param, 'WROutConfirmReq', 'WROutConfirmRsp', HeadEnum.tradeMode17)
}

/**
 * 仓单出库撤回请求
 * @param param
 * @constructor
 */
export const WROutCancel = (param: WROutCancelReq): Promise<any> => {
    return protoMiddleware<WROutCancelReq>(param, 'WROutCancelReq', 'WROutCancelRsp', HeadEnum.tradeMode17)
}

/**
 * 交割申报请求 0 6 1  (交收)
 * @param param
 * @constructor
 */
export const DeliveryOrder = (param: DeliveryOrderReq): Promise<any> =>{
    return protoMiddleware<DeliveryOrderReq>(param, 'DeliveryOrderReq', 'DeliveryOrderRsp', HeadEnum.tradeMode17)
}

/**
 * 议价申请拒绝请求
 * @param param
 * @constructor
 */
export const WrBargainNoAgree = (param: WrBargainNoAgreeReq): Promise<any> =>{
    return protoMiddleware<WrBargainNoAgreeReq>(param, 'WrBargainNoAgreeReq', 'WrBargainNoAgreeRsp', HeadEnum.tradeMode17)
}