package com.red.circle.other.adapter.app.qibla;

import com.red.circle.external.inner.endpoint.message.TrtcClient;
import com.red.circle.external.inner.model.cmd.message.AgoraRtcSigQryCmd;
import com.red.circle.framework.web.controller.BaseController;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 声网获取token
 *
 * @author zongpubin on 2023/11/29
 */
@Deprecated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/rtc/token", produces = MediaType.APPLICATION_JSON_VALUE)
public class RtcTokenRestController extends BaseController {

  private final TrtcClient trtcClient;

  /**
   * 获取声网token.
   */
  @GetMapping
  public String getToken(AgoraRtcSigQryCmd cmd) {
    return trtcClient.createAgoraToken(cmd.requiredReqUserId(), cmd.getChannelName()).getBody();
  }

}
