2026-08-26 18:30:28 +03:00
|
|
|
package rudder
|
|
|
|
|
|
2026-08-27 16:10:27 +03:00
|
|
|
import "context"
|
2026-08-26 18:30:28 +03:00
|
|
|
|
|
|
|
|
type PlayerWalletHandle struct {
|
|
|
|
|
playerID string
|
|
|
|
|
wallet *WalletService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AdjustPlayerWalletParameters struct {
|
|
|
|
|
IdempotencyKey string
|
|
|
|
|
CurrencyCode string
|
|
|
|
|
Amount int64
|
|
|
|
|
Reason string
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-27 16:10:27 +03:00
|
|
|
func (h *PlayerWalletHandle) Adjust(ctx context.Context, parameters AdjustPlayerWalletParameters) (*WalletBalance, error) {
|
2026-08-26 18:30:28 +03:00
|
|
|
wallets, err := h.wallet.Adjust(ctx, AdjustWalletParameters{
|
|
|
|
|
IdempotencyKey: parameters.IdempotencyKey,
|
2026-08-27 16:10:27 +03:00
|
|
|
Items: []WalletAdjustment{{
|
2026-08-26 18:30:28 +03:00
|
|
|
PlayerID: h.playerID,
|
|
|
|
|
CurrencyCode: parameters.CurrencyCode,
|
|
|
|
|
Amount: parameters.Amount,
|
|
|
|
|
Reason: parameters.Reason,
|
|
|
|
|
}},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return &wallets[0], nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-27 16:10:27 +03:00
|
|
|
func (h *PlayerWalletHandle) History(ctx context.Context, parameters WalletHistoryParameters) (*WalletHistory, error) {
|
2026-08-26 18:30:28 +03:00
|
|
|
return h.wallet.History(ctx, h.playerID, parameters)
|
|
|
|
|
}
|