mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Add body for asset
It makes sense to expose entire underlying asset to the callers, as underlying body might have features they like, such as currencyid or est_usd - values that do not exist in json and we're not making use of them, but we still want to keep if provided e.g. by ArchiHandler.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using JetBrains.Annotations;
|
||||
using SteamKit2.Internal;
|
||||
|
||||
namespace ArchiSteamFarm.Steam.Data;
|
||||
|
||||
@@ -34,6 +35,9 @@ public sealed class Asset {
|
||||
public const ulong SteamCommunityContextID = 6;
|
||||
public const ulong SteamPointsShopInstanceID = 3865004543;
|
||||
|
||||
[JsonIgnore]
|
||||
public CEcon_Asset Body { get; } = new();
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsSteamPointsShopItem => !Tradable && (InstanceID == SteamPointsShopInstanceID);
|
||||
|
||||
@@ -56,26 +60,41 @@ public sealed class Asset {
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
[JsonPropertyName("amount")]
|
||||
[JsonRequired]
|
||||
public uint Amount { get; internal set; }
|
||||
public uint Amount {
|
||||
get => (uint) Body.amount;
|
||||
internal set => Body.amount = value;
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonPropertyName("appid")]
|
||||
public uint AppID { get; private init; }
|
||||
public uint AppID {
|
||||
get => Body.appid;
|
||||
private init => Body.appid = value;
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
[JsonPropertyName("assetid")]
|
||||
public ulong AssetID { get; private init; }
|
||||
public ulong AssetID {
|
||||
get => Body.assetid;
|
||||
private init => Body.assetid = value;
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
[JsonPropertyName("classid")]
|
||||
public ulong ClassID { get; private init; }
|
||||
public ulong ClassID {
|
||||
get => Body.classid;
|
||||
private init => Body.classid = value;
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
[JsonPropertyName("contextid")]
|
||||
public ulong ContextID { get; private init; }
|
||||
public ulong ContextID {
|
||||
get => Body.contextid;
|
||||
private init => Body.contextid = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public InventoryDescription? Description { get; internal set; }
|
||||
@@ -83,7 +102,10 @@ public sealed class Asset {
|
||||
[JsonInclude]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
[JsonPropertyName("instanceid")]
|
||||
public ulong InstanceID { get; private init; }
|
||||
public ulong InstanceID {
|
||||
get => Body.instanceid;
|
||||
private init => Body.instanceid = value;
|
||||
}
|
||||
|
||||
[JsonInclude]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
|
||||
@@ -93,6 +115,13 @@ public sealed class Asset {
|
||||
init => AssetID = value;
|
||||
}
|
||||
|
||||
public Asset(CEcon_Asset asset, InventoryDescription? description = null) {
|
||||
ArgumentNullException.ThrowIfNull(asset);
|
||||
|
||||
Body = asset;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public Asset(uint appID, ulong contextID, ulong classID, uint amount, InventoryDescription? description = null, ulong assetID = 0, ulong instanceID = 0) {
|
||||
ArgumentOutOfRangeException.ThrowIfZero(appID);
|
||||
ArgumentOutOfRangeException.ThrowIfZero(contextID);
|
||||
|
||||
@@ -238,7 +238,7 @@ public sealed class ArchiHandler : ClientMsgHandler {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield return new Asset(asset.appid, asset.contextid, asset.classid, (uint) asset.amount, description, asset.assetid, asset.instanceid);
|
||||
yield return new Asset(asset, description);
|
||||
}
|
||||
|
||||
if (!response.more_items) {
|
||||
|
||||
Reference in New Issue
Block a user