2020-11-06 20:42:26 +09:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Client.Models
|
|
|
|
{
|
|
|
|
public class WebhookEvent
|
|
|
|
{
|
2020-11-13 16:28:15 +09:00
|
|
|
public readonly static JsonSerializerSettings DefaultSerializerSettings;
|
|
|
|
static WebhookEvent()
|
|
|
|
{
|
|
|
|
DefaultSerializerSettings = new JsonSerializerSettings();
|
|
|
|
DefaultSerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
|
|
|
|
NBitcoin.JsonConverters.Serializer.RegisterFrontConverters(DefaultSerializerSettings);
|
|
|
|
DefaultSerializerSettings.Formatting = Formatting.None;
|
|
|
|
}
|
2020-11-06 20:42:26 +09:00
|
|
|
public string DeliveryId { get; set; }
|
2020-11-16 12:05:15 +09:00
|
|
|
public string WebhookId { get; set; }
|
2020-11-06 20:42:26 +09:00
|
|
|
public string OrignalDeliveryId { get; set; }
|
2020-11-16 12:05:15 +09:00
|
|
|
public bool IsRedelivery { get; set; }
|
2020-11-06 20:42:26 +09:00
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
|
|
public WebhookEventType Type { get; set; }
|
|
|
|
[JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))]
|
|
|
|
public DateTimeOffset Timestamp { get; set; }
|
|
|
|
[JsonExtensionData]
|
|
|
|
public IDictionary<string, JToken> AdditionalData { get; set; }
|
2020-11-16 12:05:15 +09:00
|
|
|
public T ReadAs<T>()
|
|
|
|
{
|
|
|
|
var str = JsonConvert.SerializeObject(this, DefaultSerializerSettings);
|
|
|
|
return JsonConvert.DeserializeObject<T>(str, DefaultSerializerSettings);
|
|
|
|
}
|
2020-11-06 20:42:26 +09:00
|
|
|
}
|
|
|
|
}
|