Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion TransactionProcessor.Aggregates/EstateAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public static void PlayEvent(this EstateAggregate aggregate, EstateDomainEvents.
}

public static void PlayEvent(this EstateAggregate aggregate, EstateDomainEvents.OperatorRemovedFromEstateEvent domainEvent){
KeyValuePair<Guid, TransactionProcessor.Models.Estate.Operator> @operator = aggregate.Operators.Single(o => o.Key == domainEvent.OperatorId);
aggregate.Operators[domainEvent.OperatorId].IsDeleted = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public async Task<Result<Guid>> ProcessSettlement(SettlementCommands.ProcessSett
return await PolicyFactory.ExecuteWithPolicyAsync<Guid>(async () => {

Guid settlementAggregateId = Helpers.CalculateSettlementAggregateId(command.SettlementDate, command.MerchantId, command.EstateId);
List<(Guid transactionId, Guid merchantId, CalculatedFee calculatedFee)> feesToBeSettled = new();

Result<SettlementAggregate> getSettlementResult = await DomainServiceHelper.GetAggregateOrFailure(ct => this.AggregateService.GetLatest<SettlementAggregate>(settlementAggregateId, ct), settlementAggregateId, cancellationToken, false);
if (getSettlementResult.IsFailed)
Expand All @@ -73,7 +72,7 @@ public async Task<Result<Guid>> ProcessSettlement(SettlementCommands.ProcessSett
settlementSaveResult = await this.AggregateService.Save(settlementAggregate, cancellationToken);
}

feesToBeSettled = settlementAggregate.GetFeesToBeSettled();
List<(Guid transactionId, Guid merchantId, CalculatedFee calculatedFee)> feesToBeSettled = settlementAggregate.GetFeesToBeSettled();

if (feesToBeSettled.Any()) {
// Record the process call
Expand Down Expand Up @@ -189,7 +188,7 @@ public async Task<Result> AddSettledFeeToSettlement(SettlementCommands.AddSettle
return ResultHelpers.CreateFailure(getMerchantResult);

MerchantAggregate merchant = getMerchantResult.Data;
Result stateResult = Result.Failure();
Result stateResult;
if (merchant.SettlementSchedule == SettlementSchedule.Immediate) {
stateResult = settlementAggregate.ImmediatelyMarkFeeAsSettled(command.MerchantId, command.TransactionId, command.FeeId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task<Result<TransactionValidationResult>> ValidateLogonTransaction(
if (estateValidationResult.IsFailed) return CreateFailedResult(estateValidationResult.Data.validationResult);

// Validate Merchant
var merchantValidationResult = await ValidateMerchant(estateId, estateValidationResult.Data.additionalData.EstateName, merchantId, cancellationToken);
var merchantValidationResult = await ValidateMerchant(estateValidationResult.Data.additionalData.EstateName, merchantId, cancellationToken);
if (merchantValidationResult.IsFailed) return CreateFailedResult(merchantValidationResult.Data.validationResult); ;

Models.Merchant.Merchant merchant = merchantValidationResult.Data.additionalData.GetMerchant();
Expand All @@ -99,7 +99,7 @@ public async Task<Result<TransactionValidationResult>> ValidateReconciliationTra
EstateAggregate estate = estateValidationResult.Data.additionalData;

// Validate Merchant
Result<TransactionValidationResult<MerchantAggregate>> merchantValidationResult = await ValidateMerchant(estateId, estate.EstateName, merchantId, cancellationToken);
Result<TransactionValidationResult<MerchantAggregate>> merchantValidationResult = await ValidateMerchant(estate.EstateName, merchantId, cancellationToken);
if (merchantValidationResult.IsFailed) return CreateFailedResult(merchantValidationResult.Data.validationResult); ;

var merchant = merchantValidationResult.Data.additionalData.GetMerchant();
Expand Down Expand Up @@ -134,7 +134,7 @@ public async Task<Result<TransactionValidationResult>> ValidateSaleTransaction(G
if (estateOperatorValidationResult.IsFailed) return estateOperatorValidationResult;

// Validate Merchant
Result<TransactionValidationResult<MerchantAggregate>> merchantValidationResult = await ValidateMerchant(estateId, estate.EstateName, merchantId, cancellationToken);
Result<TransactionValidationResult<MerchantAggregate>> merchantValidationResult = await ValidateMerchant(estate.EstateName, merchantId, cancellationToken);
if (merchantValidationResult.IsFailed) return CreateFailedResult(merchantValidationResult.Data.validationResult); ;

Models.Merchant.Merchant merchant = merchantValidationResult.Data.additionalData.GetMerchant();
Expand All @@ -148,7 +148,7 @@ public async Task<Result<TransactionValidationResult>> ValidateSaleTransaction(G
if (merchantOperatorValidationResult.IsFailed) return merchantOperatorValidationResult;

// Validate Contract and Product
Result<TransactionValidationResult> contractProductValidationResult = await ValidateContractAndProduct(merchant, contractId, productId, cancellationToken);
Result<TransactionValidationResult> contractProductValidationResult = ValidateContractAndProduct(merchant, contractId, productId);
if (contractProductValidationResult.IsFailed) return contractProductValidationResult;

// Validate Transaction Amount
Expand Down Expand Up @@ -191,7 +191,7 @@ private Result<TransactionValidationResult> ValidateEstateOperator(EstateAggrega
return result;
}

private async Task<Result<TransactionValidationResult<MerchantAggregate>>> ValidateMerchant(Guid estateId, String estateName, Guid merchantId, CancellationToken cancellationToken)
private async Task<Result<TransactionValidationResult<MerchantAggregate>>> ValidateMerchant(String estateName, Guid merchantId, CancellationToken cancellationToken)
{
Result<MerchantAggregate> getMerchantResult = await this.AggregateService.Get<MerchantAggregate>(merchantId, cancellationToken);
if (getMerchantResult.IsFailed)
Expand Down Expand Up @@ -257,7 +257,7 @@ private Result<TransactionValidationResult> ValidateMerchantOperator(Models.Merc
return result;
}

private async Task<Result<TransactionValidationResult>> ValidateContractAndProduct(Models.Merchant.Merchant merchant, Guid contractId, Guid productId, CancellationToken cancellationToken)
private Result<TransactionValidationResult> ValidateContractAndProduct(Models.Merchant.Merchant merchant, Guid contractId, Guid productId)
{
if (contractId == Guid.Empty)
{
Expand Down
62 changes: 0 additions & 62 deletions TransactionProcessor.Client/TransactionProcessorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@
throw exception;
}

return response;

Check warning on line 79 in TransactionProcessor.Client/TransactionProcessorClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Unreachable code detected

Check warning on line 79 in TransactionProcessor.Client/TransactionProcessorClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

Unreachable code detected
}

public async Task<Result> CreateEstate(String accessToken,
CreateEstateRequest createEstateRequest,
CancellationToken cancellationToken) {
CreateEstateResponse response = null;

String requestUri = this.BuildRequestUrl("/api/estates/");

try {
Expand Down Expand Up @@ -116,8 +114,6 @@
public async Task<Result<List<EstateResponse>>> GetEstates(String accessToken,
Guid estateId,
CancellationToken cancellationToken) {
List<EstateResponse> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/all");

try {
Expand All @@ -143,8 +139,6 @@

throw exception;
}

return response;
}

public async Task<Result> CreateFloatForContractProduct(String accessToken,
Expand Down Expand Up @@ -282,8 +276,6 @@
Guid estateId,
String voucherCode,
CancellationToken cancellationToken) {
GetVoucherResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/vouchers?estateId={estateId}&voucherCode={voucherCode}");

try {
Expand Down Expand Up @@ -316,8 +308,6 @@
Guid estateId,
Guid transactionId,
CancellationToken cancellationToken) {
GetVoucherResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/vouchers?estateId={estateId}&transactionId={transactionId}");

try {
Expand Down Expand Up @@ -453,8 +443,6 @@
public async Task<Result<RedeemVoucherResponse>> RedeemVoucher(String accessToken,
RedeemVoucherRequest redeemVoucherRequest,
CancellationToken cancellationToken) {
RedeemVoucherResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/vouchers");

try {
Expand Down Expand Up @@ -849,8 +837,6 @@
Guid estateId,
CreateContractRequest createContractRequest,
CancellationToken cancellationToken) {
CreateContractResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/");

try {
Expand Down Expand Up @@ -884,8 +870,6 @@
Guid estateId,
CreateOperatorRequest createOperatorRequest,
CancellationToken cancellationToken) {
CreateOperatorResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators");

try {
Expand Down Expand Up @@ -953,8 +937,6 @@
Guid estateId,
CreateMerchantRequest createMerchantRequest,
CancellationToken cancellationToken) {
CreateMerchantResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants");

try {
Expand Down Expand Up @@ -1086,8 +1068,6 @@
Guid estateId,
Guid contractId,
CancellationToken cancellationToken) {
ContractResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/{contractId}");

try {
Expand All @@ -1114,15 +1094,11 @@

throw exception;
}

return response;
}

public async Task<Result<List<ContractResponse>>> GetContracts(String accessToken,
Guid estateId,
CancellationToken cancellationToken) {
List<ContractResponse> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts");

try {
Expand All @@ -1148,16 +1124,12 @@

throw exception;
}

return response;
}

public async Task<Result<MerchantResponse>> GetMerchant(String accessToken,
Guid estateId,
Guid merchantId,
CancellationToken cancellationToken) {
MerchantResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}");

try {
Expand All @@ -1183,16 +1155,12 @@

throw exception;
}

return response;
}

public async Task<Result<List<ContractResponse>>> GetMerchantContracts(String accessToken,
Guid estateId,
Guid merchantId,
CancellationToken cancellationToken) {
List<ContractResponse> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contracts");

try {
Expand All @@ -1218,15 +1186,11 @@

throw exception;
}

return response;
}

public async Task<Result<List<MerchantResponse>>> GetMerchants(String accessToken,
Guid estateId,
CancellationToken cancellationToken) {
List<MerchantResponse> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants");

try {
Expand All @@ -1252,17 +1216,13 @@

throw exception;
}

return response;
}

public async Task<Result<DataTransferObjects.Responses.Settlement.SettlementResponse>> GetSettlement(String accessToken,
Guid estateId,
Guid? merchantId,
Guid settlementId,
CancellationToken cancellationToken) {
DataTransferObjects.Responses.Settlement.SettlementResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/settlements/{settlementId}?merchantId={merchantId}");

try {
Expand All @@ -1282,14 +1242,12 @@

return Result.Success(responseData.Data);
}
catch (Exception ex) {

Check warning on line 1245 in TransactionProcessor.Client/TransactionProcessorClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'ex' is declared but never used

Check warning on line 1245 in TransactionProcessor.Client/TransactionProcessorClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'ex' is declared but never used
// An exception has occurred, add some additional information to the message
Exception exception = new($"Error getting settlement id {settlementId} for estate [{estateId}]");

throw exception;
}

return response;
}

public async Task<Result<List<DataTransferObjects.Responses.Settlement.SettlementResponse>>> GetSettlements(String accessToken,
Expand All @@ -1298,8 +1256,6 @@
String startDate,
String endDate,
CancellationToken cancellationToken) {
List<DataTransferObjects.Responses.Settlement.SettlementResponse> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/settlements?merchantId={merchantId}&start_date={startDate}&end_date={endDate}");

try {
Expand All @@ -1319,14 +1275,12 @@

return Result.Success(responseData.Data);
}
catch (Exception ex) {

Check warning on line 1278 in TransactionProcessor.Client/TransactionProcessorClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'ex' is declared but never used

Check warning on line 1278 in TransactionProcessor.Client/TransactionProcessorClient.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests

The variable 'ex' is declared but never used
// An exception has occurred, add some additional information to the message
Exception exception = new($"Error getting settlements for estate [{estateId}]");

throw exception;
}

return response;
}

public async Task<Result<List<ContractProductTransactionFee>>> GetTransactionFeesForProduct(String accessToken,
Expand All @@ -1335,8 +1289,6 @@
Guid contractId,
Guid productId,
CancellationToken cancellationToken) {
List<ContractProductTransactionFee> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contracts/{contractId}/products/{productId}/transactionFees");

try {
Expand All @@ -1363,8 +1315,6 @@

throw exception;
}

return response;
}

public async Task<Result> MakeMerchantDeposit(String accessToken,
Expand Down Expand Up @@ -1406,8 +1356,6 @@
Guid merchantId,
MakeMerchantWithdrawalRequest makeMerchantWithdrawalRequest,
CancellationToken cancellationToken) {
MakeMerchantWithdrawalResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/withdrawals");

try {
Expand Down Expand Up @@ -1442,8 +1390,6 @@
Guid merchantId,
SetSettlementScheduleRequest setSettlementScheduleRequest,
CancellationToken cancellationToken) {
MakeMerchantDepositResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}");

try {
Expand Down Expand Up @@ -1651,8 +1597,6 @@
Guid estateId,
Guid operatorId,
CancellationToken cancellationToken) {
OperatorResponse response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators/{operatorId}");

try {
Expand All @@ -1678,15 +1622,11 @@

throw exception;
}

return response;
}

public async Task<Result<List<OperatorResponse>>> GetOperators(String accessToken,
Guid estateId,
CancellationToken cancellationToken) {
List<OperatorResponse> response = null;

String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators");

try {
Expand All @@ -1712,7 +1652,5 @@

throw exception;
}

return response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
///
/// </summary>
[ExcludeFromCodeCoverage]
public class MetadataContants
public static class MetadataContants
{
#region Others

Expand Down
Loading
Loading