Added itemeventrouted deserializer
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Core.Models.Eft.Common.Request;
|
||||
public record BaseInteractionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public virtual string? Action { get; set; }
|
||||
public string? Action { get; set; }
|
||||
|
||||
[JsonPropertyName("fromOwner")]
|
||||
public OwnerInfo? FromOwner { get; set; }
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Eft.Inventory;
|
||||
|
||||
namespace Core.Models.Eft.Customization;
|
||||
|
||||
public record BuyClothingRequestData
|
||||
public record BuyClothingRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "CustomizationBuy";
|
||||
|
||||
[JsonPropertyName("offer")]
|
||||
public string? Offer { get; set; }
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Eft.Inventory;
|
||||
|
||||
namespace Core.Models.Eft.Customization;
|
||||
|
||||
public record CustomizationSetRequest
|
||||
public record CustomizationSetRequest : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "CustomizationSet";
|
||||
|
||||
[JsonPropertyName("customizations")]
|
||||
public List<CustomizationSetOption>? Customizations { get; set; }
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Health;
|
||||
|
||||
public record OffraidEatRequestData : BaseInteractionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Eat";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Core.Models.Eft.Health;
|
||||
|
||||
public record OffraidHealRequestData : BaseInteractionRequestData
|
||||
{
|
||||
public override string? Action { get; set; } = "Heal";
|
||||
public string? Item { get; set; }
|
||||
public BodyPart? Part { get; set; }
|
||||
public int? Count { get; set; }
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Insurance;
|
||||
|
||||
public record InsureRequestData : BaseInteractionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Insure";
|
||||
|
||||
[JsonPropertyName("tid")]
|
||||
public string? TransactionId { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryAddRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Add";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryBindRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Bind";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryCreateMarkerRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "CreateMapMarker";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryDeleteMarkerRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "DeleteMapMarker";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryEditMarkerRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "EditMapMarker";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryExamineRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Examine";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryFoldRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Fold";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryMergeRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Merge";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryMoveRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Move";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryReadEncyclopediaRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "ReadEncyclopedia";
|
||||
|
||||
[JsonPropertyName("ids")]
|
||||
public List<string>? Ids { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryRemoveRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Remove";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventorySortRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "ApplyInventoryChanges";
|
||||
|
||||
[JsonPropertyName("changedItems")]
|
||||
public List<Item>? ChangedItems { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventorySplitRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; } = "Split";
|
||||
|
||||
/** Id of item to split */
|
||||
[JsonPropertyName("splitItem")]
|
||||
public string? SplitItem { get; set; }
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventorySwapRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Swap";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryTagRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Tag";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryToggleRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Toggle";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryTransferRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Transfer";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record InventoryUnbindRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "Unbind";
|
||||
|
||||
[JsonPropertyName("item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record OpenRandomLootContainerRequestData
|
||||
public record OpenRandomLootContainerRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
public string? Action { get; set; } = "OpenRandomLootContainer";
|
||||
|
||||
/// <summary>
|
||||
/// Container item id being opened
|
||||
/// </summary>
|
||||
|
||||
@@ -3,11 +3,8 @@ using Core.Models.Eft.Common.Tables;
|
||||
|
||||
namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record PinOrLockItemRequest
|
||||
public record PinOrLockItemRequest : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "PinLock";
|
||||
|
||||
/** Id of item being pinned */
|
||||
[JsonPropertyName("Item")]
|
||||
public string? Item { get; set; }
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record RedeemProfileRequestData : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "RedeemProfileReward";
|
||||
|
||||
[JsonPropertyName("events")]
|
||||
public List<RedeemProfileRequestEvent>? Events { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace Core.Models.Eft.Inventory;
|
||||
|
||||
public record SetFavoriteItems : InventoryBaseActionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; } = "SetFavoriteItems";
|
||||
|
||||
[JsonPropertyName("items")]
|
||||
public List<object>? Items { get; set; }
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ namespace Core.Models.Eft.Notes;
|
||||
|
||||
public record NoteActionData : BaseInteractionRequestData
|
||||
{
|
||||
[JsonPropertyName("Action")]
|
||||
public string? Action { get; set; }
|
||||
|
||||
[JsonPropertyName("index")]
|
||||
public int? Index { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Eft.Common.Request;
|
||||
using Core.Models.Eft.Customization;
|
||||
|
||||
namespace Core.Utils.Json.Converters;
|
||||
|
||||
public class BaseInteractionRequestDataConverter : JsonConverter<BaseInteractionRequestData>
|
||||
{
|
||||
public override BaseInteractionRequestData? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
using var jsonDocument = JsonDocument.ParseValue(ref reader);
|
||||
var jsonText = jsonDocument.RootElement.GetRawText();
|
||||
var value = JsonSerializer.Deserialize<BaseInteractionRequestData>(jsonText, options);
|
||||
return ConvertToCorrectType(value, jsonText, options);
|
||||
}
|
||||
|
||||
private BaseInteractionRequestData? ConvertToCorrectType(BaseInteractionRequestData? value, string jsonText, JsonSerializerOptions options)
|
||||
{
|
||||
switch (value.Action)
|
||||
{
|
||||
case "CustomizationBuy":
|
||||
return JsonSerializer.Deserialize<BuyClothingRequestData>(jsonText, options);
|
||||
case "CustomizationSet":
|
||||
return JsonSerializer.Deserialize<CustomizationSetRequest>(jsonText, options);
|
||||
|
||||
///////////////////////////////////////////
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, BaseInteractionRequestData value, JsonSerializerOptions options)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value, options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user