41 lines
745 B
Go
41 lines
745 B
Go
package endpoints
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"relynolli-server/models"
|
|
"relynolli-server/services"
|
|
)
|
|
|
|
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, models.Response{Status: http.StatusBadRequest,
|
|
Info: fmt.Sprintf("Error: %s", err.Error())})
|
|
}
|
|
|
|
services.YookassaValidate(req.Object.Id, req.Object.Status)
|
|
|
|
}
|
|
|
|
type Handlers interface {
|
|
Validate(c *gin.Context)
|
|
}
|
|
|
|
func GetHandlers() Handlers {
|
|
return &handlers{}
|
|
}
|