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 PlayerInventoryHandle struct {
|
|
|
|
|
playerID string
|
|
|
|
|
inventory *InventoryService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AdjustPlayerInventoryParameters struct {
|
|
|
|
|
IdempotencyKey string
|
|
|
|
|
Slug string
|
|
|
|
|
Amount int64
|
|
|
|
|
Reason string
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-27 16:10:27 +03:00
|
|
|
func (h *PlayerInventoryHandle) Adjust(ctx context.Context, parameters AdjustPlayerInventoryParameters) (*InventoryItem, error) {
|
2026-08-26 18:30:28 +03:00
|
|
|
items, err := h.inventory.Adjust(ctx, AdjustInventoryParameters{
|
|
|
|
|
IdempotencyKey: parameters.IdempotencyKey,
|
2026-08-27 16:10:27 +03:00
|
|
|
Items: []InventoryAdjustment{{
|
2026-08-26 18:30:28 +03:00
|
|
|
PlayerID: h.playerID,
|
|
|
|
|
Slug: parameters.Slug,
|
|
|
|
|
Amount: parameters.Amount,
|
|
|
|
|
Reason: parameters.Reason,
|
|
|
|
|
}},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return &items[0], nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-27 16:10:27 +03:00
|
|
|
func (h *PlayerInventoryHandle) List(ctx context.Context, parameters ListInventoryParameters) (*InventoryList, error) {
|
2026-08-26 18:30:28 +03:00
|
|
|
return h.inventory.List(ctx, h.playerID, parameters)
|
|
|
|
|
}
|