package com.sikey.wa04.api.message.client.rest;

import com.sikey.wa04.business.application.service.message.VideoCallMessageService;
import com.sikey.wa04.business.infrastructure.configuration.ProjectContextConstant;
import com.sikey.wa04.business.infrastructure.dto.request.messaging.VideoCallDialRequest;
import com.sikey.wa04.business.infrastructure.dto.request.messaging.VideoCallHangupRequest;
import com.sikey.wa04.common.BaseController;
import com.sikey.wa04.common.interceptor.Authenticated;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * 视频通话 API
 *
 * @author luoyangwei
 * @date 2024年11月05日15:11:32
 */
@RestController
@RequestMapping(ProjectContextConstant.MESSAGE_URL + "/messaging/publish/video-call")
public class VideoCallMessageController extends BaseController {

    @Resource
    private VideoCallMessageService videoCallMessageService;

    /**
     * 拨打视频通话
     *
     * @param request 请求
     * @return 响应
     */
    @Authenticated
    @PostMapping("/dial")
    public void dial(@Valid @RequestBody VideoCallDialRequest request) {
        request.setHeader(genericManufacturerHeader());
        videoCallMessageService.dial(request);
    }

    /**
     * 挂断视频电话
     *
     * @param request 请求
     * @return 响应
     */
    @Authenticated
    @PostMapping("/hangup")
    public void hangup(@Valid @RequestBody VideoCallHangupRequest request) {
        request.setHeader(genericManufacturerHeader());
        videoCallMessageService.hangup(request);
    }

}
