veli games bet response struct fix

This commit is contained in:
Yared Yemane 2025-11-15 12:06:27 +03:00
parent e8c2213d30
commit fe7d9ad3b3

View File

@ -6,6 +6,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
@ -344,17 +345,17 @@ func (h *Handler) HandleBet(c *fiber.Ctx) error {
res, err := h.veliVirtualGameSvc.ProcessBet(c.Context(), req)
if err != nil {
if errors.Is(err, veli.ErrDuplicateTransaction) {
if strings.Contains(err.Error(), veli.ErrDuplicateTransaction.Error()) {
return c.Status(fiber.StatusConflict).JSON(domain.ErrorResponse{
// Message: "Duplicate transaction",
Error: veli.ErrDuplicateTransaction.Error(),
})
} else if errors.Is(err, veli.ErrInsufficientBalance) {
} else if strings.Contains(err.Error(), veli.ErrInsufficientBalance.Error()) {
return c.Status(fiber.StatusConflict).JSON(domain.ErrorResponse{
// Message: "Wallet balance is insufficient",
Error: veli.ErrInsufficientBalance.Error(),
})
} else if errors.Is(err, veli.ErrPlayerNotFound) {
} else if strings.Contains(err.Error(), veli.ErrPlayerNotFound.Error()) {
return c.Status(fiber.StatusConflict).JSON(domain.ErrorResponse{
// Message: "User not found",
Error: veli.ErrPlayerNotFound.Error(),
@ -439,7 +440,7 @@ func (h *Handler) HandleBet(c *fiber.Ctx) error {
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
// @Failure 409 {object} domain.ErrorResponse "Duplicate transaction"
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
// @Router /api/v1/win [post]
// @Router /win [post]
func (h *Handler) HandleWin(c *fiber.Ctx) error {
// Read the raw body to avoid parsing issues
body := c.Body()
@ -548,12 +549,12 @@ func (h *Handler) HandleCancel(c *fiber.Ctx) error {
res, err := h.veliVirtualGameSvc.ProcessCancel(c.Context(), req)
if err != nil {
if errors.Is(err, veli.ErrDuplicateTransaction) {
if strings.Contains(err.Error(), veli.ErrDuplicateTransaction.Error()) {
return c.Status(fiber.StatusConflict).JSON(domain.ErrorResponse{
// Message: "Duplicate transaction",
Error: veli.ErrDuplicateTransaction.Error(),
})
} else if errors.Is(err, veli.ErrPlayerNotFound) {
} else if strings.Contains(err.Error(), veli.ErrPlayerNotFound.Error()) {
return c.Status(fiber.StatusConflict).JSON(domain.ErrorResponse{
// Message: "User not found",
Error: veli.ErrPlayerNotFound.Error(),