using System; using Esiur.Resource; using Esiur.Core; using Esiur.Data; using Esiur.Protocol; namespace RPC.EsiurTest { [TypeId("f172196340298b8586fed434c72bc158")] [Export] public class Payment : IRecord { [Annotation("Double")] public double Amount { get; set; } [Annotation("Currency")] public RPC.EsiurTest.Currency Currency { get; set; } [Annotation("Nullable`1?")] public double? Fee { get; set; } [Annotation("PaymentMethod")] public RPC.EsiurTest.PaymentMethod Method { get; set; } [Annotation("String")] public string Reference { get; set; } [Annotation("DateTime")] public DateTime Timestamp { get; set; } public SharedModel.Payment ToShared() { return new SharedModel.Payment() { Amount = Amount, Currency = Enum.Parse(Currency.ToString(), true), Method = Enum.Parse(Method.ToString(), true), Reference = Reference, Timestamp = Timestamp, Fee = Fee, }; } public Echo.ThriftModel.Payment ToThrift() { var rt= new Echo.ThriftModel.Payment() { Amount = Amount, Currency = Enum.Parse(Currency.ToString(), true), Method = Enum.Parse(Method.ToString(), true), Reference = Reference, Timestamp = Timestamp.Ticks, }; if (Fee != null) rt.Fee = Fee.Value; return rt; } public Echo.Model.Grpc.Payment ToGrpc() { return new Echo.Model.Grpc.Payment() { Amount = Amount, Currency = Enum.Parse(Currency.ToString(), true), Fee = Fee ?? 0, Method = Enum.Parse(Method.ToString(), true), Reference = Reference, Timestamp = Timestamp.Ticks, }; } public override bool Equals(object? obj) { var other = obj as Payment; if (other == null) return false; if (Method != other.Method) return false; if (Amount != other.Amount) return false; if (Reference != other.Reference) return false; if (Fee != other.Fee) return false; return true; } } }