package controllers import ( "log" "github.com/gofiber/fiber/v2" "github.com/sujit-baniya/fiber-boilerplate/pkg/services" ) // Estructuras definidas por el cliente (ya están bien) type Address struct { Name string `json:"name"` Line1 string `json:"line_1"` Line2 string `json:"line_2"` Line3 string `json:"line_3"` City string `json:"city"` State string `json:"state"` Country string `json:"country"` Zip string `json:"zip"` PhoneNumber string `json:"phone_number"` Metadata map[string]interface{} `json:"metadata"` Canton string `json:"canton"` District string `json:"district"` } type Contact struct { PhoneNumber string `json:"phone_number"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` MothersName string `json:"mothers_name"` ContactType string `json:"contact_type"` Address Address `json:"address"` IdentificationType string `json:"identification_type"` IdentificationNumber string `json:"identification_number"` DateOfBirth string `json:"date_of_birth"` Country string `json:"country"` Nationality string `json:"nationality"` Metadata map[string]interface{} `json:"metadata"` } type WalletRequest struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` EwalletReferenceID string `json:"ewallet_reference_id"` Metadata map[string]interface{} `json:"metadata"` Type string `json:"type"` Contact Contact `json:"contact"` } func MakeWallet(c *fiber.Ctx) error { var body WalletRequest // 1. Parsear el cuerpo de la solicitud if err := c.BodyParser(&body); err != nil { return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "error": "Error al parsear el cuerpo de la solicitud: " + err.Error(), }) } // El cuerpo de un wallet lleva nombre, correo, teléfono, documento y fecha // de nacimiento: no se loguea. response, err := services.MakeRequest("post", "/v1/ewallets", body) if err != nil { log.Printf("[RAPYD] error creando wallet: %v", err) return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ "error": "Error al comunicarse con Rapyd", "details": err.Error(), }) } return c.Status(fiber.StatusOK).JSON(response) }