diff --git a/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj b/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj index 9830c488..0d024ffc 100644 --- a/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj +++ b/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj @@ -8,7 +8,7 @@ - + diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs index e2a97361..8c1953f1 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs @@ -54,10 +54,11 @@ private EstateManagementContext GetContext(String databaseName) } public VoucherDomainEventHandlerTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); Logger.Initialise(NullLogger.Instance); - StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); + SecurityServiceClient = new Mock(); MessagingServiceClient = new Mock(); diff --git a/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs index dc5fdcdf..657ba13a 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; @@ -8,7 +9,6 @@ using System; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.Services; @@ -25,6 +25,8 @@ namespace TransactionProcessor.BusinessLogic.Tests.Manager using ProjectionEngine.Database.Database; using ProjectionEngine.Database.Database.Entities; using Shared.EntityFramework; + using Shared.Serialisation; + using System.Text.Json; using Testing; public class VoucherManagementManagerTests @@ -36,6 +38,7 @@ private EstateManagementContext GetContext(String databaseName) { } public VoucherManagementManagerTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); this.AggregateService = new Mock(); this.DbContextFactory = new Mock>(); this.Context = this.GetContext(Guid.NewGuid().ToString("N")); diff --git a/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyTransactionDomainService.cs b/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyTransactionDomainService.cs index 5f36cbaa..1218fe1f 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyTransactionDomainService.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyTransactionDomainService.cs @@ -1,6 +1,5 @@ -using EventStore.Client; -using KurrentDB.Client; -using Newtonsoft.Json; +using KurrentDB.Client; +using Shared.Serialisation; using SimpleResults; using TransactionProcessor.BusinessLogic.Requests; using TransactionProcessor.ProjectionEngine.Models; @@ -101,8 +100,8 @@ public async Task> GetPartitionResultFromProjection(String projec public async Task> GetPartitionStateFromProjection(String projectionName, String partitionId, CancellationToken cancellationToken) { - MerchantBalanceProjectionState1 state = new MerchantBalanceProjectionState1(new Merchant("", "", 0, 0, new Deposits(0, 0, DateTime.MinValue), new Withdrawals(0, 0, DateTime.MinValue), new AuthorisedSales(0, 0, DateTime.MinValue), new DeclinedSales(0, 0, DateTime.MinValue), new Fees(0, 0)) { }); - return Result.Success(JsonConvert.SerializeObject(state)); + MerchantBalanceProjectionState1 state = new MerchantBalanceProjectionState1(new Merchant("", "", 0, 0)); + return Result.Success(StringSerialiser.Serialise(state)); } public async Task> GetResultFromProjection(String projectionName, diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs index a7577dc0..77cc10fc 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPostPayProxyTests.cs @@ -1,15 +1,17 @@ -using System; +using SimpleResults; +using System; using System.Threading.Tasks; -using SimpleResults; namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces { - using System.Threading; using Common; using Microsoft.Extensions.Caching.Memory; using Moq; using PataPawaPostPay; + using Shared.Serialisation; using Shouldly; + using System.Text.Json; + using System.Threading; using Testing; using TransactionProcessor.BusinessLogic.OperatorInterfaces.PataPawaPostPay; using Xunit; @@ -26,6 +28,7 @@ public class PataPawaPostPayProxyTests{ private readonly IMemoryCache MemoryCache; public PataPawaPostPayProxyTests(){ + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); PataPawaPostPayService = new Mock(); PataPawaPostPayServiceClient = new Mock(); diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs index 22e00a26..55d1df95 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/PataPawaPrePayProxyTests.cs @@ -1,15 +1,16 @@ -using System; +using Microsoft.Extensions.Caching.Memory; +using RichardSzalay.MockHttp; +using Shared.Logger; +using Shared.Serialisation; +using Shouldly; +using SimpleResults; +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Memory; -using Newtonsoft.Json; -using RichardSzalay.MockHttp; -using Shared.Logger; -using Shouldly; -using SimpleResults; using TransactionProcessor.BusinessLogic.OperatorInterfaces; using TransactionProcessor.BusinessLogic.OperatorInterfaces.PataPawaPrePay; using TransactionProcessor.Testing; @@ -23,6 +24,7 @@ public class PataPawaPrePayProxyTests { private readonly IMemoryCache MemoryCache = new MemoryCache(new MemoryCacheOptions()); public PataPawaPrePayProxyTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); PataPawaPrePaidConfiguration configuration = new PataPawaPrePaidConfiguration(); configuration.Url = "http://localhost"; configuration.Password = "password"; @@ -41,7 +43,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_MessageProcessed() { LogonResponse logonResponse = new LogonResponse { Balance = "0", Key = "Key", Msg = "Success", Status = 0 }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(logonResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(logonResponse)); var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None); result.IsSuccess.ShouldBeTrue(); @@ -66,7 +68,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_FailedLogon_MessagePro { LogonResponse logonResponse = new LogonResponse { Balance = "0", Key = "Key", Msg = "Success", Status = -1 }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(logonResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(logonResponse)); var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None); result.IsFailed.ShouldBeTrue(); @@ -102,7 +104,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Messag MeterResponse meterResponse = new MeterResponse { Status = 0, Code = "1", CustomerName = "Customer", Msg = "msg" }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(meterResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(meterResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, @@ -132,7 +134,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Failed MeterResponse meterResponse = new MeterResponse { Status = -1, Code = "1", CustomerName = "Customer", Msg = "msg" }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(meterResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(meterResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, @@ -165,7 +167,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Message CustomerName = "Mr Customer" }}; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, @@ -205,7 +207,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_FailedA } }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, @@ -245,7 +247,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Custome } }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, @@ -285,7 +287,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_AmountI } }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, @@ -323,7 +325,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_UnknownMessageType_Mess } }; - this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse)); + this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse)); var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId, TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference, diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs index 507a0bd1..66b023b3 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/SafaricomPinlessProxyTests.cs @@ -1,19 +1,21 @@ -using System; +using SimpleResults; +using System; using System.Collections.Generic; -using SimpleResults; namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces { - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; using BusinessLogic.OperatorInterfaces; using BusinessLogic.OperatorInterfaces.SafaricomPinless; using Moq; using Moq.Protected; using Shared.Logger; + using Shared.Serialisation; using Shouldly; + using System.Net; + using System.Net.Http; + using System.Text.Json; + using System.Threading; + using System.Threading.Tasks; using Testing; using Xunit; @@ -21,6 +23,7 @@ public class SafaricomPinlessProxyTests { public SafaricomPinlessProxyTests(){ Logger.Initialise(NullLogger.Instance); + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); } [Fact] diff --git a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs index 729899b7..e88a0d19 100644 --- a/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/OperatorInterfaces/VoucherManagementProxyTests.cs @@ -3,16 +3,18 @@ namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces { - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; using BusinessLogic.OperatorInterfaces; using BusinessLogic.OperatorInterfaces.VoucherManagement; using MediatR; using Moq; using Requests; + using Shared.Serialisation; using Shouldly; + using System; + using System.Collections.Generic; + using System.Text.Json; + using System.Threading; + using System.Threading.Tasks; using Testing; using Xunit; @@ -20,6 +22,7 @@ public class VoucherManagementProxyTests { public VoucherManagementProxyTests() { Logger.Initialise(new NullLogger()); + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); } [Fact] diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs index 8a744b9f..9fa899d8 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/FloatRequestHandlerTests.cs @@ -1,19 +1,25 @@ -using System.Threading.Tasks; -using SimpleResults; +using SimpleResults; +using System.Threading.Tasks; namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler; -using System.Threading; using BusinessLogic.Services; using Moq; using RequestHandlers; using Requests; +using Shared.Serialisation; using Shouldly; +using System.Text.Json; +using System.Threading; using Testing; using Xunit; public class FloatRequestHandlerTests { + public FloatRequestHandlerTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); + } + [Fact] public async Task FloatRequestHandler_CreateFloatForContractProductRequest_IsHandled(){ Mock floatDomainService = new Mock(); diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs index 38271acf..da54b86a 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs @@ -1,10 +1,12 @@ -using System.Threading; -using System.Threading.Tasks; -using Moq; +using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; +using Shared.Serialisation; using Shouldly; using SimpleResults; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.RequestHandlers; @@ -17,6 +19,10 @@ namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler; public class SettlementRequestHandlerTests { + public SettlementRequestHandlerTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); + } + [Fact] public async Task SettlementRequestHandler_ProcessSettlementRequest_IsHandled() { diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs index ceb0d0d6..24536b87 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/TransactionRequestHandlerTests.cs @@ -1,8 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; -using Moq; +using Moq; +using Shared.Serialisation; using Shouldly; using SimpleResults; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; using TransactionProcessor.BusinessLogic.RequestHandlers; using TransactionProcessor.BusinessLogic.Requests; using TransactionProcessor.BusinessLogic.Services; @@ -13,6 +15,10 @@ namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler { public class TransactionRequestHandlerTests { + public TransactionRequestHandlerTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); + } + [Fact] public async Task TransactionRequestHandler_ProcessLogonTransactionRequest_IsHandled() { diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs index bb50aba7..4a101958 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/VoucherManagementRequestHandlerTests.cs @@ -1,7 +1,7 @@ -using System; -using System.Threading.Tasks; -using Moq; +using Moq; using Shouldly; +using System; +using System.Threading.Tasks; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.RequestHandlers; using TransactionProcessor.BusinessLogic.Requests; @@ -10,11 +10,17 @@ namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler { + using Shared.Serialisation; + using System.Text.Json; using System.Threading; using Testing; public class VoucherManagementRequestHandlerTests { + public VoucherManagementRequestHandlerTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); + } + [Fact] public async Task VoucherManagementRequestHandler_IssueVoucherRequest_IsHandled() { diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs index 554978d3..c0523daa 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/ContractDomainServiceTests.cs @@ -5,6 +5,7 @@ using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; +using Shared.Serialisation; using Shouldly; using SimpleResults; using TransactionProcessor.Aggregates; @@ -26,6 +27,7 @@ public ContractDomainServiceTests() { this.EventStoreContext = new Mock(); IAggregateService AggregateServiceResolver() => this.AggregateService.Object; this.DomainService = new ContractDomainService(AggregateServiceResolver, this.EventStoreContext.Object); + StringSerialiser.Initialise(new SystemTextJsonSerializer(SystemTextJsonSerializer.GetDefaultJsonSerializerOptions())); } [Fact] @@ -38,7 +40,7 @@ public async Task ContractDomainService_CreateContract_ContractIsCreated() this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; Result result = await this.DomainService.CreateContract(command, CancellationToken.None); @@ -52,7 +54,7 @@ public async Task ContractDomainService_CreateContract_DuplicateContractNameForO .ReturnsAsync(TestData.Aggregates.EstateAggregateWithOperator()); this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); String queryResult = - "{\r\n \"total\": 1,\r\n \"contractId\": \"3015e4d0-e9a9-49e5-bd55-a5492f193b62\"\r\n}"; + "{\r\n \"total\": 1,\r\n \"contract_Id\": \"3015e4d0-e9a9-49e5-bd55-a5492f193b62\"\r\n}"; this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) .ReturnsAsync(queryResult); @@ -70,7 +72,7 @@ public async Task ContractDomainService_CreateContract_ContractAlreadyCreated_Re this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; Result result = await this.DomainService.CreateContract(command, CancellationToken.None); @@ -83,7 +85,7 @@ public async Task ContractDomainService_CreateContract_EstateNotCreated_ResultFa this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyEstateAggregate)); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; Result result = await this.DomainService.CreateContract(command, CancellationToken.None); @@ -96,7 +98,7 @@ public async Task ContractDomainService_CreateContract_NoOperatorCreatedForEstat this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; Result result = await this.DomainService.CreateContract(command, CancellationToken.None); @@ -110,7 +112,7 @@ public async Task ContractDomainService_CreateContract_OperatorNotFoundForEstate this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; Result result = await this.DomainService.CreateContract(command, CancellationToken.None); @@ -125,7 +127,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_ProductA this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); @@ -139,7 +141,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_Contract this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); @@ -155,7 +157,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_Produ this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); @@ -169,7 +171,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_Contr this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); @@ -183,7 +185,7 @@ public async Task ContractDomainService_AddProductToContract_VariableValue_Estat this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_VariableValue; Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); @@ -197,7 +199,7 @@ public async Task ContractDomainService_AddProductToContract_FixedValue_EstateNo this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddProductToContractCommand command = TestData.Commands.AddProductToContractCommand_FixedValue; Result result = await this.DomainService.AddProductToContract(command, CancellationToken.None); @@ -218,7 +220,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Tr this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType, feeType); @@ -238,7 +240,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Co .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType,feeType); @@ -259,7 +261,7 @@ public async Task ContractDomainService_AddTransactionFeeForProductToContract_Pr .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.AddTransactionFeeForProductToContractCommand command = TestData.Commands.AddTransactionFeeForProductToContractCommand(calculationType, feeType); @@ -284,7 +286,7 @@ public async Task ContractDomainService_DisableTransactionFeeForProduct_Transact this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); ContractCommands.DisableTransactionFeeForProductCommand command = TestData.Commands.DisableTransactionFeeForProductCommand; Result result = await this.DomainService.DisableTransactionFeeForProduct(command, CancellationToken.None); @@ -385,10 +387,8 @@ public async Task ContractDomainService_CreateContract_StateChangeFailed_ResultI this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); - //this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())) - // .ReturnsAsync(Result.Failure()); - + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); + ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; command = command with { RequestDTO = new CreateContractRequest { @@ -408,7 +408,7 @@ public async Task ContractDomainService_CreateContract_SaveFailed_ResultIsFailed this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); @@ -425,7 +425,7 @@ public async Task ContractDomainService_CreateContract_ExceptionThrown_ResultIsF this.AggregateService.Setup(c => c.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); this.EventStoreContext.Setup(c => c.RunTransientQuery(It.IsAny(), It.IsAny())) - .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contractId\": \"\"\r\n}"); + .ReturnsAsync("{\r\n \"total\": 0,\r\n \"contract_Id\": \"\"\r\n}"); this.AggregateService.Setup(c => c.Save(It.IsAny(), It.IsAny())).ThrowsAsync(new Exception()); ContractCommands.CreateContractCommand command = TestData.Commands.CreateContractCommand; diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs index 19f9dbc9..f371d9e6 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs @@ -1,14 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Moq; +using Moq; using SecurityService.Client; using SecurityService.DataTransferObjects; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; +using Shared.Serialisation; using Shouldly; using SimpleResults; +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Requests; using TransactionProcessor.BusinessLogic.Services; @@ -23,6 +25,7 @@ public class EstateDomainServiceTests { private Mock AggregateService; private Mock SecurityServiceClient; public EstateDomainServiceTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); this.AggregateService= new Mock(); this.SecurityServiceClient = new Mock(); IAggregateService AggregateServiceResolver() => this.AggregateService.Object; diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs index cefd7fb2..f2649cde 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs @@ -1,18 +1,20 @@ -using System; +using SimpleResults; +using System; using System.Threading.Tasks; -using SimpleResults; using TransactionProcessor.BusinessLogic.Requests; namespace TransactionProcessor.BusinessLogic.Tests.Services { - using System.Threading; using Microsoft.Extensions.Configuration; using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; + using Shared.Serialisation; using Shouldly; + using System.Text.Json; + using System.Threading; using Testing; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Services; @@ -24,7 +26,7 @@ public class FloatDomainServiceTests private readonly FloatDomainService FloatDomainService; public FloatDomainServiceTests(){ - + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs index 59a965d5..65e981ee 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantDomainServiceTests.cs @@ -1,6 +1,5 @@ using Microsoft.Extensions.Configuration; using Moq; -using Newtonsoft.Json; using SecurityService.Client; using SecurityService.DataTransferObjects; using Shared.DomainDrivenDesign.EventSourcing; @@ -8,11 +7,13 @@ using Shared.EventStore.EventStore; using Shared.General; using Shared.Logger; +using Shared.Serialisation; using Shouldly; using SimpleResults; using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using TransactionProcessor.Aggregates; @@ -36,6 +37,7 @@ public class MerchantDomainServiceTests { private readonly Mock EventStoreContext; public MerchantDomainServiceTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); @@ -838,7 +840,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_WithdrawalIsMade( .Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetTokenResponse())); - this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState))); + this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState))); var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); result.IsSuccess.ShouldBeTrue(); @@ -864,7 +866,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_DuplicateWithdraw .Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetTokenResponse())); - this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState))); + this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState))); var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); result.IsFailed.ShouldBeTrue(); @@ -943,7 +945,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_NotEnoughFundsToW .ReturnsAsync(Result.Success()); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionStateNoCredit))); + .ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionStateNoCredit))); var result = await this.DomainService.MakeMerchantWithdrawal(TestData.Commands.MakeMerchantWithdrawalCommand, CancellationToken.None); result.IsFailed.ShouldBeTrue(); @@ -1583,7 +1585,7 @@ public async Task MerchantDomainService_MakeMerchantWithdrawal_SaveFailed_Result .Setup(m => m.GetLatest(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedMerchantDepositListAggregate())); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState))); + .ReturnsAsync(Result.Success(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState))); this.AggregateService.Setup(m => m.Save(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs index 6d909c4c..c52ff69f 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/MerchantStatementDomainServiceTests.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using MessagingService.Client; +using MessagingService.Client; using MessagingService.DataTransferObjects; using Microsoft.Extensions.Configuration; using Moq; @@ -9,8 +6,13 @@ using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; +using Shared.Serialisation; using Shouldly; using SimpleResults; +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Services; using TransactionProcessor.Models.Merchant; @@ -27,6 +29,7 @@ public class MerchantStatementDomainServiceTests { private readonly Mock SecurityServiceClient; private readonly MerchantStatementDomainService DomainService; public MerchantStatementDomainServiceTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); this.AggregateService = new Mock(); this.StatementBuilder = new Mock(); this.MessagingServiceClient = new Mock(); diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs index 400c6c14..29a092fe 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/OperatorDomainServiceTests.cs @@ -1,11 +1,13 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Moq; +using Moq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; +using Shared.Serialisation; using Shouldly; using SimpleResults; +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Requests; using TransactionProcessor.BusinessLogic.Services; @@ -24,6 +26,7 @@ public OperatorDomainServiceTests(){ this.AggregateService = new Mock(); IAggregateService AggregateServiceResolver() => this.AggregateService.Object; this.OperatorDomainService = new OperatorDomainService(AggregateServiceResolver); + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); } [Fact] diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs index 2d44b471..48abb388 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs @@ -6,10 +6,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services { - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; using BusinessLogic.Services; using Microsoft.Extensions.Configuration; using Moq; @@ -17,7 +13,13 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; + using Shared.Serialisation; using Shouldly; + using System; + using System.Collections.Generic; + using System.Text.Json; + using System.Threading; + using System.Threading.Tasks; using Testing; using Xunit; @@ -27,6 +29,7 @@ public class SettlementDomainServiceTests private SettlementDomainService settlementDomainService; public SettlementDomainServiceTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); this.AggregateService = new Mock(); IAggregateService AggregateServiceResolver() => this.AggregateService.Object; diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs index 2e297c72..feedd975 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/StatementBuilderTests.cs @@ -1,14 +1,16 @@ +using Moq; +using Shared.Serialisation; +using Shouldly; +using SimpleResults; using System; using System.Collections.Generic; using System.IO; using System.IO.Abstractions; using System.Linq; using System.Reflection; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using Moq; -using Shouldly; -using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Services; using TransactionProcessor.Models.Merchant; @@ -24,6 +26,7 @@ public class StatementBuilderTests { private readonly CancellationToken _cancellationToken = CancellationToken.None; public StatementBuilderTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); _fileSystemMock = new Mock(); _builder = new StatementBuilder(_fileSystemMock.Object); diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs index c761e6e7..467e34a9 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs @@ -8,10 +8,6 @@ using TransactionProcessor.Models.Merchant; namespace TransactionProcessor.BusinessLogic.Tests.Services{ - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; using BusinessLogic.OperatorInterfaces; using BusinessLogic.Services; using MessagingService.Client; @@ -23,7 +19,13 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services{ using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; + using Shared.Serialisation; using Shouldly; + using System; + using System.Collections.Generic; + using System.Text.Json; + using System.Threading; + using System.Threading.Tasks; using Testing; using Xunit; @@ -44,6 +46,7 @@ public class TransactionDomainServiceTests{ #region Constructors public TransactionDomainServiceTests(){ + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs index 4da4b166..27181a77 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs @@ -3,19 +3,25 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services { + using BusinessLogic.Services; + using Models; + using Shared.Serialisation; + using Shouldly; using System.IO; using System.IO.Abstractions.TestingHelpers; using System.Reflection; + using System.Text.Json; using System.Threading; using System.Threading.Tasks; - using BusinessLogic.Services; - using Models; - using Shouldly; using Testing; using Xunit; public class TransactionReceiptBuilderTests { + public TransactionReceiptBuilderTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); + } + [Fact] public async Task TransactionReceiptBuilder_GetEmailReceiptMessage_MessageBuilt() { diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs index bf1303f5..fb0aed30 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs @@ -1,25 +1,23 @@ -using Shared.DomainDrivenDesign.EventSourcing; -using Shared.EventStore.Aggregate; +using Shared.EventStore.Aggregate; using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.Models.Merchant; namespace TransactionProcessor.BusinessLogic.Tests.Services; -using System; -using System.Threading; -using System.Threading.Tasks; using BusinessLogic.Services; using Microsoft.Extensions.Configuration; using Moq; -using Newtonsoft.Json; -using ProjectionEngine.Repository; -using ProjectionEngine.State; using SecurityService.Client; using Shared.EventStore.EventStore; using Shared.General; using Shared.Logger; +using Shared.Serialisation; using Shouldly; +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; using Testing; using Xunit; @@ -29,6 +27,7 @@ public class TransactionValidationServiceTests { private readonly Mock EventStoreContext; private readonly Mock AggregateService; public TransactionValidationServiceTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); @@ -404,7 +403,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidCo .ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -429,7 +428,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidPr this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -501,7 +500,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantD this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -528,7 +527,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantH this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -552,7 +551,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.AggregateService.Setup(m => m.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionStateNoCredit)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionStateNoCredit)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -627,7 +626,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN .ReturnsAsync(Result.NotFound()); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -654,7 +653,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet .ReturnsAsync(Result.NotFound()); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -749,7 +748,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_ProductId this.AggregateService.Setup(e => e.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -774,7 +773,7 @@ public async Task TransactionValidationService_ValidateSaleTransaction_Successfu this.AggregateService.SetupSequence(m => m.Get(It.IsAny(), It.IsAny())).ReturnsAsync(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Immediate)); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); + .ReturnsAsync(StringSerialiser.Serialise(TestData.MerchantBalanceProjectionState)); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs index 4e595170..7c59d143 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs @@ -17,8 +17,10 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; + using Shared.Serialisation; using Shouldly; using System; + using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Testing; @@ -34,6 +36,7 @@ public class VoucherDomainServiceTests private readonly Mock> DbContextFactory; public VoucherDomainServiceTests() { + StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions())); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); diff --git a/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj b/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj index 2bd204d8..78848b0b 100644 --- a/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj +++ b/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj @@ -8,7 +8,6 @@ - diff --git a/TransactionProcessor.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs index b28b5543..fc37fa98 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/MerchantDomainEventHandler.cs @@ -1,5 +1,4 @@ using MediatR; -using Newtonsoft.Json; using Polly; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; @@ -9,6 +8,7 @@ using System; using System.Threading; using System.Threading.Tasks; +using Shared.Serialisation; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; using TransactionProcessor.BusinessLogic.Events; @@ -65,7 +65,7 @@ private async Task HandleSpecificDomainEvent(CallbackReceivedEnrichedEve return ResultHelpers.CreateFailure(result); // We now need to deserialise the message from the callback - CallbackHandler.DataTransferObjects.Deposit callbackMessage = JsonConvert.DeserializeObject(domainEvent.CallbackMessage); + CallbackHandler.DataTransferObjects.Deposit callbackMessage = StringSerialiser.Deserialise(domainEvent.CallbackMessage); MerchantCommands.MakeMerchantDepositCommand command = new(domainEvent.EstateId, result.Data.MerchantId, DataTransferObjects.Requests.Merchant.MerchantDepositSource.Automatic, new MakeMerchantDepositRequest { DepositDateTime = callbackMessage.DateTime, Reference = callbackMessage.Reference, Amount = callbackMessage.Amount, }); return await this.Mediator.Send(command, cancellationToken); diff --git a/TransactionProcessor.BusinessLogic/Events/CallbackReceivedEnrichedEvent.cs b/TransactionProcessor.BusinessLogic/Events/CallbackReceivedEnrichedEvent.cs index 421950aa..4ae03e5b 100644 --- a/TransactionProcessor.BusinessLogic/Events/CallbackReceivedEnrichedEvent.cs +++ b/TransactionProcessor.BusinessLogic/Events/CallbackReceivedEnrichedEvent.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; using Shared.DomainDrivenDesign.EventSourcing; namespace TransactionProcessor.BusinessLogic.Events @@ -32,49 +31,14 @@ public CallbackReceivedEnrichedEvent(Guid aggregateId, Guid estateId, Int32 mess #region Properties - /// - /// Gets or sets the callback message. - /// - /// - /// The callback message. - /// - [JsonProperty("callbackMessage")] public String CallbackMessage { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estateid")] public Guid EstateId { get; set; } - /// - /// Gets or sets the message format. - /// - /// - /// The message format. - /// - [JsonProperty("messageFormat")] public Int32 MessageFormat { get; set; } - /// - /// Gets or sets the reference. - /// - /// - /// The reference. - /// - [JsonProperty("reference")] public String Reference { get; set; } - /// - /// Gets or sets the type string. - /// - /// - /// The type string. - /// - [JsonProperty("typeString")] public String TypeString { get; set; } #endregion diff --git a/TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPrePay/PataPawaPrePayProxy.cs b/TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPrePay/PataPawaPrePayProxy.cs index 48e4f498..695bf5a3 100644 --- a/TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPrePay/PataPawaPrePayProxy.cs +++ b/TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPrePay/PataPawaPrePayProxy.cs @@ -1,17 +1,20 @@ -using System.Diagnostics.CodeAnalysis; +using Shared.Serialisation; using SimpleResults; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; namespace TransactionProcessor.BusinessLogic.OperatorInterfaces.PataPawaPrePay; +using Common; +using Microsoft.Extensions.Caching.Memory; +using Shared.Logger; using System; using System.Collections.Generic; +using System.Globalization; using System.Net.Http; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using Common; -using Microsoft.Extensions.Caching.Memory; -using Newtonsoft.Json; -using Shared.Logger; public class PataPawaPrePayProxy : IOperatorProxy{ private readonly PataPawaPrePaidConfiguration Configuration; @@ -157,7 +160,7 @@ private async Task> PerformVendTransaction(String meter } private Result CreateFromLogon(String responseContent){ - LogonResponse logonResponse = JsonConvert.DeserializeObject(responseContent); + LogonResponse logonResponse = StringSerialiser.Deserialise(responseContent); if (logonResponse.Status != 0) { return Result.Failure($"Error logging on with PataPawa Pre Paid API, Response is {logonResponse.Status}"); @@ -180,7 +183,7 @@ private Result CreateFromLogon(String responseContent){ private Result CreateFromMeter(String responseContent) { - MeterResponse meterResponse = JsonConvert.DeserializeObject(responseContent); + MeterResponse meterResponse = StringSerialiser.Deserialise(responseContent); if (meterResponse.Status != 0) { @@ -202,7 +205,7 @@ private Result CreateFromMeter(String responseContent) private Result CreateFromVend(String responseContent) { - VendResponse vendResponse = JsonConvert.DeserializeObject(responseContent); + VendResponse vendResponse = StringSerialiser.Deserialise(responseContent); if (vendResponse.Status != 0) { @@ -245,4 +248,49 @@ private void PostEvictionCallback(Object key, this.ProcessLogonMessage(CancellationToken.None).Wait(); } } + + public class DateTimeSpaceConverter : JsonConverter + { + private static readonly string[] AcceptedFormats = new[] { + "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd H:mm:ss", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm:ss.FFFFFFFK", "o" // ISO 8601 round-trip + }; + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.Null) + { + return default; + } + + if (reader.TokenType == JsonTokenType.String) + { + var s = reader.GetString(); + if (string.IsNullOrWhiteSpace(s)) + return default; + + // Try exact known formats first (handles "2026-05-07 06:03:18") + if (DateTime.TryParseExact(s, AcceptedFormats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal | DateTimeStyles.AllowWhiteSpaces, out var dtExact)) + return dtExact; + + // Fall back to general parse + if (DateTime.TryParse(s, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var dt)) + return dt; + + throw new JsonException($"Unable to parse DateTime: '{s}'."); + } + + // If JSON contains a number, attempt to treat it as Unix seconds (optional) + if (reader.TokenType == JsonTokenType.Number && reader.TryGetInt64(out long seconds)) + { + return DateTimeOffset.FromUnixTimeSeconds(seconds).LocalDateTime; + } + + throw new JsonException($"Unexpected token parsing DateTime. Token: {reader.TokenType}"); + } + + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + { + // Write in the same "space" format so round-trip matches your input + writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); + } + } } \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs b/TransactionProcessor.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs index a7337110..0f350853 100644 --- a/TransactionProcessor.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs +++ b/TransactionProcessor.BusinessLogic/RequestHandlers/MerchantRequestHandler.cs @@ -3,8 +3,8 @@ using System.Threading; using System.Threading.Tasks; using MediatR; -using Newtonsoft.Json; using Shared.EventStore.EventStore; +using Shared.Serialisation; using SimpleResults; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.Requests; @@ -76,8 +76,8 @@ public async Task> Handle(MerchantQuerie if (result.IsFailed) return Result.NotFound( $"Merchant Balance not found for Merchant {query.MerchantId} on MerchantBalanceProjection"); - - MerchantBalanceProjectionState1 projectionState = JsonConvert.DeserializeObject(result.Data); + var json = result.Data.ToLower(); + MerchantBalanceProjectionState1 projectionState = StringSerialiser.Deserialise(json, new SerialiserOptions(SerialiserPropertyFormat.CamelCase)); return Result.Success(projectionState); } diff --git a/TransactionProcessor.BusinessLogic/Services/ContractDomainService.cs b/TransactionProcessor.BusinessLogic/Services/ContractDomainService.cs index 7814e00a..eb7a1c1a 100644 --- a/TransactionProcessor.BusinessLogic/Services/ContractDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/ContractDomainService.cs @@ -1,15 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; using Shared.Exceptions; using Shared.Results; +using Shared.Serialisation; using SimpleResults; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; @@ -199,19 +197,21 @@ private async Task ValidateContractCreationPreConditions(ContractCommand return Result.NotFound($"Unable to create a contract for an operator that is not setup on estate [{estate.Name}]"); String projection = - $"fromCategory(\"ContractAggregate\")\n.when({{\n $init: function (s, e) {{\n return {{\n total: 0,\n contractId: 0\n }};\n }},\n 'ContractCreatedEvent': function(s,e){{\n // Check if it matches\n if (e.data.description === '{command.RequestDTO.Description}' \n && e.data.operatorId === '{command.RequestDTO.OperatorId}'){{\n s.total += 1;\n s.contractId = e.data.contractId\n }}\n }}\n}})"; + $"fromCategory(\"ContractAggregate\")\n.when({{\n $init: function (s, e) {{\n return {{\n total: 0,\n contractId: 0\n }};\n }},\n 'ContractCreatedEvent': function(s,e){{\n // Check if it matches\n if (e.data.description === '{command.RequestDTO.Description}' \n && e.data.operatorId === '{command.RequestDTO.OperatorId}'){{\n s.total += 1;\n s.contract_Id = e.data.contractId\n }}\n }}\n}})"; Result result = await this.Context.RunTransientQuery(projection, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); String resultString = result.Data; - if (String.IsNullOrEmpty(resultString) == false) - { - JObject jsonResult = JObject.Parse(resultString); - String contractIdString = jsonResult["contractId"]?.Value(); - if (Guid.TryParse(contractIdString, out Guid contractIdResult) && contractIdResult != Guid.Empty) + if (String.IsNullOrEmpty(resultString) == false) { + var resultObject = new { total = 0, contract_Id = String.Empty }; + + var queryResult = StringSerialiser.DeserialiseAnonymousType(resultString, resultObject); + + if (Guid.TryParse(queryResult.contract_Id, out Guid contractIdResult) && contractIdResult != Guid.Empty){ return Result.Conflict($"Contract Description {command.RequestDTO.Description} already in use for operator {command.RequestDTO.OperatorId}"); + } } return Result.Success(); diff --git a/TransactionProcessor.BusinessLogic/Services/IdGenerationService.cs b/TransactionProcessor.BusinessLogic/Services/IdGenerationService.cs index 5c95319d..abb0b993 100644 --- a/TransactionProcessor.BusinessLogic/Services/IdGenerationService.cs +++ b/TransactionProcessor.BusinessLogic/Services/IdGenerationService.cs @@ -6,7 +6,6 @@ namespace TransactionProcessor.BusinessLogic.Services { using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; - using Newtonsoft.Json; using Shared.Serialisation; [ExcludeFromCodeCoverage] diff --git a/TransactionProcessor.BusinessLogic/Services/MerchantDomainService.cs b/TransactionProcessor.BusinessLogic/Services/MerchantDomainService.cs index 89c6268b..744b7bfd 100644 --- a/TransactionProcessor.BusinessLogic/Services/MerchantDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/MerchantDomainService.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; -using SecurityService.Client; +using SecurityService.Client; using SecurityService.DataTransferObjects; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; @@ -14,6 +13,7 @@ using System.Threading; using System.Threading.Tasks; using KurrentDB.Client; +using Shared.Serialisation; using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; using TransactionProcessor.BusinessLogic.Requests; @@ -802,7 +802,7 @@ private async Task ValidateWithdrawalBalance(MerchantCommands.MakeMercha return Result.Invalid($"Failed to get Merchant Balance."); } - MerchantBalanceProjectionState1 projectionState = JsonConvert.DeserializeObject(getBalanceResult.Data); + MerchantBalanceProjectionState1 projectionState = StringSerialiser.Deserialise(getBalanceResult.Data); if (projectionState?.merchant == null) { return Result.Invalid("Merchant Balance data is missing or invalid."); diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs index 88155658..0a3c1073 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs @@ -475,6 +475,7 @@ private async Task> ProcessMessageWithOperator(Models.M catch (Exception e) { // Log out the error Logger.LogError(e); + Logger.LogWarning(e.StackTrace); return ResultHelpers.CreateFailedResult(new OperatorResponse { IsSuccessful = false, ResponseCode = "9999", ResponseMessage = e.GetCombinedExceptionMessages() }); } } diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs index aa8686d0..51f4368b 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs @@ -6,15 +6,15 @@ namespace TransactionProcessor.BusinessLogic.Services; +using ProjectionEngine.State; +using Shared.EventStore.EventStore; +using Shared.Serialisation; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Newtonsoft.Json; -using ProjectionEngine.State; -using Shared.EventStore.EventStore; public interface ITransactionValidationService { @@ -305,7 +305,7 @@ private async Task> ValidateTransactionAmoun return CreateFailedResult(new TransactionValidationResult(TransactionResponseCode.UnknownFailure, $"Error getting balance for Merchant [{merchantName}]")); } - MerchantBalanceProjectionState1 projectionState = JsonConvert.DeserializeObject(getBalanceResult.Data); + MerchantBalanceProjectionState1 projectionState = StringSerialiser.Deserialise(getBalanceResult.Data); if (projectionState.merchant.balance < transactionAmount) { return CreateFailedResult(new TransactionValidationResult(TransactionResponseCode.MerchantDoesNotHaveEnoughCredit, $"Merchant [{merchantName}] does not have enough credit available [{projectionState.merchant.balance:0.00}] to perform transaction amount [{transactionAmount}]")); diff --git a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj index 013a38b5..1a228469 100644 --- a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj +++ b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj @@ -6,15 +6,15 @@ - + - - + + diff --git a/TransactionProcessor.Client/ITransactionProcessorClient.cs b/TransactionProcessor.Client/ITransactionProcessorClient.cs index 1494ab84..f745a247 100644 --- a/TransactionProcessor.Client/ITransactionProcessorClient.cs +++ b/TransactionProcessor.Client/ITransactionProcessorClient.cs @@ -21,9 +21,18 @@ namespace TransactionProcessor.Client public interface ITransactionProcessorClient { #region Methods - Task> PerformTransaction(String accessToken, - SerialisedMessage transactionRequest, - CancellationToken cancellationToken); + + Task> PerformTransaction(String accessToken, + ReconciliationRequest transactionRequest, + CancellationToken cancellationToken); + + Task> PerformTransaction(String accessToken, + SaleTransactionRequest transactionRequest, + CancellationToken cancellationToken); + + Task> PerformTransaction(String accessToken, + LogonTransactionRequest transactionRequest, + CancellationToken cancellationToken); Task> GetSettlementByDate(String accessToken, DateTime settlementDate, diff --git a/TransactionProcessor.Client/TransactionProcessor.Client.csproj b/TransactionProcessor.Client/TransactionProcessor.Client.csproj index d4236ab8..32e6da9a 100644 --- a/TransactionProcessor.Client/TransactionProcessor.Client.csproj +++ b/TransactionProcessor.Client/TransactionProcessor.Client.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/TransactionProcessor.Client/TransactionProcessorClient.cs b/TransactionProcessor.Client/TransactionProcessorClient.cs index ca8839b0..1387ce71 100644 --- a/TransactionProcessor.Client/TransactionProcessorClient.cs +++ b/TransactionProcessor.Client/TransactionProcessorClient.cs @@ -1,4 +1,3 @@ -using SecurityService.Client; using SimpleResults; using TransactionProcessor.DataTransferObjects.Requests.Contract; using TransactionProcessor.DataTransferObjects.Requests.Estate; @@ -16,13 +15,10 @@ namespace TransactionProcessor.Client; using System; using System.Collections.Generic; using System.Net.Http; -using System.Net.Http.Headers; -using System.Text; using System.Threading; using System.Threading.Tasks; using ClientProxyBase; using DataTransferObjects; -using Newtonsoft.Json; using Shared.Results; public class TransactionProcessorClient : ClientProxyBase, ITransactionProcessorClient { @@ -269,12 +265,12 @@ public async Task> GetVoucherByTransactionId(String a } } - public async Task> PerformTransaction(String accessToken, - SerialisedMessage transactionRequest, + public async Task> PerformTransaction(String accessToken, + LogonTransactionRequest transactionRequest, CancellationToken cancellationToken) { - String requestUri = this.BuildRequestUrl($"/api/transactions"); + String requestUri = this.BuildRequestUrl($"/api/transactions/logon"); try { - var result = await this.Post(requestUri, transactionRequest, accessToken, cancellationToken); + var result = await this.Post(requestUri, transactionRequest, accessToken, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -283,7 +279,53 @@ public async Task> PerformTransaction(String accessTok } catch (Exception ex) { // An exception has occurred, add some additional information to the message - Exception exception = new("Error posting transaction.", ex); + Exception exception = new("Error posting logon transaction.", ex); + + throw exception; + } + } + + public async Task> PerformTransaction(String accessToken, + SaleTransactionRequest transactionRequest, + CancellationToken cancellationToken) + { + String requestUri = this.BuildRequestUrl($"/api/transactions/sale"); + try + { + var result = await this.Post(requestUri, transactionRequest, accessToken, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(result.Data); + } + catch (Exception ex) + { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error posting logon transaction.", ex); + + throw exception; + } + } + + public async Task> PerformTransaction(String accessToken, + ReconciliationRequest transactionRequest, + CancellationToken cancellationToken) + { + String requestUri = this.BuildRequestUrl($"/api/transactions/reconciliation"); + try + { + var result = await this.Post(requestUri, transactionRequest, accessToken, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(result.Data); + } + catch (Exception ex) + { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error posting logon transaction.", ex); throw exception; } diff --git a/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs b/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs index 59838c6b..2c158d42 100644 --- a/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs +++ b/TransactionProcessor.DataTransferObjects/CreateFloatForContractProductRequest.cs @@ -1,37 +1,27 @@ using System; namespace TransactionProcessor.DataTransferObjects{ - using Newtonsoft.Json; public class CreateFloatForContractProductRequest{ - [JsonProperty("contract_id")] public Guid ContractId{ get; set; } - [JsonProperty("product_id")] public Guid ProductId{ get; set; } - [JsonProperty("create_date_time")] public DateTime CreateDateTime{ get; set; } } public class CreateFloatForContractProductResponse { - [JsonProperty("float_id")] public Guid FloatId { get; set; } } public class RecordFloatCreditPurchaseRequest{ - [JsonProperty("float_id")] public Guid FloatId { get; set; } - [JsonProperty("purchase_date_time")] public DateTime PurchaseDateTime { get; set; } - [JsonProperty("credit_amount")] public Decimal CreditAmount { get; set; } - - [JsonProperty("cost_price")] public Decimal CostPrice { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/DataTransferObject.cs b/TransactionProcessor.DataTransferObjects/DataTransferObject.cs index 4a49e602..11fe1bd6 100644 --- a/TransactionProcessor.DataTransferObjects/DataTransferObject.cs +++ b/TransactionProcessor.DataTransferObjects/DataTransferObject.cs @@ -1,45 +1,35 @@ namespace TransactionProcessor.DataTransferObjects { using System; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - - /// - /// - /// + [ExcludeFromCodeCoverage] - public class DataTransferObject + public class TransactionRequest { #region Properties - // This only here as a shell base class... - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the transaction date time. - /// - /// - /// The transaction date time. - /// - [JsonProperty("transaction_date_time")] public DateTime TransactionDateTime { get; set; } + public String TransactionType { get; set; } + #endregion } + + public class TransactionResponse { + public Guid EstateId { get; set; } + + public Guid MerchantId { get; set; } + + public String ResponseCode { get; set; } + + public String ResponseMessage { get; set; } + + public Guid TransactionId { get; set; } + public String TransactionType { get; set; } + } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/GetVoucherResponse.cs b/TransactionProcessor.DataTransferObjects/GetVoucherResponse.cs index 108f74df..5ec30052 100644 --- a/TransactionProcessor.DataTransferObjects/GetVoucherResponse.cs +++ b/TransactionProcessor.DataTransferObjects/GetVoucherResponse.cs @@ -1,108 +1,30 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects { public class GetVoucherResponse { - [JsonProperty("voucher_id")] public Guid VoucherId { get; set; } - /// - /// Gets the expiry date. - /// - /// - /// The expiry date. - /// - [JsonProperty("expiry_date")] public DateTime ExpiryDate { get; set; } - /// - /// Gets the value. - /// - /// - /// The value. - /// - [JsonProperty("value")] public Decimal Value { get; set; } - /// - /// Gets or sets the balance. - /// - /// - /// The balance. - /// - [JsonProperty("balance")] public Decimal Balance { get; set; } - /// - /// Gets the voucher code. - /// - /// - /// The voucher code. - /// - [JsonProperty("voucher_code")] public String VoucherCode { get; set; } - /// - /// Gets or sets a value indicating whether this instance is generated. - /// - /// - /// true if this instance is generated; otherwise, false. - /// - [JsonProperty("is_generated")] public Boolean IsGenerated { get; set; } - /// - /// Gets a value indicating whether this instance is issued. - /// - /// - /// true if this instance is issued; otherwise, false. - /// - [JsonProperty("is_issued")] public Boolean IsIssued { get; set; } - - /// - /// Gets or sets a value indicating whether this instance is redeemed. - /// - /// - /// true if this instance is redeemed; otherwise, false. - /// - [JsonProperty("is_redeemed")] public Boolean IsRedeemed { get; set; } - /// - /// Gets or sets the issued date time. - /// - /// - /// The issued date time. - /// - [JsonProperty("issued_date_time")] public DateTime IssuedDateTime { get; set; } - /// - /// Gets or sets the generated date time. - /// - /// - /// The generated date time. - /// - [JsonProperty("generated_date_time")] + public DateTime GeneratedDateTime { get; set; } - /// - /// Gets or sets the redeemed date time. - /// - /// - /// The redeemed date time. - /// - [JsonProperty("redeemed_date_time")] + public DateTime RedeemedDateTime { get; set; } - - /// - /// Gets or sets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - [JsonProperty("transaction_id")] + public Guid TransactionId { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/IssueVoucherRequest.cs b/TransactionProcessor.DataTransferObjects/IssueVoucherRequest.cs index 16d1782a..ddd2872f 100644 --- a/TransactionProcessor.DataTransferObjects/IssueVoucherRequest.cs +++ b/TransactionProcessor.DataTransferObjects/IssueVoucherRequest.cs @@ -1,71 +1,21 @@ namespace TransactionProcessor.DataTransferObjects { using System; - using Newtonsoft.Json; - + public class IssueVoucherRequest { - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_identifier")] public String OperatorIdentifier { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - [JsonProperty("transaction_id")] public Guid TransactionId { get; set; } - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - [JsonProperty("value")] public Decimal Value { get; set; } - /// - /// Gets or sets the recipient email. - /// - /// - /// The recipient email. - /// - [JsonProperty("recipient_email")] public String RecipientEmail { get; set; } - /// - /// Gets or sets the recipient mobile. - /// - /// - /// The recipient mobile. - /// - [JsonProperty("recipient_mobile")] public String RecipientMobile { get; set; } - /// - /// Gets or sets the issued date time. - /// - /// - /// The issued date time. - /// - [JsonProperty("issued_date_time")] public DateTime? IssuedDateTime { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/IssueVoucherResponse.cs b/TransactionProcessor.DataTransferObjects/IssueVoucherResponse.cs index 65f89500..92fe8f5f 100644 --- a/TransactionProcessor.DataTransferObjects/IssueVoucherResponse.cs +++ b/TransactionProcessor.DataTransferObjects/IssueVoucherResponse.cs @@ -1,44 +1,15 @@ namespace TransactionProcessor.DataTransferObjects { using System; - using Newtonsoft.Json; public class IssueVoucherResponse { - /// - /// Gets or sets the voucher identifier. - /// - /// - /// The voucher identifier. - /// - [JsonProperty("voucher_id")] public Guid VoucherId { get; set; } - /// - /// Gets or sets the expiry date. - /// - /// - /// The expiry date. - /// - [JsonProperty("expiry_date")] public DateTime ExpiryDate { get; set; } - /// - /// Gets or sets the voucher code. - /// - /// - /// The voucher code. - /// - [JsonProperty("voucher_code")] public String VoucherCode { get; set; } - /// - /// Gets or sets the message. - /// - /// - /// The message. - /// - [JsonProperty("message")] public String Message { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/LogonTransactionRequest.cs b/TransactionProcessor.DataTransferObjects/LogonTransactionRequest.cs index 34aa95fa..4e31f4a0 100644 --- a/TransactionProcessor.DataTransferObjects/LogonTransactionRequest.cs +++ b/TransactionProcessor.DataTransferObjects/LogonTransactionRequest.cs @@ -2,41 +2,16 @@ { using System; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - - /// - /// - /// + [ExcludeFromCodeCoverage] - public class LogonTransactionRequest : DataTransferObject + public class LogonTransactionRequest : TransactionRequest { #region Properties - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("device_identifier")] public String DeviceIdentifier { get; set; } - /// - /// Gets or sets the transaction number. - /// - /// - /// The transaction number. - /// - [JsonProperty("transaction_number")] public String TransactionNumber { get; set; } - /// - /// Gets or sets the type of the transaction. - /// - /// - /// The type of the transaction. - /// - [JsonProperty("transaction_type")] public String TransactionType { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/LogonTransactionResponse.cs b/TransactionProcessor.DataTransferObjects/LogonTransactionResponse.cs index 75814297..9c67e331 100644 --- a/TransactionProcessor.DataTransferObjects/LogonTransactionResponse.cs +++ b/TransactionProcessor.DataTransferObjects/LogonTransactionResponse.cs @@ -2,61 +2,10 @@ { using System; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - - /// - /// - /// + [ExcludeFromCodeCoverage] - public class LogonTransactionResponse + public class LogonTransactionResponse : TransactionResponse { - #region Properties - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] - public Guid EstateId { get; set; } - - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] - public Guid MerchantId { get; set; } - - /// - /// Gets or sets the response code. - /// - /// - /// The response code. - /// - [JsonProperty("response_code")] - public String ResponseCode { get; set; } - - /// - /// Gets or sets the response message. - /// - /// - /// The response message. - /// - [JsonProperty("response_message")] - public String ResponseMessage { get; set; } - - /// - /// Gets or sets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - [JsonProperty("transaction_id")] - public Guid TransactionId { get; set; } - - #endregion + } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/MerchantBalanceChangedEntryResponse.cs b/TransactionProcessor.DataTransferObjects/MerchantBalanceChangedEntryResponse.cs index 657b7762..6758780b 100644 --- a/TransactionProcessor.DataTransferObjects/MerchantBalanceChangedEntryResponse.cs +++ b/TransactionProcessor.DataTransferObjects/MerchantBalanceChangedEntryResponse.cs @@ -1,5 +1,4 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects { @@ -8,28 +7,20 @@ namespace TransactionProcessor.DataTransferObjects [ExcludeFromCodeCoverage] public class MerchantBalanceChangedEntryResponse { - [JsonProperty("original_event_id")] public Guid OriginalEventId { get; set; } - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - [JsonProperty("change_amount")] public Decimal ChangeAmount { get; set; } - [JsonProperty("date_time")] public DateTime DateTime { get; set; } - [JsonProperty("reference")] public String Reference { get; set; } - [JsonProperty("debit_or_credit")] public String DebitOrCredit { get; set; } - [JsonProperty("balance")] public Decimal Balance { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/MerchantBalanceResponse.cs b/TransactionProcessor.DataTransferObjects/MerchantBalanceResponse.cs index c947337e..cd913ec3 100644 --- a/TransactionProcessor.DataTransferObjects/MerchantBalanceResponse.cs +++ b/TransactionProcessor.DataTransferObjects/MerchantBalanceResponse.cs @@ -2,45 +2,16 @@ { using System; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; [ExcludeFromCodeCoverage] public class MerchantBalanceResponse { - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the available balance. - /// - /// - /// The available balance. - /// - [JsonProperty("available_balance")] public Decimal AvailableBalance { get; set; } - /// - /// Gets or sets the balance. - /// - /// - /// The balance. - /// - [JsonProperty("balance")] public Decimal Balance { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/OperatorTotalRequest.cs b/TransactionProcessor.DataTransferObjects/OperatorTotalRequest.cs index fffa4026..e002304d 100644 --- a/TransactionProcessor.DataTransferObjects/OperatorTotalRequest.cs +++ b/TransactionProcessor.DataTransferObjects/OperatorTotalRequest.cs @@ -2,50 +2,18 @@ { using System; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - - /// - /// - /// + [ExcludeFromCodeCoverage] public class OperatorTotalRequest { #region Properties - /// - /// Gets or sets the contract identifier. - /// - /// - /// The contract identifier. - /// - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets or sets the transaction count. - /// - /// - /// The transaction count. - /// - [JsonProperty("transaction_count")] public Int32 TransactionCount { get; set; } - /// - /// Gets or sets the transaction value. - /// - /// - /// The transaction value. - /// - [JsonProperty("transaction_cvalue")] public Decimal TransactionValue { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/ReconciliationRequest.cs b/TransactionProcessor.DataTransferObjects/ReconciliationRequest.cs index 6b0b2a5c..f460cd1f 100644 --- a/TransactionProcessor.DataTransferObjects/ReconciliationRequest.cs +++ b/TransactionProcessor.DataTransferObjects/ReconciliationRequest.cs @@ -3,51 +3,18 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - - /// - /// - /// - /// + [ExcludeFromCodeCoverage] - public class ReconciliationRequest : DataTransferObject + public class ReconciliationRequest : TransactionRequest { #region Properties - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("device_identifier")] public String DeviceIdentifier { get; set; } - /// - /// Gets or sets the operator totals. - /// - /// - /// The operator totals. - /// - [JsonProperty("operator_totals")] public List OperatorTotals { get; set; } - /// - /// Gets or sets the transaction count. - /// - /// - /// The transaction count. - /// - [JsonProperty("transaction_count")] public Int32 TransactionCount { get; set; } - /// - /// Gets or sets the transaction value. - /// - /// - /// The transaction value. - /// - [JsonProperty("transaction_value")] public Decimal TransactionValue { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/ReconciliationResponse.cs b/TransactionProcessor.DataTransferObjects/ReconciliationResponse.cs index 6ac7e86e..783b7c71 100644 --- a/TransactionProcessor.DataTransferObjects/ReconciliationResponse.cs +++ b/TransactionProcessor.DataTransferObjects/ReconciliationResponse.cs @@ -2,58 +2,10 @@ { using System; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - + [ExcludeFromCodeCoverage] - public class ReconciliationResponse + public class ReconciliationResponse : TransactionResponse { - #region Properties - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] - public Guid EstateId { get; set; } - - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] - public Guid MerchantId { get; set; } - - /// - /// Gets or sets the response code. - /// - /// - /// The response code. - /// - [JsonProperty("response_code")] - public String ResponseCode { get; set; } - - /// - /// Gets or sets the response message. - /// - /// - /// The response message. - /// - [JsonProperty("response_message")] - public String ResponseMessage { get; set; } - - /// - /// Gets or sets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - [JsonProperty("transaction_id")] - public Guid TransactionId { get; set; } - - #endregion + } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/RedeemVoucherRequest.cs b/TransactionProcessor.DataTransferObjects/RedeemVoucherRequest.cs index 2e3be3cc..18956468 100644 --- a/TransactionProcessor.DataTransferObjects/RedeemVoucherRequest.cs +++ b/TransactionProcessor.DataTransferObjects/RedeemVoucherRequest.cs @@ -1,29 +1,13 @@ namespace TransactionProcessor.DataTransferObjects { using System; - using Newtonsoft.Json; public class RedeemVoucherRequest { - /// - /// Gets or sets the voucher code. - /// - /// - /// The voucher code. - /// - [JsonProperty("voucher_code")] public String VoucherCode { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - [JsonProperty("redeemed_date_time")] public DateTime? RedeemedDateTime { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs b/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs index d3f0db99..d2953bbc 100644 --- a/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs +++ b/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs @@ -1,35 +1,12 @@ namespace TransactionProcessor.DataTransferObjects { using System; - using Newtonsoft.Json; - public class RedeemVoucherResponse { - /// - /// Gets or sets the expiry date. - /// - /// - /// The expiry date. - /// - [JsonProperty("expiry_date")] public DateTime ExpiryDate { get; set; } - /// - /// Gets or sets the voucher code. - /// - /// - /// The voucher code. - /// - [JsonProperty("voucher_code")] public String VoucherCode { get; set; } - /// - /// Gets or sets the remaining balance. - /// - /// - /// The remaining balance. - /// - [JsonProperty("remaining_balance")] public Decimal RemainingBalance { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs index ab5207e4..63257d47 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs @@ -1,5 +1,4 @@ using System; -using Newtonsoft.Json; using TransactionProcessor.DataTransferObjects.Responses.Contract; namespace TransactionProcessor.DataTransferObjects.Requests.Contract @@ -11,40 +10,12 @@ public class AddProductToContractRequest { #region Properties - /// - /// Gets or sets the display text. - /// - /// - /// The display text. - /// - [JsonProperty("display_text")] public String DisplayText { get; set; } - /// - /// Gets or sets the name of the product. - /// - /// - /// The name of the product. - /// - [JsonProperty("product_name")] public String ProductName { get; set; } - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - [JsonProperty("value")] public Decimal? Value { get; set; } - /// - /// Gets or sets the type of the product. - /// - /// - /// The type of the product. - /// - [JsonProperty("product_type")] public ProductType ProductType { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs index af915423..9d81f020 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs @@ -1,5 +1,4 @@ using System; -using Newtonsoft.Json; using TransactionProcessor.DataTransferObjects.Responses.Contract; namespace TransactionProcessor.DataTransferObjects.Requests.Contract @@ -11,40 +10,12 @@ public class AddTransactionFeeForProductToContractRequest { #region Properties - /// - /// Gets or sets the type of the calculation. - /// - /// - /// The type of the calculation. - /// - [JsonProperty("calculation_type")] public CalculationType CalculationType { get; set; } - /// - /// Gets or sets the description. - /// - /// - /// The description. - /// - [JsonProperty("description")] public String Description { get; set; } - /// - /// Gets or sets the type of the fee. - /// - /// - /// The type of the fee. - /// - [JsonProperty("fee_type")] public FeeType FeeType { get; set; } - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - [JsonProperty("value")] public Decimal Value { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs index 5bd1ce1a..1ba75888 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs @@ -1,28 +1,13 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Contract { [ExcludeFromCodeCoverage] public class CreateContractRequest { - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets or sets the description. - /// - /// - /// The description. - /// - [JsonProperty("description")] public String Description { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs index 1757f063..ba6b6271 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs @@ -1,7 +1,6 @@ using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Estate { @@ -13,14 +12,6 @@ public class AssignOperatorRequest { #region Properties - /// - /// Gets or sets the name. - /// - /// - /// The name. - /// - [Required] - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs index 422e0a1a..cadce77a 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs @@ -1,29 +1,12 @@ using System; using System.ComponentModel.DataAnnotations; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Estate { public class CreateEstateRequest { - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [Required] - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the name of the estate. - /// - /// - /// The name of the estate. - /// - [Required] - [JsonProperty("estate_name")] public String EstateName { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs index b1826d83..22a89b9d 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs @@ -1,54 +1,20 @@ using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Estate { [ExcludeFromCodeCoverage] public class CreateEstateUserRequest { - [Required] - [JsonProperty("email_address")] public String EmailAddress { get; set; } - /// - /// Gets or sets the password. - /// - /// - /// The password. - /// - [Required] - [JsonProperty("password")] public String Password { get; set; } - /// - /// Gets or sets the name of the given. - /// - /// - /// The name of the given. - /// - [Required] - [JsonProperty("given_name")] public String GivenName { get; set; } - /// - /// Gets or sets the name of the middle. - /// - /// - /// The name of the middle. - /// - [JsonProperty("middle_name")] public String MiddleName { get; set; } - /// - /// Gets or sets the name of the family. - /// - /// - /// The name of the family. - /// - [Required] - [JsonProperty("family_name")] public String FamilyName { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs index f5bb45df..efe53ff6 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs @@ -1,12 +1,10 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant{ [ExcludeFromCodeCoverage] public class AddMerchantContractRequest - { - [JsonProperty("contract_id")] + { public Guid ContractId { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs index 043d242d..1afb31ac 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs @@ -1,19 +1,11 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { [ExcludeFromCodeCoverage] public class AddMerchantDeviceRequest { - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("device_identifier")] public String DeviceIdentifier { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs index 77939632..69620c68 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs @@ -1,90 +1,25 @@ using System; using System.ComponentModel.DataAnnotations; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { - /// - /// - /// public class Address { #region Properties - /// - /// Gets or sets the address line1. - /// - /// - /// The address line1. - /// - [JsonProperty("address_line1")] - [Required] public String AddressLine1 { get; set; } - /// - /// Gets or sets the address line2. - /// - /// - /// The address line2. - /// - [JsonProperty("address_line2")] public String AddressLine2 { get; set; } - /// - /// Gets or sets the address line3. - /// - /// - /// The address line3. - /// - [JsonProperty("address_line3")] public String AddressLine3 { get; set; } - /// - /// Gets or sets the address line4. - /// - /// - /// The address line4. - /// - [JsonProperty("address_line4")] public String AddressLine4 { get; set; } - /// - /// Gets or sets the country. - /// - /// - /// The country. - /// - [JsonProperty("country")] - [Required] public String Country { get; set; } - /// - /// Gets or sets the postal code. - /// - /// - /// The postal code. - /// - [JsonProperty("postal_code")] public String PostalCode { get; set; } - /// - /// Gets or sets the region. - /// - /// - /// The region. - /// - [JsonProperty("region")] - [Required] public String Region { get; set; } - - /// - /// Gets or sets the town. - /// - /// - /// The town. - /// - [JsonProperty("town")] - [Required] public String Town { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs index d2c44d0b..b86aade4 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { @@ -12,31 +11,10 @@ public class AssignOperatorRequest { #region Properties - /// - /// Gets or sets the merchant number. - /// - /// - /// The merchant number. - /// - [JsonProperty("merchant_number")] public String MerchantNumber { get; set; } - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets or sets the terminal number. - /// - /// - /// The terminal number. - /// - [JsonProperty("terminal_number")] public String TerminalNumber { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs index bb4342cb..f876a88f 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs @@ -1,43 +1,16 @@ using System; using System.ComponentModel.DataAnnotations; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { - /// - /// - /// public class Contact { #region Properties - /// - /// Gets or sets the name of the contact. - /// - /// - /// The name of the contact. - /// - [JsonProperty("contact_name")] - [Required] public String ContactName { get; set; } - /// - /// Gets or sets the email address. - /// - /// - /// The email address. - /// - [JsonProperty("email_address")] - [Required] public String EmailAddress { get; set; } - /// - /// Gets or sets the phone number. - /// - /// - /// The phone number. - /// - [JsonProperty("phone_number")] public String PhoneNumber { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs index ace015d4..e40bda8c 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel.DataAnnotations; -using Newtonsoft.Json; using TransactionProcessor.DataTransferObjects.Responses.Merchant; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant @@ -12,43 +11,16 @@ public class CreateMerchantRequest { #region Properties - /// - /// Gets or sets the address. - /// - /// - /// The address. - /// - [JsonProperty("address")] - [Required] public Address Address { get; set; } - /// - /// Gets or sets the contact. - /// - /// - /// The contact. - /// - [JsonProperty("contact")] - [Required] public Contact Contact { get; set; } - /// - /// Gets or sets the name. - /// - /// - /// The name. - /// - [Required] - [JsonProperty("name")] public String Name { get; set; } - [JsonProperty("settlement_schedule")] public SettlementSchedule SettlementSchedule { get; set; } - [JsonProperty("merchant_id")] public Guid? MerchantId { get; set; } - [JsonProperty("created_date_time")] public DateTime? CreatedDateTime { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs index 70b6482c..400e70ff 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs @@ -1,54 +1,20 @@ using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { [ExcludeFromCodeCoverage] public class CreateMerchantUserRequest { - [Required] - [JsonProperty("email_address")] public String EmailAddress { get; set; } - /// - /// Gets or sets the password. - /// - /// - /// The password. - /// - [Required] - [JsonProperty("password")] public String Password { get; set; } - /// - /// Gets or sets the name of the given. - /// - /// - /// The name of the given. - /// - [Required] - [JsonProperty("given_name")] public String GivenName { get; set; } - /// - /// Gets or sets the name of the middle. - /// - /// - /// The name of the middle. - /// - [JsonProperty("middle_name")] public String MiddleName { get; set; } - /// - /// Gets or sets the name of the family. - /// - /// - /// The name of the family. - /// - [Required] - [JsonProperty("family_name")] public String FamilyName { get; set; } } } diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs index 07202598..eac8147d 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs @@ -1,5 +1,4 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { @@ -7,13 +6,6 @@ public class GenerateMerchantStatementRequest { #region Properties - /// - /// Gets or sets the statement date. - /// - /// - /// The statement date. - /// - [JsonProperty("merchant_statement_date")] public DateTime MerchantStatementDate { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs index 22e4af42..13285d11 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { @@ -12,31 +11,10 @@ public class MakeMerchantDepositRequest { #region Properties - /// - /// Gets or sets the amount. - /// - /// - /// The amount. - /// - [JsonProperty("amount")] public Decimal Amount { get; set; } - /// - /// Gets or sets the deposit date time. - /// - /// - /// The deposit date time. - /// - [JsonProperty("deposit_date_time")] public DateTime DepositDateTime { get; set; } - /// - /// Gets or sets the reference. - /// - /// - /// The reference. - /// - [JsonProperty("reference")] public String Reference { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs index 7893bc28..b1d57e9c 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { @@ -9,31 +8,10 @@ public class MakeMerchantWithdrawalRequest { #region Properties - /// - /// Gets or sets the amount. - /// - /// - /// The amount. - /// - [JsonProperty("amount")] public Decimal Amount { get; set; } - /// - /// Gets or sets the withdrawal date time. - /// - /// - /// The withdrawal date time. - /// - [JsonProperty("withdrawal_date_time")] public DateTime WithdrawalDateTime { get; set; } - /// - /// Gets or sets the reference. - /// - /// - /// The reference. - /// - [JsonProperty("reference")] public String Reference { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs index 62f1665a..bc724c3f 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; using TransactionProcessor.DataTransferObjects.Responses.Merchant; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant @@ -7,7 +6,6 @@ namespace TransactionProcessor.DataTransferObjects.Requests.Merchant [ExcludeFromCodeCoverage] public class SetSettlementScheduleRequest { - [JsonProperty("settlment_schedule")] public SettlementSchedule SettlementSchedule { get; set; } } diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs index d4a42bc9..599d1526 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs @@ -1,17 +1,9 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant { public class SwapMerchantDeviceRequest { - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("new_device_identifier")] public String NewDeviceIdentifier { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs index ab77515d..bffc1136 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs @@ -1,5 +1,4 @@ using System; -using Newtonsoft.Json; using TransactionProcessor.DataTransferObjects.Responses.Merchant; namespace TransactionProcessor.DataTransferObjects.Requests.Merchant @@ -7,11 +6,8 @@ namespace TransactionProcessor.DataTransferObjects.Requests.Merchant public class UpdateMerchantRequest { #region Properties - - [JsonProperty("name")] public String Name { get; set; } - [JsonProperty("settlement_schedule")] public SettlementSchedule SettlementSchedule { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/MerchantSchedule/CreateMerchantScheduleRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/MerchantSchedule/CreateMerchantScheduleRequest.cs index 9933e629..f17ab8a1 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/MerchantSchedule/CreateMerchantScheduleRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/MerchantSchedule/CreateMerchantScheduleRequest.cs @@ -1,34 +1,28 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.MerchantSchedule { [ExcludeFromCodeCoverage] public class CreateMerchantScheduleRequest { - [JsonProperty("year")] public Int32 Year { get; set; } - [JsonProperty("months")] - public System.Collections.Generic.List Months { get; set; } = []; + public List Months { get; set; } = []; } [ExcludeFromCodeCoverage] public class UpdateMerchantScheduleRequest { - [JsonProperty("months")] public List Months { get; set; } = []; } [ExcludeFromCodeCoverage] public class MerchantScheduleMonthRequest { - [JsonProperty("month")] public Int32 Month { get; set; } - [JsonProperty("closed_days")] public List ClosedDays { get; set; } = []; } } diff --git a/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs index 57ab8776..aca1e7bb 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs @@ -1,7 +1,6 @@ using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Operator { @@ -13,38 +12,12 @@ public class CreateOperatorRequest { #region Properties - /// - /// Gets or sets the name. - /// - /// - /// The name. - /// - [Required] - [JsonProperty("name")] public String Name { get; set; } - [Required] - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets or sets a value indicating whether [require custom merchant number]. - /// - /// - /// true if [require custom merchant number]; otherwise, false. - /// - [Required] - [JsonProperty("require_custom_merchant_number")] public Boolean? RequireCustomMerchantNumber { get; set; } - /// - /// Gets or sets a value indicating whether [require custom terminal number]. - /// - /// - /// true if [require custom terminal number]; otherwise, false. - /// - [Required] - [JsonProperty("require_custom_terminal_number")] public Boolean? RequireCustomTerminalNumber { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs index 9ced77a1..876f74e7 100644 --- a/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs +++ b/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs @@ -1,7 +1,6 @@ using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Requests.Operator{ [ExcludeFromCodeCoverage] @@ -9,34 +8,10 @@ public class UpdateOperatorRequest { #region Properties - /// - /// Gets or sets the name. - /// - /// - /// The name. - /// - [Required] - [JsonProperty("name")] public String Name { get; set; } - /// - /// Gets or sets a value indicating whether [require custom merchant number]. - /// - /// - /// true if [require custom merchant number]; otherwise, false. - /// - [Required] - [JsonProperty("require_custom_merchant_number")] public Boolean? RequireCustomMerchantNumber { get; set; } - /// - /// Gets or sets a value indicating whether [require custom terminal number]. - /// - /// - /// true if [require custom terminal number]; otherwise, false. - /// - [Required] - [JsonProperty("require_custom_terminal_number")] public Boolean? RequireCustomTerminalNumber { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs index 5d2b56c4..806f1f18 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { @@ -12,31 +11,10 @@ public class AddProductToContractResponse { #region Properties - /// - /// Gets or sets the contract identifier. - /// - /// - /// The contract identifier. - /// - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the product identifier. - /// - /// - /// The product identifier. - /// - [JsonProperty("product_id")] public Guid ProductId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs index d8b5c76d..7bc8e5b1 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { @@ -9,40 +8,12 @@ public class AddTransactionFeeForProductToContractResponse { #region Properties - /// - /// Gets or sets the contract identifier. - /// - /// - /// The contract identifier. - /// - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the product identifier. - /// - /// - /// The product identifier. - /// - [JsonProperty("product_id")] public Guid ProductId { get; set; } - /// - /// Gets or sets the transaction fee identifier. - /// - /// - /// The transaction fee identifier. - /// - [JsonProperty("transaction_fee_id")] public Guid TransactionFeeId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs index 1a237a6b..718fafa2 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { @@ -8,41 +7,12 @@ namespace TransactionProcessor.DataTransferObjects.Responses.Contract public class ContactResponse { #region Properties - - /// - /// Gets the contact email address. - /// - /// - /// The contact email address. - /// - [JsonProperty("contact_email_address")] public String ContactEmailAddress { get; set; } - /// - /// Gets the contact identifier. - /// - /// - /// The contact identifier. - /// - [JsonProperty("contact_id")] public Guid ContactId { get; set; } - /// - /// Gets the name of the contact. - /// - /// - /// The name of the contact. - /// - [JsonProperty("contact_name")] public String ContactName { get; set; } - /// - /// Gets the contact phone number. - /// - /// - /// The contact phone number. - /// - [JsonProperty("contact_phone_number")] public String ContactPhoneNumber { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs index 403628df..9b166470 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs @@ -1,66 +1,22 @@ using System; using System.Collections.Generic; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { public class ContractProduct { - /// - /// Gets or sets the display text. - /// - /// - /// The display text. - /// - [JsonProperty("display_text")] public String DisplayText { get; set; } - /// - /// Gets or sets the name. - /// - /// - /// The name. - /// - [JsonProperty("name")] public String Name { get; set; } - /// - /// Gets or sets the product identifier. - /// - /// - /// The product identifier. - /// - [JsonProperty("product_id")] public Guid ProductId { get; set; } - [JsonProperty("product_reporting_id")] public Int32 ProductReportingId { get; set; } - /// - /// Gets or sets the transaction fees. - /// - /// - /// The transaction fees. - /// - [JsonProperty("transaction_fees")] public List TransactionFees { get; set; } - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - [JsonProperty("value")] public Decimal? Value { get; set; } - /// - /// Gets or sets the type of the product. - /// - /// - /// The type of the product. - /// - [JsonProperty("product_type")] public ProductType ProductType { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs index fa517baf..fe80ee42 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs @@ -1,5 +1,4 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { @@ -7,52 +6,16 @@ public class ContractProductTransactionFee { #region Properties - /// - /// Gets or sets the type of the calculation. - /// - /// - /// The type of the calculation. - /// - [JsonProperty("calculation_type")] public CalculationType CalculationType { get; set; } - /// - /// Gets or sets the type of the fee. - /// - /// - /// The type of the fee. - /// - [JsonProperty("fee_type")] public FeeType FeeType { get; set; } - /// - /// Gets or sets the description. - /// - /// - /// The description. - /// - [JsonProperty("description")] public String Description { get; set; } - /// - /// Gets or sets the transaction fee identifier. - /// - /// - /// The transaction fee identifier. - /// - [JsonProperty("transaction_fee_id")] public Guid TransactionFeeId { get; set; } - [JsonProperty("transaction_fee_reporting_id")] public Int32 TransactionFeeReportingId { get; set; } - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - [JsonProperty("value")] public Decimal Value { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs index faf78922..72066986 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs @@ -1,70 +1,24 @@ using System; using System.Collections.Generic; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { public class ContractResponse { - /// - /// Gets or sets the contract identifier. - /// - /// - /// The contract identifier. - /// - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - [JsonProperty("contract_reporting_id")] public Int32 ContractReportingId { get; set; } - /// - /// Gets or sets the description. - /// - /// - /// The description. - /// - [JsonProperty("description")] public String Description { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - [JsonProperty("estate_reporting_id")] public Int32 EstateReportingId { get; set; } - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets or sets the name of the operator. - /// - /// - /// The name of the operator. - /// - [JsonProperty("operator_name")] public String OperatorName { get; set; } - /// - /// Gets or sets the products. - /// - /// - /// The products. - /// - [JsonProperty("products")] public List Products { get; set; } - } } diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs index baa7fce9..b55a3260 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs @@ -1,37 +1,14 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Contract { public class CreateContractResponse { #region Properties - - /// - /// Gets or sets the contract identifier. - /// - /// - /// The contract identifier. - /// - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs index 322348d4..9161e4de 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs @@ -1,19 +1,11 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Estate { [ExcludeFromCodeCoverage] public class CreateEstateResponse { - /// - /// Gets or sets the name of the estate. - /// - /// - /// The name of the estate. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs index 74355e0e..84d7e17a 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Estate { @@ -10,22 +9,8 @@ namespace TransactionProcessor.DataTransferObjects.Responses.Estate [ExcludeFromCodeCoverage] public class CreateEstateUserResponse { - /// - /// Gets or sets the name of the estate. - /// - /// - /// The name of the estate. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the user identifier. - /// - /// - /// The user identifier. - /// - [JsonProperty("user_id")] public Guid UserId { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs index 6979af45..88696050 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Estate { @@ -9,43 +8,14 @@ public class EstateOperatorResponse { #region Properties - /// - /// Gets the name. - /// - /// - /// The name. - /// - [JsonProperty("name")] public String Name { get; set; } - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets a value indicating whether [require custom merchant number]. - /// - /// - /// true if [require custom merchant number]; otherwise, false. - /// - [JsonProperty("require_custom_merchant_number")] public Boolean RequireCustomMerchantNumber { get; set; } - /// - /// Gets a value indicating whether [require customterminal number]. - /// - /// - /// true if [require customterminal number]; otherwise, false. - /// - [JsonProperty("require_custom_terminal_number")] public Boolean RequireCustomTerminalNumber { get; set; } - [JsonProperty("is_deleted")] public Boolean IsDeleted { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs index 1d1687cf..ce93d2bd 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Estate { @@ -13,46 +12,16 @@ public class EstateResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - [JsonProperty("estate_reporting_id")] public Int32 EstateReportingId { get; set; } - /// - /// Gets or sets the name of the estate. - /// - /// - /// The name of the estate. - /// - [JsonProperty("estate_name")] public String EstateName { get; set; } - [JsonProperty("estate_reference")] public String EstateReference { get; set; } - /// - /// Gets or sets the operators. - /// - /// - /// The operators. - /// - [JsonProperty("operators")] public List Operators { get; set; } - - /// - /// Gets or sets the security users. - /// - /// - /// The security users. - /// - [JsonProperty("security_users")] + public List SecurityUsers { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs index bfee711a..7efafb98 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Estate { @@ -9,22 +8,8 @@ public class SecurityUserResponse { #region Properties - /// - /// Gets or sets the email address. - /// - /// - /// The email address. - /// - [JsonProperty("email_address")] public String EmailAddress { get; set; } - /// - /// Gets or sets the security user identifier. - /// - /// - /// The security user identifier. - /// - [JsonProperty("security_user_id")] public Guid SecurityUserId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs index 8991e8e6..2443d7ee 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -9,31 +8,10 @@ public class AddMerchantDeviceResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("device_id")] public Guid DeviceId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs index 18744f2a..d39825e0 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -9,85 +8,22 @@ public class AddressResponse { #region Properties - /// - /// Gets or sets the address identifier. - /// - /// - /// The address identifier. - /// - [JsonProperty("address_id")] public Guid AddressId { get; set; } - /// - /// Gets the address line1. - /// - /// - /// The address line1. - /// - [JsonProperty("address_line1")] public String AddressLine1 { get; set; } - /// - /// Gets the address line2. - /// - /// - /// The address line2. - /// - [JsonProperty("address_line2")] public String AddressLine2 { get; set; } - /// - /// Gets the address line3. - /// - /// - /// The address line3. - /// - [JsonProperty("address_line3")] public String AddressLine3 { get; set; } - /// - /// Gets the address line4. - /// - /// - /// The address line4. - /// - [JsonProperty("address_line4")] public String AddressLine4 { get; set; } - /// - /// Gets the country. - /// - /// - /// The country. - /// - [JsonProperty("country")] public String Country { get; set; } - /// - /// Gets the postal code. - /// - /// - /// The postal code. - /// - [JsonProperty("postal_code")] public String PostalCode { get; set; } - /// - /// Gets the region. - /// - /// - /// The region. - /// - [JsonProperty("region")] public String Region { get; set; } - /// - /// Gets the town. - /// - /// - /// The town. - /// - [JsonProperty("town")] public String Town { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs index 4b2dc4e6..da7ff612 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -12,31 +11,10 @@ public class AssignOperatorResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs index 1df62a1e..7efbcf0d 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -12,22 +11,8 @@ public class CreateMerchantResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs index dc63caae..95827e92 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -9,31 +8,10 @@ public class CreateMerchantUserResponse { #region Properties - /// - /// Gets or sets the name of the estate. - /// - /// - /// The name of the estate. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the user identifier. - /// - /// - /// The user identifier. - /// - [JsonProperty("user_id")] public Guid UserId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs index 48bb62bc..f40ceaa7 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs @@ -1,15 +1,11 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { public class GenerateMerchantStatementResponse { - [JsonProperty("merchant_statement_id")] public Guid MerchantStatementId { get; set; } - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - [JsonProperty("estate_id")] public Guid EstateId { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs index efd29295..928e68fa 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -9,31 +8,10 @@ public class MakeMerchantDepositResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("deposit_id")] public Guid DepositId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs index e566dd2a..5a506b27 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -9,31 +8,10 @@ public class MakeMerchantWithdrawalResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the withdrawal identifier. - /// - /// - /// The withdrawal identifier. - /// - [JsonProperty("withdrawal_id")] public Guid WithdrawalId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs index a131e64f..8533f00f 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs @@ -1,19 +1,14 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant{ [ExcludeFromCodeCoverage] public class MerchantContractResponse { - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - - [JsonProperty("is_deleted")] public Boolean IsDeleted { get; set; } - [JsonProperty("contract_products")] public List ContractProducts { get; set; } public MerchantContractResponse() diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs index addd06d9..acf38a9d 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -8,44 +7,14 @@ namespace TransactionProcessor.DataTransferObjects.Responses.Merchant public class MerchantOperatorResponse { #region Properties - - /// - /// Gets the name. - /// - /// - /// The name. - /// - [JsonProperty("name")] public String Name { get; set; } - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets or sets the merchant number. - /// - /// - /// The merchant number. - /// - [JsonProperty("merchant_number")] public String MerchantNumber { get; set; } - /// - /// Gets or sets the terminal number. - /// - /// - /// The terminal number. - /// - [JsonProperty("terminal_number")] public String TerminalNumber { get; set; } - [JsonProperty("is_deleted")] public Boolean IsDeleted { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs index 36c8639b..97ee7ed9 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Newtonsoft.Json; using TransactionProcessor.DataTransferObjects.Requests.Merchant; using TransactionProcessor.DataTransferObjects.Responses.Contract; @@ -13,109 +12,34 @@ public class MerchantResponse { #region Properties - /// - /// Gets or sets the addresses. - /// - /// - /// The addresses. - /// - [JsonProperty("addresses")] public List Addresses { get; set; } - /// - /// Gets or sets the contacts. - /// - /// - /// The contacts. - /// - [JsonProperty("contacts")] public List Contacts { get; set; } - /// - /// Gets or sets the devices. - /// - /// - /// The devices. - /// - [JsonProperty("devices")] public Dictionary Devices { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - [JsonProperty("estate_reporting_id")] public Int32 EstateReportingId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - [JsonProperty("merchant_reporting_id")] public Int32 MerchantReportingId { get; set; } - /// - /// Gets or sets the name of the merchant. - /// - /// - /// The name of the merchant. - /// - [JsonProperty("merchant_name")] public String MerchantName { get; set; } - - /// - /// Gets or sets the merchant reference. - /// - /// - /// The merchant reference. - /// - [JsonProperty("merchant_reference")] + public String MerchantReference { get; set; } - /// - /// Gets or sets the next statement date. - /// - /// - /// The next statement date. - /// - [JsonProperty("next_statement_date")] public DateTime NextStatementDate { get; set; } - /// - /// Gets or sets the operators. - /// - /// - /// The operators. - /// - [JsonProperty("operators")] public List Operators { get; set; } - /// - /// Gets or sets the settlement schedule. - /// - /// - /// The settlement schedule. - /// - [JsonProperty("settlement_schedule")] public SettlementSchedule SettlementSchedule { get; set; } - [JsonProperty("contracts")] public List Contracts { get; set; } - [JsonProperty("opening_hours")] public Dictionary OpeningHours { get; set; } - [JsonProperty("schedules")] public List Schedules { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantScheduleResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantScheduleResponse.cs index 2c532188..da2c8bca 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantScheduleResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantScheduleResponse.cs @@ -1,23 +1,18 @@ using System; using System.Collections.Generic; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant; public class MerchantScheduleResponse { - [JsonProperty("year")] public Int32 Year { get; set; } - [JsonProperty("months")] public List Months { get; set; } = []; } public class MerchantScheduleMonthResponse { - [JsonProperty("month")] public Int32 Month { get; set; } - [JsonProperty("closed_days")] public List ClosedDays { get; set; } = []; } diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs index 04a9e491..f610d8ec 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Merchant { @@ -9,31 +8,10 @@ public class SwapMerchantDeviceResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - /// - /// Gets or sets the device identifier. - /// - /// - /// The device identifier. - /// - [JsonProperty("device_id")] public Guid DeviceId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs index 9ab08661..76bcd017 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Operator { @@ -9,22 +8,8 @@ public class CreateOperatorResponse { #region Properties - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs index 573df9e3..ceb891c3 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs @@ -1,44 +1,15 @@ using System; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Operator { public class OperatorResponse { - /// - /// Gets the name. - /// - /// - /// The name. - /// - [JsonProperty("name")] public String Name { get; set; } - /// - /// Gets the operator identifier. - /// - /// - /// The operator identifier. - /// - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - /// - /// Gets a value indicating whether [require custom merchant number]. - /// - /// - /// true if [require custom merchant number]; otherwise, false. - /// - [JsonProperty("require_custom_merchant_number")] public Boolean RequireCustomMerchantNumber { get; set; } - /// - /// Gets a value indicating whether [require customterminal number]. - /// - /// - /// true if [require customterminal number]; otherwise, false. - /// - [JsonProperty("require_custom_terminal_number")] public Boolean RequireCustomTerminalNumber { get; set; } diff --git a/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs index 5bfaacee..9f9edd01 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Settlement { @@ -8,32 +7,22 @@ namespace TransactionProcessor.DataTransferObjects.Responses.Settlement public class SettlementFeeResponse { #region Properties - - [JsonProperty("calculated_value")] public Decimal CalculatedValue { get; set; } - [JsonProperty("fee_description")] public String FeeDescription { get; set; } - [JsonProperty("is_settled")] public Boolean IsSettled { get; set; } - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - [JsonProperty("merchant_name")] public String MerchantName { get; set; } - [JsonProperty("settlement_date")] public DateTime SettlementDate { get; set; } - [JsonProperty("settlement_id")] public Guid SettlementId { get; set; } - [JsonProperty("transaction_id")] public Guid TransactionId { get; set; } - [JsonProperty("operator_identifier")] public String OperatorIdentifier { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs index 8c7ec957..2a463622 100644 --- a/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs +++ b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; namespace TransactionProcessor.DataTransferObjects.Responses.Settlement { @@ -19,22 +18,16 @@ public SettlementResponse() #region Properties - [JsonProperty("is_completed")] public Boolean IsCompleted { get; set; } - [JsonProperty("number_of_fees_settled")] public Int32 NumberOfFeesSettled { get; set; } - [JsonProperty("settlement_date")] public DateTime SettlementDate { get; set; } - [JsonProperty("settlement_fees")] public List SettlementFees { get; set; } - [JsonProperty("settlement_id")] public Guid SettlementId { get; set; } - [JsonProperty("value_of_fees_settled")] public Decimal ValueOfFeesSettled { get; set; } #endregion diff --git a/TransactionProcessor.DataTransferObjects/SaleTransactionRequest.cs b/TransactionProcessor.DataTransferObjects/SaleTransactionRequest.cs index 920282a4..60cb1fca 100644 --- a/TransactionProcessor.DataTransferObjects/SaleTransactionRequest.cs +++ b/TransactionProcessor.DataTransferObjects/SaleTransactionRequest.cs @@ -3,40 +3,28 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - + [ExcludeFromCodeCoverage] - public class SaleTransactionRequest : DataTransferObject + public class SaleTransactionRequest : TransactionRequest { #region Properties - [JsonProperty("additional_transaction_metadata")] public Dictionary AdditionalTransactionMetadata { get; set; } - [JsonProperty("contract_id")] public Guid ContractId { get; set; } - [JsonProperty("customer_email_address")] public String CustomerEmailAddress { get; set; } - [JsonProperty("device_identifier")] public String DeviceIdentifier { get; set; } - [JsonProperty("operator_id")] public Guid OperatorId { get; set; } - [JsonProperty("product_id")] public Guid ProductId { get; set; } - [JsonProperty("transaction_number")] public String TransactionNumber { get; set; } - [JsonProperty("transaction_source")] public Int32? TransactionSource { get; set; } - [JsonProperty("transaction_type")] - public String TransactionType { get; set; } - #endregion } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/SaleTransactionResponse.cs b/TransactionProcessor.DataTransferObjects/SaleTransactionResponse.cs index fe39eadb..542e2207 100644 --- a/TransactionProcessor.DataTransferObjects/SaleTransactionResponse.cs +++ b/TransactionProcessor.DataTransferObjects/SaleTransactionResponse.cs @@ -3,67 +3,10 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - + [ExcludeFromCodeCoverage] - public class SaleTransactionResponse + public class SaleTransactionResponse : TransactionResponse { - #region Properties - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - [JsonProperty("estate_id")] - public Guid EstateId { get; set; } - - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - [JsonProperty("merchant_id")] - public Guid MerchantId { get; set; } - - /// - /// Gets or sets the response code. - /// - /// - /// The response code. - /// - [JsonProperty("response_code")] - public String ResponseCode { get; set; } - - /// - /// Gets or sets the response message. - /// - /// - /// The response message. - /// - [JsonProperty("response_message")] - public String ResponseMessage { get; set; } - - /// - /// Gets or sets the additional transaction metadata. - /// - /// - /// The additional transaction metadata. - /// - [JsonProperty("additional_transaction_metadata")] public Dictionary AdditionalTransactionMetadata { get; set; } - - /// - /// Gets or sets the transaction identifier. - /// - /// - /// The transaction identifier. - /// - [JsonProperty("transaction_id")] - public Guid TransactionId { get; set; } - - #endregion } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/SerialisedMessage.cs b/TransactionProcessor.DataTransferObjects/SerialisedMessage.cs deleted file mode 100644 index 5e6e0ba7..00000000 --- a/TransactionProcessor.DataTransferObjects/SerialisedMessage.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace TransactionProcessor.DataTransferObjects -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - - /// - /// - /// - [ExcludeFromCodeCoverage] - public class SerialisedMessage - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - public SerialisedMessage() - { - this.Metadata = new Dictionary(); - } - - #endregion - - #region Properties - - /// - /// Gets or sets the metadata. - /// - /// - /// The metadata. - /// - [JsonProperty("metadata")] - public Dictionary Metadata { get; set; } - - /// - /// Gets or sets the serialised data. - /// - /// - /// The serialised data. - /// - [JsonProperty("serialised_data")] - public String SerialisedData { get; set; } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/SettlementResponse.cs b/TransactionProcessor.DataTransferObjects/SettlementResponse.cs index 71c1e592..c01118d2 100644 --- a/TransactionProcessor.DataTransferObjects/SettlementResponse.cs +++ b/TransactionProcessor.DataTransferObjects/SettlementResponse.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; - + namespace TransactionProcessor.DataTransferObjects { using System; @@ -8,19 +7,13 @@ namespace TransactionProcessor.DataTransferObjects [ExcludeFromCodeCoverage] public class SettlementResponse { - [JsonProperty("estate_id")] public Guid EstateId { get; set; } - [JsonProperty("merchant_id")] public Guid MerchantId { get; set; } - [JsonProperty("settlement_date")] public DateTime SettlementDate { get; set; } - [JsonProperty("number_of_fees_pending_settlement")] public Int32 NumberOfFeesPendingSettlement { get; set; } - [JsonProperty("number_of_fees_settled")] public Int32 NumberOfFeesSettled { get; set; } - [JsonProperty("settlement_completed")] public Boolean SettlementCompleted { get; set; } } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj b/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj index 2c108c5c..bbd67581 100644 --- a/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj +++ b/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj @@ -7,7 +7,6 @@ - diff --git a/TransactionProcessor.Database/TransactionProcessor.Database.csproj b/TransactionProcessor.Database/TransactionProcessor.Database.csproj index fa091d44..22c8404b 100644 --- a/TransactionProcessor.Database/TransactionProcessor.Database.csproj +++ b/TransactionProcessor.Database/TransactionProcessor.Database.csproj @@ -18,9 +18,9 @@ - + - + diff --git a/TransactionProcessor.DatabaseTests/TransactionProcessor.DatabaseTests.csproj b/TransactionProcessor.DatabaseTests/TransactionProcessor.DatabaseTests.csproj index 323bc50e..d4bfb49c 100644 --- a/TransactionProcessor.DatabaseTests/TransactionProcessor.DatabaseTests.csproj +++ b/TransactionProcessor.DatabaseTests/TransactionProcessor.DatabaseTests.csproj @@ -22,7 +22,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/TransactionProcessor.DomainEvents/TransactionProcessor.DomainEvents.csproj b/TransactionProcessor.DomainEvents/TransactionProcessor.DomainEvents.csproj index 87369caf..94058117 100644 --- a/TransactionProcessor.DomainEvents/TransactionProcessor.DomainEvents.csproj +++ b/TransactionProcessor.DomainEvents/TransactionProcessor.DomainEvents.csproj @@ -6,6 +6,6 @@ enable - + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs b/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs index 69f866c2..4da0b63a 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs @@ -1,4 +1,6 @@ -using TransactionProcessor.DataTransferObjects.Responses.Contract; +using Shared.Serialisation; +using TransactionProcessor.DataTransferObjects; +using TransactionProcessor.DataTransferObjects.Responses.Contract; namespace TransactionProcessor.IntegrationTesting.Helpers { @@ -18,10 +20,10 @@ private EstateDetails(Guid estateId, String estateName, String estateReference) this.AssignedOperators = new List(); this.MerchantUsers = new Dictionary>(); this.Contracts = new List(); - this.TransactionResponses = new Dictionary<(Guid merchantId, String transactionNumber), String>(); + this.TransactionResponses = new Dictionary<(Guid merchantId, String transactionNumber), TransactionResponse>(); } - private Dictionary<(Guid merchantId, String transactionNumber), String> TransactionResponses { get; } + private Dictionary<(Guid merchantId, String transactionNumber), TransactionResponse> TransactionResponses { get; } public Guid GetMerchantId(String merchantName) { @@ -35,7 +37,7 @@ public Guid GetMerchantId(String merchantName) public void AddTransactionResponse(Guid merchantId, String transactionNumber, - String transactionResponse) + TransactionResponse transactionResponse) { this.TransactionResponses.Add((merchantId, transactionNumber), transactionResponse); } @@ -52,10 +54,10 @@ public static EstateDetails Create(Guid estateId, return new EstateDetails(estateId,estateName, estateReference); } - public String GetTransactionResponse(Guid merchantId, + public TransactionResponse GetTransactionResponse(Guid merchantId, String transactionNumber) { - KeyValuePair<(Guid merchantId, String transactionNumber), String> transactionResponse = + KeyValuePair<(Guid merchantId, String transactionNumber), TransactionResponse> transactionResponse = this.TransactionResponses.SingleOrDefault(t => t.Key.merchantId == merchantId && t.Key.transactionNumber == transactionNumber); return transactionResponse.Value; diff --git a/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs b/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs index 06d76906..6fdaeeae 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs @@ -1,4 +1,5 @@ using Shared.Extensions; +using Shared.Serialisation; using Shouldly; using TransactionProcessor.DataTransferObjects.Requests.Contract; using TransactionProcessor.DataTransferObjects.Requests.Estate; @@ -12,7 +13,6 @@ namespace TransactionProcessor.IntegrationTesting.Helpers; using DataTransferObjects; -using Newtonsoft.Json; using Reqnroll; using Shared.General; using AssignOperatorToEstateRequest = DataTransferObjects.Requests.Estate.AssignOperatorRequest; @@ -330,7 +330,7 @@ public static List ToAutomaticDepositRequests(this DataTableRows tableRo amount = amount }; - requests.Add(JsonConvert.SerializeObject(makeDepositRequest)); + requests.Add(StringSerialiser.Serialise(makeDepositRequest)); } return requests; @@ -472,8 +472,8 @@ public static List ToAutomaticDepositRequests(this DataTableRows tableRo return results; } - public static List<(EstateDetails, Guid, String, SerialisedMessage)> ToSerialisedMessages(this DataTableRows tableRows, List estateDetailsList){ - List<(EstateDetails, Guid, String, SerialisedMessage)> messages = new List<(EstateDetails, Guid, String, SerialisedMessage)>(); + public static List<(EstateDetails, Guid, String, TransactionRequest)> ToTransactionRequests(this DataTableRows tableRows, List estateDetailsList){ + List<(EstateDetails, Guid, String, TransactionRequest)> messages = new List<(EstateDetails, Guid, String, TransactionRequest)>(); foreach (DataTableRow tableRow in tableRows){ String transactionType = ReqnrollTableHelper.GetStringRowValue(tableRow, "TransactionType"); String dateString = ReqnrollTableHelper.GetStringRowValue(tableRow, "DateTime"); @@ -490,19 +490,16 @@ public static List ToAutomaticDepositRequests(this DataTableRows tableRo String serialisedData = null; if (transactionType == "Logon"){ - LogonTransactionRequest logonTransactionRequest = new LogonTransactionRequest{ + LogonTransactionRequest logonTransactionRequest = new() { MerchantId = merchantId, EstateId = estateDetails.EstateId, TransactionDateTime = transactionDateTime, TransactionNumber = transactionNumber, DeviceIdentifier = deviceIdentifier, - TransactionType = transactionType + TransactionType = transactionType, }; - serialisedData = JsonConvert.SerializeObject(logonTransactionRequest, - new JsonSerializerSettings{ - TypeNameHandling = TypeNameHandling.All - }); - + messages.Add((estateDetails, merchantId, transactionNumber, logonTransactionRequest)); + continue; } if (transactionType == "Sale"){ @@ -559,7 +556,7 @@ public static List ToAutomaticDepositRequests(this DataTableRows tableRo Guid operatorId = estateDetails.GetOperatorId(operatorName); - SaleTransactionRequest saleTransactionRequest = new SaleTransactionRequest{ + SaleTransactionRequest saleTransactionRequest = new() { MerchantId = merchantId, EstateId = estateDetails.EstateId, TransactionDateTime = transactionDateTime, @@ -579,43 +576,35 @@ public static List ToAutomaticDepositRequests(this DataTableRows tableRo "PataPawa PrePay" => BuildPataPawaPrePayMetaData(messageType, meterNumber, customerName, transactionAmount), _ => BuildMobileTopupMetaData(transactionAmount, customerAccountNumber) }; - serialisedData = JsonConvert.SerializeObject(saleTransactionRequest, - new JsonSerializerSettings{ - TypeNameHandling = TypeNameHandling.All - }); + + messages.Add((estateDetails, merchantId, transactionNumber, saleTransactionRequest)); + continue; } if (transactionType == "Reconciliation"){ Int32 transactionCount = ReqnrollTableHelper.GetIntValue(tableRow, "TransactionCount"); Decimal transactionValue = ReqnrollTableHelper.GetDecimalValue(tableRow, "TransactionValue"); - ReconciliationRequest reconciliationRequest = new ReconciliationRequest{ + ReconciliationRequest reconciliationRequest = new() { MerchantId = merchantId, EstateId = estateDetails.EstateId, TransactionDateTime = transactionDateTime, DeviceIdentifier = deviceIdentifier, TransactionValue = transactionValue, TransactionCount = transactionCount, - }; + TransactionType = "Reconciliation" + }; - serialisedData = JsonConvert.SerializeObject(reconciliationRequest, - new JsonSerializerSettings{ - TypeNameHandling = TypeNameHandling.All - }); + messages.Add((estateDetails, merchantId, transactionNumber, reconciliationRequest)); + continue; } - - SerialisedMessage serialisedMessage = new SerialisedMessage(); - serialisedMessage.Metadata.Add(MetadataContants.EstateIdMetadataName, estateDetails.EstateId.ToString()); - serialisedMessage.Metadata.Add(MetadataContants.MerchantIdMetadataName, merchantId.ToString()); - serialisedMessage.SerialisedData = serialisedData; - messages.Add((estateDetails, merchantId, transactionNumber, serialisedMessage)); } return messages; } - public static List<(SerialisedMessage, String, String, String)> GetTransactionDetails(this DataTableRows tableRows, List estateDetailsList){ - List<(SerialisedMessage, String, String, String)> expectedValuesForTransaction = new List<(SerialisedMessage, String, String, String)>(); + public static List<(TransactionResponse, String, String, String)> GetTransactionDetails(this DataTableRows tableRows, List estateDetailsList){ + List<(TransactionResponse, String, String, String)> expectedValuesForTransaction = new List<(TransactionResponse, String, String, String)>(); foreach (DataTableRow tableRow in tableRows){ String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); @@ -628,9 +617,8 @@ public static List ToAutomaticDepositRequests(this DataTableRows tableRo String expectedResponseCode = ReqnrollTableHelper.GetStringRowValue(tableRow, "ResponseCode"); String expectedResponseMessage = ReqnrollTableHelper.GetStringRowValue(tableRow, "ResponseMessage"); - var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber); - var serialisedMessage = JsonConvert.DeserializeObject(message); - expectedValuesForTransaction.Add((serialisedMessage, transactionNumber, expectedResponseCode, expectedResponseMessage)); + var dataTransferObject = estateDetails.GetTransactionResponse(merchantId, transactionNumber); + expectedValuesForTransaction.Add((dataTransferObject, transactionNumber, expectedResponseCode, expectedResponseMessage)); } return expectedValuesForTransaction; @@ -754,8 +742,8 @@ public static ProcessSettlementRequest ToProcessSettlementRequest(String dateStr }; } - public static List GetTransactionResendDetails(this DataTableRows tableRows, List estateDetailsList){ - List serialisedMessages = new List(); + public static List GetTransactionResendDetails(this DataTableRows tableRows, List estateDetailsList){ + List serialisedMessages = new List(); foreach (DataTableRow tableRow in tableRows){ String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); @@ -766,9 +754,9 @@ public static List GetTransactionResendDetails(this DataTable Guid merchantId = estateDetails.GetMerchantId(merchantName); String transactionNumber = ReqnrollTableHelper.GetStringRowValue(tableRow, "TransactionNumber"); - var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber); - var serialisedMessage = JsonConvert.DeserializeObject(message); - serialisedMessages.Add(serialisedMessage); + var dataTransferObject = estateDetails.GetTransactionResponse(merchantId, transactionNumber); + + serialisedMessages.Add(dataTransferObject); } return serialisedMessages; @@ -897,13 +885,9 @@ public static (EstateDetails, SaleTransactionResponse) GetVoucherByTransactionNu EstateDetails estateDetails = ReqnrollExtensions.GetEstateDetails(estateDetailsList, estateName); Guid merchantId = estateDetails.GetMerchantId(merchantName); - var message = estateDetails.GetTransactionResponse(merchantId, transactionNumber.ToString()); - var serialisedMessage = JsonConvert.DeserializeObject(message); - SaleTransactionResponse transactionResponse = JsonConvert.DeserializeObject(serialisedMessage.SerialisedData, - new JsonSerializerSettings{ - TypeNameHandling = TypeNameHandling.All - }); - return (estateDetails, transactionResponse); + var dataTransferObject = estateDetails.GetTransactionResponse(merchantId, transactionNumber.ToString()) as SaleTransactionResponse; + + return (estateDetails, dataTransferObject); } public static List ToCreateEstateRequests(this DataTableRows tableRows) diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj index f9d6f0f5..45a61f27 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj @@ -7,12 +7,12 @@ - + - + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs index b5e4a506..e38417de 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs @@ -1,4 +1,5 @@ using EventStore.Client; +using Shared.Serialisation; using SimpleResults; using TransactionProcessor.DataTransferObjects.Requests.Contract; using TransactionProcessor.DataTransferObjects.Requests.Estate; @@ -18,7 +19,6 @@ namespace TransactionProcessor.IntegrationTesting.Helpers; using System.Text.Json; using Client; using DataTransferObjects; -using Newtonsoft.Json; using Shared.IntegrationTesting; using Shouldly; using TransactionProcessor.DataTransferObjects.Responses.Merchant; @@ -158,17 +158,24 @@ public async Task WhenIGetTheMerchantForEstateAnErrorIsReturned(String accessTok result.Status.ShouldBe(ResultStatus.NotFound); } - public async Task WhenIPerformTheFollowingTransactions(String accessToken, List<(EstateDetails, Guid, String, SerialisedMessage)> serialisedMessages) + public async Task WhenIPerformTheFollowingTransactions(String accessToken, List<(EstateDetails, Guid, String, TransactionRequest)> serialisedMessages) { - List<(EstateDetails, Guid, String, SerialisedMessage)> responseMessages = new List<(EstateDetails, Guid, String, SerialisedMessage)>(); - foreach ((EstateDetails, Guid, String, SerialisedMessage) serialisedMessage in serialisedMessages) - { - Result? performTransactionResult = - await this.TransactionProcessorClient.PerformTransaction(accessToken, serialisedMessage.Item4, CancellationToken.None); - performTransactionResult.IsSuccess.ShouldBeTrue(); - SerialisedMessage responseSerialisedMessage = performTransactionResult.Data; - String message = JsonConvert.SerializeObject(responseSerialisedMessage); - serialisedMessage.Item1.AddTransactionResponse(serialisedMessage.Item2, serialisedMessage.Item3, message); + foreach ((EstateDetails, Guid, String, TransactionRequest) serialisedMessage in serialisedMessages) { + if (serialisedMessage.Item4 is LogonTransactionRequest ltr) { + Result? logonResult = await this.TransactionProcessorClient.PerformTransaction(accessToken, ltr, CancellationToken.None); + logonResult.IsSuccess.ShouldBeTrue(); + serialisedMessage.Item1.AddTransactionResponse(serialisedMessage.Item2, serialisedMessage.Item3, logonResult.Data); + } + if (serialisedMessage.Item4 is SaleTransactionRequest str) { + Result? saleResult = await this.TransactionProcessorClient.PerformTransaction(accessToken, str, CancellationToken.None); + saleResult.IsSuccess.ShouldBeTrue(); + serialisedMessage.Item1.AddTransactionResponse(serialisedMessage.Item2, serialisedMessage.Item3, saleResult.Data); + } + if (serialisedMessage.Item4 is ReconciliationRequest rr) { + Result? reconciliationResult = await this.TransactionProcessorClient.PerformTransaction(accessToken, rr, CancellationToken.None); + reconciliationResult.IsSuccess.ShouldBeTrue(); + serialisedMessage.Item1.AddTransactionResponse(serialisedMessage.Item2, serialisedMessage.Item3, reconciliationResult.Data); + } } } @@ -319,10 +326,6 @@ await Retry.For(async () => { string projectionName = "MerchantBalanceProjection"; String partitionId = $"MerchantBalance-{m.Item2:N}"; - dynamic gg = await this.ProjectionManagementClient.GetStateAsync( - projectionName, partitionId); - JsonElement x = (JsonElement)gg; - Result? getMerchantBalanceResult = await this.TransactionProcessorClient.GetMerchantBalance(accessToken, m.Item1, m.Item2, CancellationToken.None); getMerchantBalanceResult.IsSuccess.ShouldBeTrue(); getMerchantBalanceResult.Data.ShouldNotBeNull(); @@ -337,17 +340,11 @@ await Retry.For(async () => { return responses; } - public void ValidateTransactions(List<(SerialisedMessage, String, String, String)> transactions) + public void ValidateTransactions(List<(TransactionResponse, String, String, String)> transactions) { - foreach ((SerialisedMessage, String, String, String) transaction in transactions) + foreach ((TransactionResponse, String, String, String) transaction in transactions) { - Object transactionResponse = JsonConvert.DeserializeObject(transaction.Item1.SerialisedData, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - - this.ValidateTransactionResponse((dynamic)transactionResponse, transaction.Item2, transaction.Item3, transaction.Item4); + this.ValidateTransactionResponse((dynamic)transaction.Item1, transaction.Item2, transaction.Item3, transaction.Item4); } } @@ -370,16 +367,10 @@ private void ValidateTransactionResponse(ReconciliationResponse reconciliationRe reconciliationResponse.ResponseMessage.ShouldBe(expectedResponseMessage, $"Transaction Number {transactionNumber} verification failed"); } - public async Task WhenIRequestTheReceiptIsResent(String accessToken, List transactions) + public async Task WhenIRequestTheReceiptIsResent(String accessToken, List transactions) { - foreach (SerialisedMessage serialisedMessage in transactions) - { - SaleTransactionResponse transactionResponse = JsonConvert.DeserializeObject(serialisedMessage.SerialisedData, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - + foreach (TransactionResponse transactionResponse in transactions) { + SaleTransactionResponse saleTransactionResponse = transactionResponse as SaleTransactionResponse; await Retry.For(async () => { Should.NotThrow(async () => { await this.TransactionProcessorClient.ResendEmailReceipt(accessToken, @@ -444,7 +435,7 @@ public async Task SendRequestToTestHost(List objects, String url){ foreach (T o in objects){ HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, url); - httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json"); + httpRequestMessage.Content = new StringContent(StringSerialiser.Serialise(o), Encoding.UTF8, "application/json"); HttpResponseMessage response = await this.TestHostHttpClient.SendAsync(httpRequestMessage); response.StatusCode.ShouldBe(HttpStatusCode.OK); diff --git a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs index 388decc9..3a7bc221 100644 --- a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs @@ -8,7 +8,6 @@ namespace TransactionProcessor.IntegrationTests.Common using EventStore.Client; using global::Shared.IntegrationTesting; using global::Shared.Serialisation; - using Newtonsoft.Json; using SecurityService.Client; using Shouldly; using System; @@ -82,7 +81,7 @@ private async Task ConfigureTestBank(String sortCode, await Retry.For(async () => { HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "/api/testbank/configuration"); - requestMessage.Content = new StringContent(JsonConvert.SerializeObject(hostConfig), Encoding.UTF8, "application/json"); + requestMessage.Content = new StringContent(StringSerialiser.Serialise(hostConfig), Encoding.UTF8, "application/json"); var responseMessage = await this.TestHostHttpClient.SendAsync(requestMessage); responseMessage.IsSuccessStatusCode.ShouldBeTrue(); }); diff --git a/TransactionProcessor.IntegrationTests/Common/TestingContext.cs b/TransactionProcessor.IntegrationTests/Common/TestingContext.cs index 00f488f6..7227eb04 100644 --- a/TransactionProcessor.IntegrationTests/Common/TestingContext.cs +++ b/TransactionProcessor.IntegrationTests/Common/TestingContext.cs @@ -11,7 +11,6 @@ namespace TransactionProcessor.IntegrationTests.Common using DataTransferObjects; using global::Shared.IntegrationTesting; using global::Shared.Logger; - using Newtonsoft.Json; using Reqnroll; using Shouldly; using Retry = IntegrationTests.Retry; @@ -194,13 +193,9 @@ public void AddVoucher((IssueVoucherRequest request, IssueVoucherResponse respon public async Task GetVoucherByTransactionNumber(String estateName, String merchantName, Int32 transactionNumber) { EstateDetails estate = this.GetEstateDetails(estateName); Guid merchantId = estate.GetMerchantId(merchantName); - String message = estate.GetTransactionResponse(merchantId, transactionNumber.ToString()); - SerialisedMessage serialisedMessage = JsonConvert.DeserializeObject(message); - SaleTransactionResponse transactionResponse = JsonConvert.DeserializeObject(serialisedMessage.SerialisedData, - new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); + TransactionResponse message = estate.GetTransactionResponse(merchantId, transactionNumber.ToString()); + + SaleTransactionResponse transactionResponse = message as SaleTransactionResponse; GetVoucherResponse voucher = null; await Retry.For(async () => { diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 7c18bd96..8ee5a079 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -9,6 +9,8 @@ using TransactionProcessor.DataTransferObjects.Responses.Contract; using TransactionProcessor.DataTransferObjects.Responses.Merchant; using TransactionProcessor.DataTransferObjects.Responses.Operator; +using TransactionProcessor.ProjectionEngine.Projections; +using TransactionProcessor.ProjectionEngine.State; namespace TransactionProcessor.IntegrationTests.Shared { @@ -16,7 +18,6 @@ namespace TransactionProcessor.IntegrationTests.Shared using DataTransferObjects; using IntegrationTesting.Helpers; using Microsoft.EntityFrameworkCore.Metadata.Internal; - using Newtonsoft.Json.Linq; using Reqnroll; using SecurityService.IntegrationTesting.Helpers; using Shouldly; @@ -317,7 +318,7 @@ public async Task WhenICreateTheFollowingMerchants(DataTable table) [When(@"I perform the following transactions")] public async Task WhenIPerformTheFollowingTransactions(DataTable table) { - List<(EstateDetails, Guid, String, SerialisedMessage)> serialisedMessages = table.Rows.ToSerialisedMessages(this.TestingContext.Estates); + List<(EstateDetails, Guid, String, TransactionRequest)> serialisedMessages = table.Rows.ToTransactionRequests(this.TestingContext.Estates); await this.TransactionProcessorSteps.WhenIPerformTheFollowingTransactions(this.TestingContext.AccessToken, serialisedMessages); } @@ -351,14 +352,14 @@ public async Task WhenIAddTheFollowingTransactionFees(DataTable table) [Then(@"transaction response should contain the following information")] public void ThenTransactionResponseShouldContainTheFollowingInformation(DataTable table) { - List<(SerialisedMessage, String, String, String)> transactions = table.Rows.GetTransactionDetails(this.TestingContext.Estates); + List<(TransactionResponse, String, String, String)> transactions = table.Rows.GetTransactionDetails(this.TestingContext.Estates); this.TransactionProcessorSteps.ValidateTransactions(transactions); } [When(@"I request the receipt is resent")] public async Task WhenIRequestTheReceiptIsResent(DataTable table) { - List transactions = table.Rows.GetTransactionResendDetails(this.TestingContext.Estates); + List transactions = table.Rows.GetTransactionResendDetails(this.TestingContext.Estates); await this.TransactionProcessorSteps.WhenIRequestTheReceiptIsResent(this.TestingContext.AccessToken, transactions); } [When(@"I get the merchants for '(.*)' then (.*) merchants will be returned")] @@ -401,17 +402,15 @@ public async Task WhenIAddTheFollowingContractsToTheFollowingMerchants(DataTable private async Task GetMerchantBalance(Guid merchantId) { - JsonElement jsonElement = (JsonElement)await this.TestingContext.DockerHelper.ProjectionManagementClient.GetStateAsync("MerchantBalanceProjection", $"MerchantBalance-{merchantId:N}"); - JObject jsonObject = JObject.Parse(jsonElement.GetRawText()); - decimal balanceValue = jsonObject.SelectToken("merchant.balance").Value(); - return balanceValue; + MerchantBalanceProjectionState1 balanceState = await this.TestingContext.DockerHelper.ProjectionManagementClient.GetStateAsync("MerchantBalanceProjection", $"MerchantBalance-{merchantId:N}"); + return balanceState.merchant.balance; } [When(@"I perform the following reconciliations")] public async Task WhenIPerformTheFollowingReconciliations(DataTable table) { - List<(EstateDetails, Guid, String, SerialisedMessage)> serialisedMessages = table.Rows.ToSerialisedMessages(this.TestingContext.Estates); + List<(EstateDetails, Guid, String, TransactionRequest)> serialisedMessages = table.Rows.ToTransactionRequests(this.TestingContext.Estates); await this.TransactionProcessorSteps.WhenIPerformTheFollowingTransactions(this.TestingContext.AccessToken, serialisedMessages); } @@ -419,7 +418,7 @@ public async Task WhenIPerformTheFollowingReconciliations(DataTable table) [Then(@"reconciliation response should contain the following information")] public void ThenReconciliationResponseShouldContainTheFollowingInformation(DataTable table) { - List<(SerialisedMessage, String, String, String)> transactions = table.Rows.GetTransactionDetails(this.TestingContext.Estates); + List<(TransactionResponse, String, String, String)> transactions = table.Rows.GetTransactionDetails(this.TestingContext.Estates); this.TransactionProcessorSteps.ValidateTransactions(transactions); } diff --git a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj index 93b88e20..1775968b 100644 --- a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj +++ b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj @@ -7,7 +7,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/TransactionProcessor.ProjectionEngine/State/MerchantBalanceState.cs b/TransactionProcessor.ProjectionEngine/State/MerchantBalanceState.cs index b35f37db..034abece 100644 --- a/TransactionProcessor.ProjectionEngine/State/MerchantBalanceState.cs +++ b/TransactionProcessor.ProjectionEngine/State/MerchantBalanceState.cs @@ -32,26 +32,26 @@ public record MerchantBalanceState : Shared.EventStore.ProjectionEngine.State public Int32 CompletedTransactionCount { get; init; } } -[ExcludeFromCodeCoverage] -public record AuthorisedSales(int count, decimal value, DateTime? lastSale); +//[ExcludeFromCodeCoverage] +//public record AuthorisedSales(int count, decimal value, DateTime? lastSale); -[ExcludeFromCodeCoverage] -public record DeclinedSales(int count, decimal value, DateTime? lastSale); +//[ExcludeFromCodeCoverage] +//public record DeclinedSales(int count, decimal value, DateTime? lastSale); -[ExcludeFromCodeCoverage] -public record Deposits(int count, decimal value, DateTime? lastDeposit); +//[ExcludeFromCodeCoverage] +//public record Deposits(int count, decimal value, DateTime? lastDeposit); [ExcludeFromCodeCoverage] public record Fees(int count, decimal value); [ExcludeFromCodeCoverage] -public record Merchant(string Id, string Name, int numberOfEventsProcessed, decimal balance, - Deposits deposits, Withdrawals withdrawals, AuthorisedSales authorisedSales, - DeclinedSales declinedSales, Fees fees); +public record Merchant(string Id, string Name, int numberOfEventsProcessed, decimal balance); + //Deposits deposits, Withdrawals withdrawals, AuthorisedSales authorisedSales, + //DeclinedSales declinedSales, Fees fees); [ExcludeFromCodeCoverage] public record MerchantBalanceProjectionState1(Merchant merchant); -[ExcludeFromCodeCoverage] -public record Withdrawals(int count, decimal value, DateTime? lastWithdrawal); +//[ExcludeFromCodeCoverage] +//public record Withdrawals(int count, decimal value, DateTime? lastWithdrawal); diff --git a/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj b/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj index c222abbd..0005c5bc 100644 --- a/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj +++ b/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj b/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj index c2010469..684f8444 100644 --- a/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj +++ b/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/TransactionProcessor.Testing/TestData.cs b/TransactionProcessor.Testing/TestData.cs index 0d2b0394..66bed237 100644 --- a/TransactionProcessor.Testing/TestData.cs +++ b/TransactionProcessor.Testing/TestData.cs @@ -1492,22 +1492,12 @@ public static TokenResponse GetTokenResponse() { public static ProjectionEngine.State.Merchant MerchantState = new ProjectionEngine.State.Merchant(TestData.MerchantStateId, TestData.MerchantName, 1, - TestData.AvailableBalance, - new Deposits(1, 100.00m, DateTime.Now.AddDays(-1)), - new Withdrawals(0, 0, null), - new AuthorisedSales(1, 55.0m, DateTime.Now), - new DeclinedSales(0, 0, null), - new Fees(0, 0)); - + TestData.AvailableBalance); + public static ProjectionEngine.State.Merchant MerchantStateNoCredit = new ProjectionEngine.State.Merchant(TestData.MerchantStateId, TestData.MerchantName, 1, - 0, - new Deposits(1, 100.00m, DateTime.Now.AddDays(-1)), - new Withdrawals(0, 0, null), - new AuthorisedSales(1, 55.0m, DateTime.Now), - new DeclinedSales(0, 0, null), - new Fees(0, 0)); + 0); public static MerchantBalanceProjectionState1 MerchantBalanceProjectionState => new MerchantBalanceProjectionState1(TestData.MerchantState); diff --git a/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj b/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj index c4436cf2..84ec864b 100644 --- a/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj +++ b/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj @@ -6,7 +6,7 @@ - + diff --git a/TransactionProcessor.Tests/Common/TransactionProcessorWebFactory.cs b/TransactionProcessor.Tests/Common/TransactionProcessorWebFactory.cs index 6779a378..8d12e9b2 100644 --- a/TransactionProcessor.Tests/Common/TransactionProcessorWebFactory.cs +++ b/TransactionProcessor.Tests/Common/TransactionProcessorWebFactory.cs @@ -1,5 +1,6 @@ using System; using System.Text; +using Shared.Serialisation; namespace TransactionProcessor.Tests.Common { @@ -12,7 +13,6 @@ namespace TransactionProcessor.Tests.Common using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; using Moq; - using Newtonsoft.Json; using Xunit; public class TransactionProcessorWebFactory : WebApplicationFactory where TStartup : class @@ -70,7 +70,7 @@ public static class Helpers /// public static StringContent CreateStringContent(T requestObject) { - return new StringContent(JsonConvert.SerializeObject(requestObject), Encoding.UTF8, "application/json"); + return new StringContent(StringSerialiser.Serialise(requestObject), Encoding.UTF8, "application/json"); } #endregion diff --git a/TransactionProcessor.Tests/ControllerTests/TransactionControllerTests.cs b/TransactionProcessor.Tests/ControllerTests/TransactionControllerTests.cs index 81e665dc..e81e0c23 100644 --- a/TransactionProcessor.Tests/ControllerTests/TransactionControllerTests.cs +++ b/TransactionProcessor.Tests/ControllerTests/TransactionControllerTests.cs @@ -1,20 +1,23 @@ -using System; +using Shared.Serialisation; +using System; +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; -namespace TransactionProcessor.Tests.ControllerTests -{ +namespace TransactionProcessor.Tests.ControllerTests { + using Common; + using DataTransferObjects; + using Shouldly; + using System.Globalization; using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; - using Common; - using DataTransferObjects; - using Newtonsoft.Json; - using Shouldly; + using TransactionProcessor.BusinessLogic.OperatorInterfaces.PataPawaPrePay; using Xunit; [Collection("TestCollection")] - public class TransactionControllerTests : IClassFixture> - { + public class TransactionControllerTests : IClassFixture> { #region Fields /// @@ -26,24 +29,22 @@ public class TransactionControllerTests : IClassFixture webApplicationFactory) - { + public TransactionControllerTests(TransactionProcessorWebFactory webApplicationFactory) { this.WebApplicationFactory = webApplicationFactory; } #endregion [Fact(Skip = "Incomplete")] - public async Task TransactionController_POST_LogonTransaction_LogonTransactionResponseIsReturned() - { + public async Task TransactionController_POST_LogonTransaction_LogonTransactionResponseIsReturned() { HttpClient client = this.WebApplicationFactory.CreateClient(); - + LogonTransactionRequest logonTransactionRequest = new LogonTransactionRequest(); String uri = "api/transactions"; StringContent content = Helpers.CreateStringContent(logonTransactionRequest); client.DefaultRequestHeaders.Add("api-version", "1.0"); - + HttpResponseMessage response = await client.PostAsync(uri, content, CancellationToken.None); response.StatusCode.ShouldBe(HttpStatusCode.Created); @@ -51,10 +52,66 @@ public async Task TransactionController_POST_LogonTransaction_LogonTransactionRe String responseAsJson = await response.Content.ReadAsStringAsync(); responseAsJson.ShouldNotBeNullOrEmpty(); - LogonTransactionResponse responseObject = JsonConvert.DeserializeObject(responseAsJson); + LogonTransactionResponse responseObject = StringSerialiser.Deserialise(responseAsJson); responseObject.ShouldNotBeNull(); responseObject.ResponseCode.ShouldBe("0000"); responseObject.ResponseMessage.ShouldBe("SUCCESS"); } + + [Fact] + public void Test() { + var options = SystemTextJsonSerializer.GetDefaultJsonSerializerOptions(); + options.Converters.Add(new DateTimeSpaceConverter()); + options.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString; + StringSerialiser.Initialise(new SystemTextJsonSerializer(options)); + String responseContent = "{\r\n \"transaction\": {\r\n \"fixed\": [\r\n {\r\n \"ercCharge\": 3.19,\r\n \"forexCharge\": 0.47,\r\n \"fuelIndexCharge\": 2.47,\r\n \"inflationAdjustment\": 0,\r\n \"monthlyFC\": 13.27,\r\n \"repCharge\": 1.39,\r\n \"totalTax\": 15.21\r\n }\r\n ],\r\n \"customerName\": \"Customer 1\",\r\n \"date\": \"2026-05-07 06:03:18\",\r\n \"meterNo\": \"00000001\",\r\n \"msg\": null,\r\n \"ref\": \"20260507060318986\",\r\n \"rescode\": \"elec000\",\r\n \"status\": 0,\r\n \"stdTokenAmt\": 64.0,\r\n \"stdTokenRctNum\": \"Ce001OVS3709952\",\r\n \"stdTokenTax\": \"0\",\r\n \"token\": \"63f9a9c47a7149e58a73f404222158cc\",\r\n \"totalAmount\": \"400\",\r\n \"transactionId\": 1,\r\n \"units\": \"6.1\",\r\n \"vendor\": \"support\"\r\n },\r\n \"msg\": \"success\",\r\n \"status\": 0\r\n}"; + VendResponse vendResponse = StringSerialiser.Deserialise(responseContent, new SerialiserOptions(SerialiserPropertyFormat.CamelCase)); + } } -} + + public class DateTimeSpaceConverter : JsonConverter + { + private static readonly string[] AcceptedFormats = new[] { + "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd H:mm:ss", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm:ss.FFFFFFFK", "o" // ISO 8601 round-trip + }; + public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.Null) + { + return default; + } + + if (reader.TokenType == JsonTokenType.String) + { + var s = reader.GetString(); + if (string.IsNullOrWhiteSpace(s)) + return default; + + // Try exact known formats first (handles "2026-05-07 06:03:18") + if (DateTime.TryParseExact(s, AcceptedFormats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal | DateTimeStyles.AllowWhiteSpaces, out var dtExact)) + return dtExact; + + // Fall back to general parse + if (DateTime.TryParse(s, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var dt)) + return dt; + + throw new JsonException($"Unable to parse DateTime: '{s}'."); + } + + // If JSON contains a number, attempt to treat it as Unix seconds (optional) + if (reader.TokenType == JsonTokenType.Number && reader.TryGetInt64(out long seconds)) + { + return DateTimeOffset.FromUnixTimeSeconds(seconds).LocalDateTime; + } + + throw new JsonException($"Unexpected token parsing DateTime. Token: {reader.TokenType}"); + } + + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + { + // Write in the same "space" format so round-trip matches your input + writer.WriteStringValue(value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); + } + } + } + diff --git a/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs b/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs index 3a94aeff..7d801c8f 100644 --- a/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs +++ b/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs @@ -191,14 +191,14 @@ public void ModelFactory_ProcessLogonTransactionResponseModel_IsConverted() { ProcessLogonTransactionResponse processLogonTransactionResponseModel = TestData.ProcessLogonTransactionResponseModel; - SerialisedMessage logonTransactionResponse = ModelFactory.ConvertFrom(processLogonTransactionResponseModel); + LogonTransactionResponse logonTransactionResponse = ModelFactory.ConvertFrom(processLogonTransactionResponseModel); logonTransactionResponse.ShouldNotBeNull(); - logonTransactionResponse.Metadata.ShouldContainKey(MetadataContants.EstateIdMetadataName); - logonTransactionResponse.Metadata.ShouldContainKey(MetadataContants.MerchantIdMetadataName); - String estateId = logonTransactionResponse.Metadata[MetadataContants.EstateIdMetadataName]; - String merchantId = logonTransactionResponse.Metadata[MetadataContants.MerchantIdMetadataName]; - estateId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.EstateId.ToString()); - merchantId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.MerchantId.ToString()); + logonTransactionResponse.EstateId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.EstateId); + logonTransactionResponse.MerchantId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.MerchantId); + logonTransactionResponse.ResponseCode.ShouldBe(TestData.ProcessLogonTransactionResponseModel.ResponseCode); + logonTransactionResponse.ResponseMessage.ShouldBe(TestData.ProcessLogonTransactionResponseModel.ResponseMessage); + logonTransactionResponse.TransactionId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.TransactionId); + logonTransactionResponse.TransactionType.ShouldBe("Logon"); } [Fact] @@ -206,7 +206,7 @@ public void ModelFactory_ProcessLogonTransactionResponseModel_NullInput_IsConver { ProcessLogonTransactionResponse processLogonTransactionResponseModel = null; - SerialisedMessage logonTransactionResult = ModelFactory.ConvertFrom(processLogonTransactionResponseModel); + LogonTransactionResponse logonTransactionResult = ModelFactory.ConvertFrom(processLogonTransactionResponseModel); logonTransactionResult.ShouldBeNull(); } @@ -215,23 +215,24 @@ public void ModelFactory_ProcessSaleTransactionResponseModel_IsConverted() { ProcessSaleTransactionResponse processSaleTransactionResponseModel = TestData.ProcessSaleTransactionResponseModel; - SerialisedMessage saleTransactionResponse = ModelFactory.ConvertFrom(processSaleTransactionResponseModel); + SaleTransactionResponse saleTransactionResponse = ModelFactory.ConvertFrom(processSaleTransactionResponseModel); saleTransactionResponse.ShouldNotBeNull(); - saleTransactionResponse.Metadata.ShouldContainKey(MetadataContants.EstateIdMetadataName); - saleTransactionResponse.Metadata.ShouldContainKey(MetadataContants.MerchantIdMetadataName); - String estateId = saleTransactionResponse.Metadata[MetadataContants.EstateIdMetadataName]; - String merchantId = saleTransactionResponse.Metadata[MetadataContants.MerchantIdMetadataName]; - estateId.ShouldBe(TestData.ProcessSaleTransactionResponseModel.EstateId.ToString()); - merchantId.ShouldBe(TestData.ProcessSaleTransactionResponseModel.MerchantId.ToString()); + saleTransactionResponse.EstateId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.EstateId); + saleTransactionResponse.MerchantId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.MerchantId); + saleTransactionResponse.ResponseCode.ShouldBe(TestData.ProcessLogonTransactionResponseModel.ResponseCode); + saleTransactionResponse.ResponseMessage.ShouldBe(TestData.ProcessLogonTransactionResponseModel.ResponseMessage); + saleTransactionResponse.TransactionId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.TransactionId); + saleTransactionResponse.TransactionType.ShouldBe("Sale"); } + [Fact] public void ModelFactory_ProcessSaleTransactionResponseModel_NullInput_IsConverted() { ProcessSaleTransactionResponse processSaleTransactionResponseModel = null; - SerialisedMessage saleTransactionResult = ModelFactory.ConvertFrom(processSaleTransactionResponseModel); + SaleTransactionResponse saleTransactionResult = ModelFactory.ConvertFrom(processSaleTransactionResponseModel); saleTransactionResult.ShouldBeNull(); } @@ -240,15 +241,15 @@ public void ModelFactory_ProcessReconciliationTransactionResponse_IsConverted() { ProcessReconciliationTransactionResponse processReconciliationTransactionResponseModel = TestData.ProcessReconciliationTransactionResponseModel; - SerialisedMessage processReconciliationTransactionResponse = ModelFactory.ConvertFrom(processReconciliationTransactionResponseModel); + ReconciliationResponse reconciliationTransactionResponse = ModelFactory.ConvertFrom(processReconciliationTransactionResponseModel); - processReconciliationTransactionResponse.ShouldNotBeNull(); - processReconciliationTransactionResponse.Metadata.ShouldContainKey(MetadataContants.EstateIdMetadataName); - processReconciliationTransactionResponse.Metadata.ShouldContainKey(MetadataContants.MerchantIdMetadataName); - String estateId = processReconciliationTransactionResponse.Metadata[MetadataContants.EstateIdMetadataName]; - String merchantId = processReconciliationTransactionResponse.Metadata[MetadataContants.MerchantIdMetadataName]; - estateId.ShouldBe(TestData.ProcessSaleTransactionResponseModel.EstateId.ToString()); - merchantId.ShouldBe(TestData.ProcessSaleTransactionResponseModel.MerchantId.ToString()); + reconciliationTransactionResponse.ShouldNotBeNull(); + reconciliationTransactionResponse.EstateId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.EstateId); + reconciliationTransactionResponse.MerchantId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.MerchantId); + reconciliationTransactionResponse.ResponseCode.ShouldBe(TestData.ProcessLogonTransactionResponseModel.ResponseCode); + reconciliationTransactionResponse.ResponseMessage.ShouldBe(TestData.ProcessLogonTransactionResponseModel.ResponseMessage); + reconciliationTransactionResponse.TransactionId.ShouldBe(TestData.ProcessLogonTransactionResponseModel.TransactionId); + reconciliationTransactionResponse.TransactionType.ShouldBe("Reconciliation"); } [Fact] @@ -256,7 +257,7 @@ public void ModelFactory_ProcessReconciliationTransactionResponse_NullInput_IsCo { ProcessReconciliationTransactionResponse processReconciliationTransactionResponseModel = null; - SerialisedMessage reconciliationTransactionResult = ModelFactory.ConvertFrom(processReconciliationTransactionResponseModel); + ReconciliationResponse reconciliationTransactionResult = ModelFactory.ConvertFrom(processReconciliationTransactionResponseModel); reconciliationTransactionResult.ShouldBeNull(); } diff --git a/TransactionProcessor.Tests/General/BootstrapperTests.cs b/TransactionProcessor.Tests/General/BootstrapperTests.cs index eeb24dc4..364837ab 100644 --- a/TransactionProcessor.Tests/General/BootstrapperTests.cs +++ b/TransactionProcessor.Tests/General/BootstrapperTests.cs @@ -1,15 +1,19 @@ +using Shouldly; + namespace TransactionProcessor.Tests.General { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; using Lamar; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Moq; + using Shared.Serialisation; + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using TransactionProcessor.ProjectionEngine.State; using Xunit; /// @@ -88,28 +92,4 @@ private void AddTestRegistrations(IServiceCollection services, #endregion } - - //public static class ServiceCollectionExtensions - //{ - // public static void AssertConfigurationIsValid(this IServiceCollection serviceCollection, - // List typesToIgnore = null) - // { - // ServiceProvider buildServiceProvider = serviceCollection.BuildServiceProvider(); - - // List list = serviceCollection.Where(x => x.ServiceType.Namespace != null && x.ServiceType.Namespace.Contains("Vme")).ToList(); - - // if (typesToIgnore != null) - // { - // list.RemoveAll(listItem => typesToIgnore.Contains(listItem.ServiceType)); - // } - - // foreach (ServiceDescriptor serviceDescriptor in list) - // { - // Type type = serviceDescriptor.ServiceType; - - // //This throws an Exception if the type cannot be instantiated. - // buildServiceProvider.GetService(type); - // } - // } - //} } diff --git a/TransactionProcessor.Tests/HandlerTests/TransactionHandlersTests.cs b/TransactionProcessor.Tests/HandlerTests/TransactionHandlersTests.cs index 1b8000e0..3430768e 100644 --- a/TransactionProcessor.Tests/HandlerTests/TransactionHandlersTests.cs +++ b/TransactionProcessor.Tests/HandlerTests/TransactionHandlersTests.cs @@ -5,7 +5,6 @@ using MediatR; using Microsoft.AspNetCore.Http; using Moq; -using Newtonsoft.Json; using Shared.General; using Shouldly; using SimpleResults; @@ -28,18 +27,12 @@ public async Task PerformTransaction_LogonPayloadWithoutTypeMetadata_SendsLogonC DeviceIdentifier = "device-1", TransactionDateTime = DateTime.SpecifyKind(new DateTime(2024, 1, 2, 3, 4, 5), DateTimeKind.Utc), TransactionNumber = "000001", - TransactionType = "Logon" + TransactionType = "Logon", + EstateId = TestData.EstateId, + MerchantId = TestData.MerchantId }; - mediator.Setup(m => m.Send(It.Is(command => - command.EstateId == TestData.EstateId && - command.MerchantId == TestData.MerchantId && - command.DeviceIdentifier == request.DeviceIdentifier && - command.TransactionNumber == request.TransactionNumber && - command.TransactionType == request.TransactionType && - command.TransactionDateTime.Kind == DateTimeKind.Unspecified && - command.TransactionDateTime.Ticks == request.TransactionDateTime.Ticks), - It.IsAny())) + mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(new ProcessLogonTransactionResponse { EstateId = TestData.EstateId, @@ -49,9 +42,9 @@ public async Task PerformTransaction_LogonPayloadWithoutTypeMetadata_SendsLogonC TransactionId = Guid.NewGuid() })); - IResult result = await TransactionHandlers.PerformTransaction(mediator.Object, + IResult result = await TransactionHandlers.PerformLogonTransaction(mediator.Object, new DefaultHttpContext(), - CreateSerialisedMessage(request), + request, CancellationToken.None); result.ShouldNotBeNull(); @@ -73,21 +66,12 @@ public async Task PerformTransaction_SalePayloadWithoutTypeMetadata_SendsSaleCom TransactionDateTime = new DateTime(2024, 1, 2, 3, 4, 5), TransactionNumber = "000002", TransactionSource = 2, - TransactionType = "Sale" + TransactionType = "Sale", + EstateId = TestData.EstateId, + MerchantId = TestData.MerchantId }; - mediator.Setup(m => m.Send(It.Is(command => - command.EstateId == TestData.EstateId && - command.MerchantId == TestData.MerchantId && - command.DeviceIdentifier == request.DeviceIdentifier && - command.TransactionNumber == request.TransactionNumber && - command.TransactionType == request.TransactionType && - command.OperatorId == request.OperatorId && - command.CustomerEmailAddress == request.CustomerEmailAddress && - command.ContractId == request.ContractId && - command.ProductId == request.ProductId && - command.TransactionSource == request.TransactionSource && - command.AdditionalTransactionMetadata["amount"] == "12.34"), + mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(new ProcessSaleTransactionResponse { @@ -98,9 +82,9 @@ public async Task PerformTransaction_SalePayloadWithoutTypeMetadata_SendsSaleCom TransactionId = Guid.NewGuid() })); - IResult result = await TransactionHandlers.PerformTransaction(mediator.Object, + IResult result = await TransactionHandlers.PerformSaleTransaction(mediator.Object, new DefaultHttpContext(), - CreateSerialisedMessage(request), + request, CancellationToken.None); result.ShouldNotBeNull(); @@ -117,15 +101,13 @@ public async Task PerformTransaction_ReconciliationPayloadWithoutTypeMetadata_Se OperatorTotals = new List(), TransactionCount = 4, TransactionDateTime = new DateTime(2024, 1, 2, 3, 4, 5), - TransactionValue = 42.50m + TransactionValue = 42.50m, + EstateId = TestData.EstateId, + MerchantId = TestData.MerchantId, + TransactionType = "Reconciliation" }; - mediator.Setup(m => m.Send(It.Is(command => - command.EstateId == TestData.EstateId && - command.MerchantId == TestData.MerchantId && - command.DeviceIdentifier == request.DeviceIdentifier && - command.TransactionCount == request.TransactionCount && - command.TransactionValue == request.TransactionValue), + mediator.Setup(m => m.Send(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(new ProcessReconciliationTransactionResponse { @@ -136,47 +118,15 @@ public async Task PerformTransaction_ReconciliationPayloadWithoutTypeMetadata_Se TransactionId = Guid.NewGuid() })); - IResult result = await TransactionHandlers.PerformTransaction(mediator.Object, + IResult result = await TransactionHandlers.PerformReconciliationTransaction(mediator.Object, new DefaultHttpContext(), - CreateSerialisedMessage(request), + request, CancellationToken.None); result.ShouldNotBeNull(); mediator.VerifyAll(); } - [Fact] - public async Task PerformTransaction_UnsupportedPayload_ReturnsBadRequest() - { - Mock mediator = new Mock(MockBehavior.Strict); - - IResult result = await TransactionHandlers.PerformTransaction(mediator.Object, - new DefaultHttpContext(), - CreateSerialisedMessage(new - { - device_identifier = "device-1", - transaction_type = "Unknown" - }), - CancellationToken.None); - - IStatusCodeHttpResult statusCodeResult = result.ShouldBeAssignableTo(); - statusCodeResult.StatusCode.ShouldBe(StatusCodes.Status400BadRequest); - mediator.Verify(m => m.Send(It.IsAny(), It.IsAny()), Times.Never); - } - - private static SerialisedMessage CreateSerialisedMessage(Object request) - { - return new SerialisedMessage - { - Metadata = new Dictionary - { - { MetadataContants.EstateIdMetadataName, TestData.EstateId.ToString() }, - { MetadataContants.MerchantIdMetadataName, TestData.MerchantId.ToString() } - }, - SerialisedData = JsonConvert.SerializeObject(request) - }; - } - private static class TestData { public static Guid EstateId => Guid.Parse("11111111-1111-1111-1111-111111111111"); diff --git a/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj b/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj index 85dde6e0..cddf9111 100644 --- a/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj +++ b/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj @@ -2,13 +2,12 @@ net10.0 - None + Full false - - + diff --git a/TransactionProcessor/Bootstrapper/MiddlewareRegistry.cs b/TransactionProcessor/Bootstrapper/MiddlewareRegistry.cs index 561f31ff..7f39fc4d 100644 --- a/TransactionProcessor/Bootstrapper/MiddlewareRegistry.cs +++ b/TransactionProcessor/Bootstrapper/MiddlewareRegistry.cs @@ -13,8 +13,6 @@ namespace TransactionProcessor.Bootstrapper using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; - using Newtonsoft.Json; - using Newtonsoft.Json.Serialization; using OpenIddict.Abstractions; using Shared.Authorisation; using Shared.EventStore.Extensions; @@ -103,14 +101,7 @@ private void ConfigureAuthorization() private void ConfigureControllers() { - this.AddControllers().AddNewtonsoftJson(options => - { - options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - options.SerializerSettings.TypeNameHandling = TypeNameHandling.Auto; - options.SerializerSettings.Formatting = Formatting.Indented; - options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; - options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); - }); + this.AddControllers(); } private void ConfigureHealthChecks(KurrentDBClientSettings eventStoreClientSettings) @@ -156,7 +147,6 @@ private void ConfigureSwagger() } }); // add a custom operation filter which sets default values - c.OperationFilter(); c.ExampleFilters(); //Locate the XML files being generated by ASP.NET... @@ -169,8 +159,6 @@ private void ConfigureSwagger() c.IncludeXmlComments(fileInfo.FullName); } }); - - this.AddSwaggerExamplesFromAssemblyOf(); } /// diff --git a/TransactionProcessor/Common/Examples/ExampleData.cs b/TransactionProcessor/Common/Examples/ExampleData.cs deleted file mode 100644 index 2e0d004f..00000000 --- a/TransactionProcessor/Common/Examples/ExampleData.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace TransactionProcessor.Common.Examples -{ - using System; - using System.Diagnostics.CodeAnalysis; - - /// - /// - /// - [ExcludeFromCodeCoverage] - internal static class ExampleData - { - #region Fields - - internal static Guid ContractId = Guid.Parse("64CB4CFC-F7DF-411C-9FB3-A631478B503C"); - - internal static String CustomerEmailAddress = "exmaplecustomer@email.com"; - - internal static String DeviceIdentifier = "exampledeviceidentifier1"; - - internal static Guid EstateId = Guid.Parse("9B3D0726-D1FC-45CE-BBB4-18F83EB93F07"); - - internal static String EstateIdMetadataName = "EstateId"; - - internal static String LogonResponseCode = "0000"; - - internal static String LogonResponseMessage = "SUCCESS"; - - internal static Guid MerchantId = Guid.Parse("9B3D0726-D1FC-45CE-BBB4-18F83EB93F07"); - - internal static String MerchantIdMetadataName = "MerchantId"; - - internal static Guid OperatorId = Guid.Parse("70881EB5-2892-47FE-BE0B-B23E004C342F"); - - internal static Guid ProductId = Guid.Parse("C0AEC683-587E-4F6A-BB20-B36312D9F712"); - - internal static Int32 OnlineSaleTransactionSource = 1; - - internal static Int32 FileBasedSaleTransactionSource = 2; - - internal static String ReconciliationResponseCode = "0000"; - - internal static String ReconciliationResponseMessage = "SUCCESS"; - - internal static String SaleResponseCode = "0000"; - - internal static String SaleResponseMessage = "SUCCESS"; - - internal static Int32 TransactionCount = 1; - - internal static DateTime TransactionDateTime = DateTime.Now; - - internal static String TransactionNumber = "1"; - - internal static String TransactionTypeLogon = "Logon"; - - internal static String TransactionTypeSale = "Sale"; - - internal static Decimal TransactionValue = 10.00m; - - internal static Guid TransactionId = Guid.Parse("612970B8-FDF1-4CAA-998A-D84632BD4DE0"); - - internal static Boolean IsGenerated = true; - - internal static Boolean IsIssued = true; - - internal static Boolean IsRedeemed = true; - - internal static DateTime? IssuedDateTime = new DateTime(2021, 3, 6); - - internal static DateTime? GeneratedDateTime = new DateTime(2021, 3, 7); - - internal static DateTime? RedeemedDateTime = new DateTime(2021, 3, 7); - - internal static String RecipientMobile = "07777777777"; - - internal static String RecipientEmail = "recipient@myvoucheremail.co.uk"; - - internal static Decimal VoucherValue = 10.00m; - - internal static Decimal RemainingBalance = 0; - - internal static DateTime ExpiryDate = new DateTime(2021, 4, 6); - - internal static String Message = String.Empty; - - internal static String VoucherCode = "1234567890"; - - internal static Guid VoucherId = Guid.Parse("AD3297AB-5484-4D5E-BBC2-B91815708920"); - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor/Common/Examples/GetVoucherResponseExample.cs b/TransactionProcessor/Common/Examples/GetVoucherResponseExample.cs deleted file mode 100644 index 45ff4926..00000000 --- a/TransactionProcessor/Common/Examples/GetVoucherResponseExample.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace TransactionProcessor.Common.Examples; - -using System.Diagnostics.CodeAnalysis; -using DataTransferObjects; -using Swashbuckle.AspNetCore.Filters; - -[ExcludeFromCodeCoverage] -public class GetVoucherResponseExample : IExamplesProvider -{ - /// - /// Gets the examples. - /// - /// - public GetVoucherResponse GetExamples() - { - return new GetVoucherResponse - { - VoucherCode = ExampleData.VoucherCode, - Value = ExampleData.VoucherValue, - ExpiryDate = ExampleData.ExpiryDate, - Balance = ExampleData.RemainingBalance, - GeneratedDateTime = ExampleData.GeneratedDateTime.Value, - IsGenerated = ExampleData.IsGenerated, - IsIssued = ExampleData.IsIssued, - IsRedeemed = ExampleData.IsRedeemed, - IssuedDateTime = ExampleData.IssuedDateTime.Value, - RedeemedDateTime = ExampleData.RedeemedDateTime.Value, - TransactionId = ExampleData.TransactionId, - VoucherId = ExampleData.VoucherId - }; - } -} \ No newline at end of file diff --git a/TransactionProcessor/Common/Examples/RedeemVoucherRequestExample.cs b/TransactionProcessor/Common/Examples/RedeemVoucherRequestExample.cs deleted file mode 100644 index 44bfddb9..00000000 --- a/TransactionProcessor/Common/Examples/RedeemVoucherRequestExample.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace TransactionProcessor.Common.Examples; - -using System.Diagnostics.CodeAnalysis; -using DataTransferObjects; -using Swashbuckle.AspNetCore.Filters; - -[ExcludeFromCodeCoverage] -public class RedeemVoucherRequestExample : IExamplesProvider -{ - /// - /// Gets the examples. - /// - /// - public RedeemVoucherRequest GetExamples() - { - return new RedeemVoucherRequest - { - EstateId = ExampleData.EstateId, - RedeemedDateTime = ExampleData.RedeemedDateTime, - VoucherCode = ExampleData.VoucherCode - }; - } -} \ No newline at end of file diff --git a/TransactionProcessor/Common/Examples/RedeemVoucherResponseExample.cs b/TransactionProcessor/Common/Examples/RedeemVoucherResponseExample.cs deleted file mode 100644 index 962ec7df..00000000 --- a/TransactionProcessor/Common/Examples/RedeemVoucherResponseExample.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace TransactionProcessor.Common.Examples; - -using System.Diagnostics.CodeAnalysis; -using DataTransferObjects; -using Swashbuckle.AspNetCore.Filters; - -[ExcludeFromCodeCoverage] -public class RedeemVoucherResponseExample : IExamplesProvider -{ - /// - /// Gets the examples. - /// - /// - public RedeemVoucherResponse GetExamples() - { - return new RedeemVoucherResponse - { - VoucherCode = ExampleData.VoucherCode, - ExpiryDate = ExampleData.ExpiryDate, - RemainingBalance = ExampleData.RemainingBalance - }; - } -} \ No newline at end of file diff --git a/TransactionProcessor/Common/Examples/TransactionRequestExample.cs b/TransactionProcessor/Common/Examples/TransactionRequestExample.cs deleted file mode 100644 index e0b87d7a..00000000 --- a/TransactionProcessor/Common/Examples/TransactionRequestExample.cs +++ /dev/null @@ -1,162 +0,0 @@ -namespace TransactionProcessor.Common.Examples -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using DataTransferObjects; - using Newtonsoft.Json; - using Swashbuckle.AspNetCore.Filters; - - /// - /// - /// - /// - [ExcludeFromCodeCoverage] - public class TransactionRequestExample : IMultipleExamplesProvider - { - #region Methods - - public IEnumerable> GetExamples() - { - return new List> - { - this.GetLogonExample(), - this.GetOnlineSaleExample(), - this.GetFileImportSaleExample(), - this.GetReconciliationExample() - }; - } - - private SwaggerExample GetLogonExample() - { - LogonTransactionRequest request = new LogonTransactionRequest - { - DeviceIdentifier = ExampleData.DeviceIdentifier, - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - TransactionDateTime = ExampleData.TransactionDateTime, - TransactionNumber = ExampleData.TransactionNumber, - TransactionType = ExampleData.TransactionTypeLogon - }; - - return new SwaggerExample - { - Name = "Logon Request", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(request, Formatting.Indented) - } - }; - } - - private SwaggerExample GetReconciliationExample() - { - ReconciliationRequest request = new ReconciliationRequest - { - DeviceIdentifier = ExampleData.DeviceIdentifier, - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - TransactionDateTime = ExampleData.TransactionDateTime, - OperatorTotals = new List - { - new OperatorTotalRequest - { - ContractId = ExampleData.ContractId, - OperatorId = ExampleData.OperatorId, - TransactionCount = ExampleData.TransactionCount, - TransactionValue = ExampleData.TransactionValue - } - }, - TransactionCount = ExampleData.TransactionCount, - TransactionValue = ExampleData.TransactionValue - }; - - return new SwaggerExample - { - Name = "Reconciliation Request", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(request, Formatting.Indented) - } - }; - } - - private SwaggerExample GetOnlineSaleExample() - { - SaleTransactionRequest onlineSaleTransactionRequest = new SaleTransactionRequest - { - DeviceIdentifier = ExampleData.DeviceIdentifier, - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - TransactionDateTime = ExampleData.TransactionDateTime, - TransactionNumber = ExampleData.TransactionNumber, - TransactionType = ExampleData.TransactionTypeSale, - AdditionalTransactionMetadata = new Dictionary(), - ContractId = ExampleData.ContractId, - CustomerEmailAddress = ExampleData.CustomerEmailAddress, - OperatorId = ExampleData.OperatorId, - ProductId = ExampleData.ProductId, - TransactionSource = ExampleData.OnlineSaleTransactionSource - }; - - return new SwaggerExample - { - Name = "Online Sale Request", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(onlineSaleTransactionRequest, Formatting.Indented) - } - }; - } - - private SwaggerExample GetFileImportSaleExample() - { - SaleTransactionRequest onlineSaleTransactionRequest = new SaleTransactionRequest - { - DeviceIdentifier = ExampleData.DeviceIdentifier, - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - TransactionDateTime = ExampleData.TransactionDateTime, - TransactionNumber = ExampleData.TransactionNumber, - TransactionType = ExampleData.TransactionTypeSale, - AdditionalTransactionMetadata = new Dictionary(), - ContractId = ExampleData.ContractId, - CustomerEmailAddress = ExampleData.CustomerEmailAddress, - OperatorId = ExampleData.OperatorId, - ProductId = ExampleData.ProductId, - TransactionSource = ExampleData.FileBasedSaleTransactionSource - }; - - return new SwaggerExample - { - Name = "File Import Sale Request", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(onlineSaleTransactionRequest, Formatting.Indented) - } - }; - } - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor/Common/Examples/TransactionResponseExample.cs b/TransactionProcessor/Common/Examples/TransactionResponseExample.cs deleted file mode 100644 index 22642fa0..00000000 --- a/TransactionProcessor/Common/Examples/TransactionResponseExample.cs +++ /dev/null @@ -1,122 +0,0 @@ -namespace TransactionProcessor.Common.Examples -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using DataTransferObjects; - using Newtonsoft.Json; - using Swashbuckle.AspNetCore.Filters; - - /// - /// - /// - /// - [ExcludeFromCodeCoverage] - public class TransactionResponseExample : IMultipleExamplesProvider - { - /// - /// Gets the logon example. - /// - /// - private SwaggerExample GetLogonExample() - { - LogonTransactionResponse response = new LogonTransactionResponse - { - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - ResponseCode = ExampleData.LogonResponseCode, - ResponseMessage = ExampleData.LogonResponseMessage, - TransactionId = ExampleData.TransactionId - }; - - return new SwaggerExample - { - Name = "Logon Response", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(response, Formatting.Indented) - } - }; - } - - /// - /// Gets the reconciliation example. - /// - /// - private SwaggerExample GetReconciliationExample() - { - ReconciliationResponse response = new ReconciliationResponse - { - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - ResponseCode = ExampleData.ReconciliationResponseCode, - ResponseMessage = ExampleData.ReconciliationResponseMessage, - TransactionId = ExampleData.TransactionId - }; - - return new SwaggerExample - { - Name = "Reconciliation Response", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(response, Formatting.Indented) - } - }; - } - - /// - /// Gets the sale example. - /// - /// - private SwaggerExample GetSaleExample() - { - SaleTransactionResponse response = new SaleTransactionResponse - { - EstateId = ExampleData.EstateId, - MerchantId = ExampleData.MerchantId, - AdditionalTransactionMetadata = new Dictionary(), - ResponseCode = ExampleData.SaleResponseCode, - ResponseMessage = ExampleData.SaleResponseMessage, - TransactionId = ExampleData.TransactionId - }; - - return new SwaggerExample - { - Name = "Sale Response", - Value = new SerialisedMessage - { - Metadata = new Dictionary - { - {ExampleData.EstateIdMetadataName, ExampleData.EstateId.ToString()}, - {ExampleData.MerchantIdMetadataName, ExampleData.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(response, Formatting.Indented) - } - }; - } - - /// - /// Gets the examples. - /// - /// - public IEnumerable> GetExamples() - { - return new List> - { - this.GetLogonExample(), - this.GetSaleExample(), - this.GetReconciliationExample() - }; - } - } -} \ No newline at end of file diff --git a/TransactionProcessor/Common/SwaggerDefaultValues.cs b/TransactionProcessor/Common/SwaggerDefaultValues.cs deleted file mode 100644 index 2c15b805..00000000 --- a/TransactionProcessor/Common/SwaggerDefaultValues.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Linq; -using Microsoft.OpenApi; - -namespace TransactionProcessor.Common -{ - using System.Diagnostics.CodeAnalysis; - using Microsoft.AspNetCore.Mvc.ApiExplorer; - using Swashbuckle.AspNetCore.SwaggerGen; - - /// - /// Represents the Swagger/Swashbuckle operation filter used to document the implicit API version parameter. - /// - /// This is only required due to bugs in the . - /// Once they are fixed and published, this class can be removed. - [ExcludeFromCodeCoverage] - public class SwaggerDefaultValues : IOperationFilter - { - /// - /// Applies the filter to the specified operation using the given context. - /// - /// The operation to apply the filter to. - /// The current operation filter context. - public void Apply(OpenApiOperation operation, - OperationFilterContext context) - { - ApiDescription apiDescription = context.ApiDescription; - - if (operation.Parameters == null) - { - return; - } - - foreach (OpenApiParameter parameter in operation.Parameters) - { - ApiParameterDescription description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name); - - if (parameter.Description == null) - { - parameter.Description = description.ModelMetadata?.Description; - } - - parameter.Required |= description.IsRequired; - } - } - } -} diff --git a/TransactionProcessor/Common/SwaggerJsonConverter.cs b/TransactionProcessor/Common/SwaggerJsonConverter.cs deleted file mode 100644 index adffb317..00000000 --- a/TransactionProcessor/Common/SwaggerJsonConverter.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; - -namespace TransactionProcessor.Common -{ - using System.Diagnostics.CodeAnalysis; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; - - /// - /// - /// - /// - [ExcludeFromCodeCoverage] - public class SwaggerJsonConverter : JsonConverter - { - #region Properties - - /// - /// Gets a value indicating whether this can read JSON. - /// - /// - /// true if this can read JSON; otherwise, false. - /// - public override Boolean CanRead => false; - - #endregion - - #region Methods - - /// - /// Determines whether this instance can convert the specified object type. - /// - /// Type of the object. - /// - /// true if this instance can convert the specified object type; otherwise, false. - /// - public override Boolean CanConvert(Type objectType) - { - return true; - } - - /// - /// Reads the JSON representation of the object. - /// - /// The to read from. - /// Type of the object. - /// The existing value of object being read. - /// The calling serializer. - /// - /// The object value. - /// - /// - /// - public override Object ReadJson(JsonReader reader, - Type objectType, - Object existingValue, - JsonSerializer serializer) - { - throw new NotImplementedException(); - } - - /// - /// Writes the JSON representation of the object. - /// - /// The to write to. - /// The value. - /// The calling serializer. - public override void WriteJson(JsonWriter writer, - Object value, - JsonSerializer serializer) - { - // Disable sending the $type in the serialized json - serializer.TypeNameHandling = TypeNameHandling.None; - - JToken t = JToken.FromObject(value); - t.WriteTo(writer); - } - - #endregion - } -} diff --git a/TransactionProcessor/Controllers/DomainEventController.cs b/TransactionProcessor/Controllers/DomainEventController.cs index 506ce13d..ac575c56 100644 --- a/TransactionProcessor/Controllers/DomainEventController.cs +++ b/TransactionProcessor/Controllers/DomainEventController.cs @@ -8,8 +8,6 @@ namespace TransactionProcessor.Controllers { using Microsoft.AspNetCore.Mvc; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.EventStore.EventHandling; @@ -94,7 +92,7 @@ public async Task PostEventAsync([FromBody] Object request, } catch (Exception ex) { - String domainEventData = JsonConvert.SerializeObject(domainEvent); + String domainEventData = StringSerialiser.Serialise(domainEvent); Logger.LogError(new Exception($" Failed to Process Event, Event Data received [{domainEventData}]", ex)); throw; @@ -143,41 +141,18 @@ private async Task GetDomainEvent(Object domainEvent) if (type == null) throw new NotFoundException($"Failed to find a domain event with type {eventType}"); - - //JsonIgnoreAttributeIgnorerContractResolver jsonIgnoreAttributeIgnorerContractResolver = new JsonIgnoreAttributeIgnorerContractResolver(); - //JsonSerializerSettings jsonSerialiserSettings = new JsonSerializerSettings - //{ - // ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - // TypeNameHandling = TypeNameHandling.All, - // Formatting = Formatting.Indented, - // DateTimeZoneHandling = DateTimeZoneHandling.Utc, - // ContractResolver = jsonIgnoreAttributeIgnorerContractResolver - //}; - + if (type.IsSubclassOf(typeof(DomainEvent))) { - String json = StringSerialiser.Serialise(domainEvent); //JsonConvert.SerializeObject(domainEvent, jsonSerialiserSettings); + String json = StringSerialiser.Serialise(domainEvent); DomainEventFactory domainEventFactory = new(); - String validatedJson = this.ValidateEvent(json); - return domainEventFactory.CreateDomainEvent(validatedJson, type); + return domainEventFactory.CreateDomainEvent(json, type); } return null; } - private String ValidateEvent(String domainEventJson) - { - JObject domainEvent = JObject.Parse(domainEventJson); - - if (domainEvent.ContainsKey("eventId") == false || domainEvent["eventId"].ToObject() == Guid.Empty) - { - throw new ArgumentException("Domain Event must contain an Event Id"); - } - - return domainEventJson; - } - #endregion #region Others diff --git a/TransactionProcessor/Endpoints/TransactionEndpoints.cs b/TransactionProcessor/Endpoints/TransactionEndpoints.cs index 9c756a95..db014212 100644 --- a/TransactionProcessor/Endpoints/TransactionEndpoints.cs +++ b/TransactionProcessor/Endpoints/TransactionEndpoints.cs @@ -18,8 +18,14 @@ public static IEndpointRouteBuilder MapTransactionEndpoints(this IEndpointRouteB .RequireAuthorization(AuthorizationExtensions.PolicyNames.ClientCredentialsOnlyPolicy); // POST /api/transactions - rejects password tokens => require client credentials - group.MapPost("/", TransactionHandlers.PerformTransaction) - .WithName("PerformTransaction"); + group.MapPost("/logon", TransactionHandlers.PerformLogonTransaction) + .WithName("PerformLogonTransaction"); + + group.MapPost("/sale", TransactionHandlers.PerformSaleTransaction) + .WithName("PerformSaleTransaction"); + + group.MapPost("/reconciliation", TransactionHandlers.PerformReconciliationTransaction) + .WithName("PerformReconciliationTransaction"); // POST /api/{estateId}/transactions/{transactionId}/resendreceipt // note: controller used absolute route; map both forms — keep support for the original absolute route diff --git a/TransactionProcessor/Factories/ModelFactory.cs b/TransactionProcessor/Factories/ModelFactory.cs index 05c730ac..94f0e361 100644 --- a/TransactionProcessor/Factories/ModelFactory.cs +++ b/TransactionProcessor/Factories/ModelFactory.cs @@ -13,7 +13,6 @@ namespace TransactionProcessor.Factories using System.Collections.Generic; using DataTransferObjects; using Models; - using Newtonsoft.Json; using TransactionProcessor.Models.Estate; using TransactionProcessor.Models.Merchant; using CalculationType = DataTransferObjects.Responses.Contract.CalculationType; @@ -131,7 +130,7 @@ public static List ConvertFrom(List return result.ToList(); } - public static SerialisedMessage ConvertFrom(ProcessLogonTransactionResponse processLogonTransactionResponse) + public static LogonTransactionResponse ConvertFrom(ProcessLogonTransactionResponse processLogonTransactionResponse) { if (processLogonTransactionResponse == null) { @@ -144,24 +143,14 @@ public static SerialisedMessage ConvertFrom(ProcessLogonTransactionResponse proc ResponseCode = processLogonTransactionResponse.ResponseCode, MerchantId = processLogonTransactionResponse.MerchantId, EstateId = processLogonTransactionResponse.EstateId, - TransactionId = processLogonTransactionResponse.TransactionId + TransactionId = processLogonTransactionResponse.TransactionId, + TransactionType = "Logon" }; - return new SerialisedMessage - { - Metadata = new Dictionary() - { - {MetadataContants.EstateIdMetadataName, logonTransactionResponse.EstateId.ToString()}, - {MetadataContants.MerchantIdMetadataName, logonTransactionResponse.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(logonTransactionResponse, new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }) - }; + return logonTransactionResponse; } - public static SerialisedMessage ConvertFrom(ProcessSaleTransactionResponse processSaleTransactionResponse) + public static SaleTransactionResponse ConvertFrom(ProcessSaleTransactionResponse processSaleTransactionResponse) { if (processSaleTransactionResponse == null) { @@ -175,24 +164,14 @@ public static SerialisedMessage ConvertFrom(ProcessSaleTransactionResponse proce MerchantId = processSaleTransactionResponse.MerchantId, EstateId = processSaleTransactionResponse.EstateId, AdditionalTransactionMetadata = processSaleTransactionResponse.AdditionalTransactionMetadata, - TransactionId = processSaleTransactionResponse.TransactionId - }; + TransactionId = processSaleTransactionResponse.TransactionId, + TransactionType = "Sale" + }; - return new SerialisedMessage - { - Metadata = new Dictionary() - { - {MetadataContants.EstateIdMetadataName, processSaleTransactionResponse.EstateId.ToString()}, - {MetadataContants.MerchantIdMetadataName, processSaleTransactionResponse.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(saleTransactionResponse, new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }) - }; + return saleTransactionResponse; } - public static SerialisedMessage ConvertFrom(ProcessReconciliationTransactionResponse processReconciliationTransactionResponse) + public static ReconciliationResponse ConvertFrom(ProcessReconciliationTransactionResponse processReconciliationTransactionResponse) { if (processReconciliationTransactionResponse == null) { @@ -205,21 +184,11 @@ public static SerialisedMessage ConvertFrom(ProcessReconciliationTransactionResp ResponseCode = processReconciliationTransactionResponse.ResponseCode, MerchantId = processReconciliationTransactionResponse.MerchantId, EstateId = processReconciliationTransactionResponse.EstateId, - TransactionId = processReconciliationTransactionResponse.TransactionId + TransactionId = processReconciliationTransactionResponse.TransactionId, + TransactionType = "Reconciliation" }; - return new SerialisedMessage - { - Metadata = new Dictionary() - { - {MetadataContants.EstateIdMetadataName, processReconciliationTransactionResponse.EstateId.ToString()}, - {MetadataContants.MerchantIdMetadataName, processReconciliationTransactionResponse.MerchantId.ToString()} - }, - SerialisedData = JsonConvert.SerializeObject(reconciliationTransactionResponse, new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }) - }; + return reconciliationTransactionResponse; } public static IssueVoucherResponse ConvertFrom(Models.IssueVoucherResponse issueVoucherResponse) diff --git a/TransactionProcessor/Handlers/TransactionHandlers.cs b/TransactionProcessor/Handlers/TransactionHandlers.cs index 9470a35d..1e4a468b 100644 --- a/TransactionProcessor/Handlers/TransactionHandlers.cs +++ b/TransactionProcessor/Handlers/TransactionHandlers.cs @@ -1,14 +1,10 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediatR; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using SimpleResults; using Shared.Results.Web; -using Shared.General; using Shared.Results; using TransactionProcessor.DataTransferObjects; using TransactionProcessor.Factories; @@ -19,129 +15,31 @@ namespace TransactionProcessor.Handlers { public static class TransactionHandlers { - public static async Task PerformTransaction(IMediator mediator, HttpContext ctx, SerialisedMessage transactionRequest, CancellationToken cancellationToken) + public static async Task PerformSaleTransaction(IMediator mediator, HttpContext ctx, SaleTransactionRequest transactionRequest, CancellationToken cancellationToken) { DateTime transactionReceivedDateTime = DateTime.Now; - Guid estateId = Guid.Parse(transactionRequest.Metadata[MetadataContants.EstateIdMetadataName]); - Guid merchantId = Guid.Parse(transactionRequest.Metadata[MetadataContants.MerchantIdMetadataName]); - - Result deserialiseResult = DeserializeTransactionRequest(transactionRequest.SerialisedData); - if (deserialiseResult.IsFailed || deserialiseResult.Data == null) - { - return ResponseFactory.FromResult(Result.Invalid(deserialiseResult.Message)); - } - - DataTransferObject dto = deserialiseResult.Data; - - dto.MerchantId = merchantId; - dto.EstateId = estateId; - if (dto.TransactionDateTime.Kind == DateTimeKind.Utc) - { - dto.TransactionDateTime = new DateTime(dto.TransactionDateTime.Ticks, DateTimeKind.Unspecified); - } - - Result transactionResult = dto switch - { - LogonTransactionRequest ltr => await ProcessSpecificMessage(mediator, ltr, transactionReceivedDateTime, cancellationToken), - SaleTransactionRequest str => await ProcessSpecificMessage(mediator, str, transactionReceivedDateTime, cancellationToken), - ReconciliationRequest rr => await ProcessSpecificMessage(mediator, rr, cancellationToken), - _ => Result.Invalid($"DTO Type {dto.GetType().Name} not supported") - }; + Result transactionResult = await ProcessSpecificMessage(mediator, transactionRequest, transactionReceivedDateTime, cancellationToken); return ResponseFactory.FromResult(transactionResult, message => message); } - private static Result DeserializeTransactionRequest(String serialisedData) + public static async Task PerformLogonTransaction(IMediator mediator, HttpContext ctx, LogonTransactionRequest transactionRequest, CancellationToken cancellationToken) { - try { - JObject jsonObject = JObject.Parse(serialisedData); - - if (IsReconciliationRequest(jsonObject)) { - return DeserializeKnownType(jsonObject); - } - - if (IsSaleRequest(jsonObject)) { - return DeserializeKnownType(jsonObject); - } - - if (IsLogonRequest(jsonObject)) { - return DeserializeKnownType(jsonObject); - } - - return Result.Invalid("DTO Type could not be determined"); - } - catch (JsonException ex) { - return Result.Invalid($"Invalid transaction request payload: {ex.Message}"); - } - } - - private static Result DeserializeKnownType(JObject jsonObject) where T : DataTransferObject - { - try - { - JsonSerializer serializer = JsonSerializer.Create(new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.None, - MetadataPropertyHandling = MetadataPropertyHandling.Ignore - }); - - T dto = jsonObject.ToObject(serializer); - - if (dto == null) - { - return Result.Invalid($"Failed to deserialize transaction request as {typeof(T).Name}: deserialized payload was null"); - } - - return Result.Success(dto); - } - catch (JsonException ex) - { - return Result.Invalid($"Failed to deserialize transaction request as {typeof(T).Name}: {ex.Message}"); - } - } - - private static Boolean IsLogonRequest(JObject jsonObject) { - if (TryGetTransactionType(jsonObject, out string transactionType)) { - return String.Equals(transactionType, "Logon", StringComparison.OrdinalIgnoreCase); - } - - return false; - } - - private static Boolean IsSaleRequest(JObject jsonObject) { - if (TryGetTransactionType(jsonObject, out string transactionType)) { - return String.Equals(transactionType, "Sale", StringComparison.OrdinalIgnoreCase); - } - - return false; - } + DateTime transactionReceivedDateTime = DateTime.Now; - private static Boolean IsReconciliationRequest(JObject jsonObject) { - if (TryGetTransactionType(jsonObject, out string _)) { - return false; - } + Result transactionResult = await ProcessSpecificMessage(mediator, transactionRequest, transactionReceivedDateTime, cancellationToken); - return true; + return ResponseFactory.FromResult(transactionResult, message => message); } - private static bool TryGetTransactionType(JObject jsonObject, - out string transactionType) { - transactionType = null; - - if (!HasProperty(jsonObject, "transaction_type")) - return false; - - transactionType = jsonObject.GetValue("transaction_type", StringComparison.OrdinalIgnoreCase)?.Value(); - - return transactionType != null; - } + public static async Task PerformReconciliationTransaction(IMediator mediator, HttpContext ctx, ReconciliationRequest transactionRequest, CancellationToken cancellationToken) + { + Result transactionResult = await ProcessSpecificMessage(mediator, transactionRequest, cancellationToken); - private static Boolean HasProperty(JObject jsonObject, - String propertyName) { - return jsonObject.GetValue(propertyName, StringComparison.OrdinalIgnoreCase) != null; + return ResponseFactory.FromResult(transactionResult, message => message); } - + public static async Task ResendTransactionReceipt(IMediator mediator, HttpContext ctx, Guid estateId, Guid transactionId, CancellationToken cancellationToken) { TransactionCommands.ResendTransactionReceiptCommand command = new(transactionId, estateId); @@ -151,7 +49,7 @@ public static async Task ResendTransactionReceipt(IMediator mediator, H } // Helpers copied from controller logic - private static async Task> ProcessSpecificMessage(IMediator mediator, LogonTransactionRequest logon, DateTime transactionReceivedDateTime, CancellationToken cancellationToken) + private static async Task> ProcessSpecificMessage(IMediator mediator, LogonTransactionRequest logon, DateTime transactionReceivedDateTime, CancellationToken cancellationToken) { Guid transactionId = Guid.NewGuid(); @@ -165,14 +63,14 @@ private static async Task> ProcessSpecificMessage(IMed logon.TransactionNumber, transactionReceivedDateTime); - var result = await mediator.Send(command, cancellationToken); + Result result = await mediator.Send(command, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); return ModelFactory.ConvertFrom(result.Data); } - private static async Task> ProcessSpecificMessage(IMediator mediator, SaleTransactionRequest sale, DateTime transactionReceivedDateTime, CancellationToken cancellationToken) + private static async Task> ProcessSpecificMessage(IMediator mediator, SaleTransactionRequest sale, DateTime transactionReceivedDateTime, CancellationToken cancellationToken) { Guid transactionId = Guid.NewGuid(); @@ -200,7 +98,7 @@ private static async Task> ProcessSpecificMessage(IMed return ModelFactory.ConvertFrom(result.Data); } - private static async Task> ProcessSpecificMessage(IMediator mediator, ReconciliationRequest reconciliation, CancellationToken cancellationToken) + private static async Task> ProcessSpecificMessage(IMediator mediator, ReconciliationRequest reconciliation, CancellationToken cancellationToken) { Guid transactionId = Guid.NewGuid(); diff --git a/TransactionProcessor/TransactionProcessor.csproj b/TransactionProcessor/TransactionProcessor.csproj index 1f28abfa..7041c389 100644 --- a/TransactionProcessor/TransactionProcessor.csproj +++ b/TransactionProcessor/TransactionProcessor.csproj @@ -12,7 +12,7 @@ - + @@ -20,7 +20,6 @@ - all @@ -32,10 +31,10 @@ - - + + - + diff --git a/TransactionProcessor/nlog.config b/TransactionProcessor/nlog.config index 0cd9d21d..1ec67c78 100644 --- a/TransactionProcessor/nlog.config +++ b/TransactionProcessor/nlog.config @@ -33,7 +33,7 @@ s - +