40 lines
1003 B
Go
40 lines
1003 B
Go
|
|
package rudder
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"hub.rudder.build/rudder/rudder-go-sdk/models"
|
||
|
|
)
|
||
|
|
|
||
|
|
type PlayerWalletHandle struct {
|
||
|
|
playerID string
|
||
|
|
wallet *WalletService
|
||
|
|
}
|
||
|
|
|
||
|
|
type AdjustPlayerWalletParameters struct {
|
||
|
|
IdempotencyKey string
|
||
|
|
CurrencyCode string
|
||
|
|
Amount int64
|
||
|
|
Reason string
|
||
|
|
}
|
||
|
|
|
||
|
|
func (h *PlayerWalletHandle) Adjust(ctx context.Context, parameters AdjustPlayerWalletParameters) (*models.WalletDetails, error) {
|
||
|
|
wallets, err := h.wallet.Adjust(ctx, AdjustWalletParameters{
|
||
|
|
IdempotencyKey: parameters.IdempotencyKey,
|
||
|
|
Items: []models.BatchAdjustPlayerWalletsItem{{
|
||
|
|
PlayerID: h.playerID,
|
||
|
|
CurrencyCode: parameters.CurrencyCode,
|
||
|
|
Amount: parameters.Amount,
|
||
|
|
Reason: parameters.Reason,
|
||
|
|
}},
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return &wallets[0], nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (h *PlayerWalletHandle) History(ctx context.Context, parameters WalletHistoryParameters) (*models.GetWalletHistoryResponse, error) {
|
||
|
|
return h.wallet.History(ctx, h.playerID, parameters)
|
||
|
|
}
|