relynolli-server/handlers/validate/endpoints/validate.go

39 lines
616 B
Go

package endpoints
import (
"net/http"
"relynolli-server/services"
"github.com/gin-gonic/gin"
)
type handlers struct{}
type ValidateReq struct {
Type string `json:"type"`
Event string `json:"event"`
Object struct {
Id string `json:"id"`
Status string `json:"status"`
}
}
func (_ handlers) Validate(c *gin.Context) {
req := ValidateReq{}
err := c.ShouldBindJSON(&req)
if err != nil {
c.JSON(http.StatusBadRequest)
}
services.YookassaValidate(req.Object.Id, req.Object.Status)
}
type Handlers interface {
Validate(c *gin.Context)
}
func GetHandlers() Handlers {
return &handlers{}
}