enjin / platform-csharp-sdk

SDK for connecting to and interacting with the Enjin Platform.
GNU Lesser General Public License v3.0
7 stars 8 forks source link

Added an accessor to PendingEvent to be able to get back typed data #28

Closed CliffCawley closed 5 months ago

CliffCawley commented 5 months ago

Added an accessor to PendingEvent to be able to get back typed data, instead of just a JsonElement.

It's not fully populated and someone with some more knowledge about the events and their data would be able to better fill it out, but I think it's a great start and can easily be expanded upon.

I.e.

Now you can do the following:

foreach (var edge in response.Result.Data.Result.Edges)
{
    if (edge.Node.DataTyped is PendingEventDataTransfer eventDataTransfer)
    {
        Console.WriteLine($"From: {eventDataTransfer.From}");
        Console.WriteLine($"To: {eventDataTransfer.To}");
        Console.WriteLine($"Amount: {eventDataTransfer.Amount}");
    }
}

Instead of:

foreach (var edge in response.Result.Data.Result.Edges)
{
    var root = edge.Node.Data.Value;
    if (root.ValueKind == JsonValueKind.Object)
    {
        foreach (JsonProperty prop in root.EnumerateObject())
        {
            Console.WriteLine($"Key: {prop.Name}, Value: {prop.Value}");
        }
    }
}
v16Studios commented 5 months ago

Looks good :) Would you mind going through and adding some summary blocks for the properties? Just to keep everything consistent. Cheers!

CliffCawley commented 5 months ago

@v16Studios I've added some, although I had to guess what their purpose was, since I don't actually know. Some of the events I added, I just did so because I saw their data in the returned data from the call.

Like I said, it's also incomplete, I'm not sure what other events are possible, or even what all of their properties mean.

For example, I'm not sure what the Deposit or Withdraw events are actually for, I just made an assumption about what the properties might be.