release: v0.6.1
This commit is contained in:
commit
877eef7f07
118 files changed
+46315
No files matched your search
@@ -0,0 +1,60 @@
|
||||
package call_handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
call_service "github.com/EvolutionAPI/evolution-go/pkg/call/service"
|
||||
instance_model "github.com/EvolutionAPI/evolution-go/pkg/instance/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type CallHandler interface {
|
||||
RejectCall(ctx *gin.Context)
|
||||
}
|
||||
|
||||
type callHandler struct {
|
||||
callService call_service.CallService
|
||||
}
|
||||
|
||||
// Reject call
|
||||
// @Summary Reject call
|
||||
// @Description Reject call
|
||||
// @Tags Call
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param message body call_service.RejectCallStruct true "Call data"
|
||||
// @Success 200 {object} gin.H "success"
|
||||
// @Failure 500 {object} gin.H "Internal server error"
|
||||
// @Router /call/reject [post]
|
||||
func (g *callHandler) RejectCall(ctx *gin.Context) {
|
||||
getInstance := ctx.MustGet("instance")
|
||||
|
||||
instance, ok := getInstance.(*instance_model.Instance)
|
||||
if !ok {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "instance not found"})
|
||||
return
|
||||
}
|
||||
|
||||
var data *call_service.RejectCallStruct
|
||||
err := ctx.ShouldBindBodyWithJSON(&data)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
err = g.callService.RejectCall(data, instance)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, gin.H{"message": "success"})
|
||||
}
|
||||
|
||||
func NewCallHandler(
|
||||
callService call_service.CallService,
|
||||
) CallHandler {
|
||||
return &callHandler{
|
||||
callService: callService,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user