package mappers import ( "apskel-pos-be/internal/entities" "apskel-pos-be/internal/models" ) // ToGamePlayResponse converts a game play entity to a game play response func ToGamePlayResponse(gamePlay *entities.GamePlay) *models.GamePlayResponse { if gamePlay == nil { return nil } return &models.GamePlayResponse{ ID: gamePlay.ID, GameID: gamePlay.GameID, CustomerID: gamePlay.CustomerID, PrizeID: gamePlay.PrizeID, TokenUsed: gamePlay.TokenUsed, RandomSeed: gamePlay.RandomSeed, CreatedAt: gamePlay.CreatedAt, Game: ToGameResponse(&gamePlay.Game), Customer: ToCustomerResponse(&gamePlay.Customer), Prize: ToGamePrizeResponse(gamePlay.Prize), } } // ToGamePlayResponses converts a slice of game play entities to game play responses func ToGamePlayResponses(gamePlays []entities.GamePlay) []models.GamePlayResponse { responses := make([]models.GamePlayResponse, len(gamePlays)) for i, gp := range gamePlays { responses[i] = *ToGamePlayResponse(&gp) } return responses } // ToGamePlayEntity converts a create game play request to a game play entity func ToGamePlayEntity(req *models.CreateGamePlayRequest) *entities.GamePlay { return &entities.GamePlay{ GameID: req.GameID, CustomerID: req.CustomerID, TokenUsed: req.TokenUsed, RandomSeed: req.RandomSeed, } }