26 lines
784 B
C#
26 lines
784 B
C#
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using RudderSdk.Core.Models.Inventory;
|
|
|
|
namespace RudderSdk.Core;
|
|
|
|
/// <summary>Player inventory.</summary>
|
|
public sealed class InventoryService
|
|
{
|
|
private readonly RudderClient _client;
|
|
|
|
internal InventoryService(RudderClient client) => _client = client;
|
|
|
|
/// <summary>Lists the items the player owns.</summary>
|
|
public async Task<IReadOnlyList<PlayerInventoryItem>> GetAsync(CancellationToken cancellationToken = default)
|
|
{
|
|
var response = await _client.SendAsync<GetInventoryResponse>(
|
|
"GET",
|
|
"/sdk/v1/inventory",
|
|
cancellationToken).ConfigureAwait(false);
|
|
|
|
return response?.Items ?? new List<PlayerInventoryItem>();
|
|
}
|
|
}
|