Tokens are EnakCoin and no app uses the token names any more, so their compatibility layer goes: - GET /customer/tokens and its handler, service, processor and response types. - total_tokens and tokens_history on GET /customer/wallet; last_updated now comes from the most recent row of either currency. - token_used and tokens_remaining on game and spin responses, and sort_by=token_used on the game play list. - TOKENS as a campaign type and reward type, with the mapping to COINS: migration 000092 already renamed the stored values. The customer_tokens table and its entity stay, as cmd/wallet-migrate still reads them, and LEGACY_TOKENS stays as the reference of the MIGRATION rows it wrote. The docs list the removed names and their replacements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
package contract
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CreateGamePlayRequest struct {
|
|
GameID uuid.UUID `json:"game_id" validate:"required"`
|
|
CustomerID uuid.UUID `json:"customer_id" validate:"required"`
|
|
CoinsUsed int `json:"coins_used" validate:"min=0"`
|
|
RandomSeed *string `json:"random_seed,omitempty"`
|
|
}
|
|
|
|
type GamePlayResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
GameID uuid.UUID `json:"game_id"`
|
|
CustomerID uuid.UUID `json:"customer_id"`
|
|
PrizeID *uuid.UUID `json:"prize_id,omitempty"`
|
|
CoinsUsed int `json:"coins_used"`
|
|
RandomSeed *string `json:"random_seed,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Game *GameResponse `json:"game,omitempty"`
|
|
Customer *CustomerResponse `json:"customer,omitempty"`
|
|
Prize *GamePrizeResponse `json:"prize,omitempty"`
|
|
}
|
|
|
|
type ListGamePlaysRequest struct {
|
|
Page int `json:"page" validate:"min=1"`
|
|
Limit int `json:"limit" validate:"min=1,max=100"`
|
|
Search string `json:"search"`
|
|
GameID *uuid.UUID `json:"game_id"`
|
|
CustomerID *uuid.UUID `json:"customer_id"`
|
|
PrizeID *uuid.UUID `json:"prize_id"`
|
|
SortBy string `json:"sort_by" validate:"omitempty,oneof=created_at coins_used"`
|
|
SortOrder string `json:"sort_order" validate:"omitempty,oneof=asc desc"`
|
|
}
|
|
|
|
type PaginatedGamePlaysResponse struct {
|
|
Data []GamePlayResponse `json:"data"`
|
|
TotalCount int `json:"total_count"`
|
|
Page int `json:"page"`
|
|
Limit int `json:"limit"`
|
|
TotalPages int `json:"total_pages"`
|
|
}
|
|
|
|
// PlayGameRequest plays a game for a customer. What it costs is the game's
|
|
// metadata.coin_cost (docs/prd-point-coin.md F8), never the caller's choice.
|
|
type PlayGameRequest struct {
|
|
GameID uuid.UUID `json:"game_id" validate:"required"`
|
|
CustomerID uuid.UUID `json:"customer_id" validate:"required"`
|
|
}
|
|
|
|
type PlayGameResponse struct {
|
|
GamePlay GamePlayResponse `json:"game_play"`
|
|
PrizeWon *GamePrizeResponse `json:"prize_won,omitempty"`
|
|
CoinsRemaining int64 `json:"coins_remaining"`
|
|
}
|