This commit is contained in:
Zeeshaun
2026-03-17 08:54:34 -05:00
parent 64856c640e
commit cdcba54aa4
330 changed files with 54110 additions and 0 deletions
@@ -0,0 +1,120 @@
using ReserveManagementSystemLib.Configuration;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.LcuHttpClient.Utilities;
namespace ReserveManagementSystemApi.ServiceClients
{
public class CoreApiServiceClient : ICoreApiServiceClient
{
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
private readonly CoreApiConfiguration _coreApiWrapperConfiguration;
private readonly IPostRequest _postRequest;
private readonly IGetRequest _getRequest;
private readonly IPutRequest _putRequest;
private const string ClientKeyValue = "ReserveManagementSystem";
public CoreApiServiceClient(
ApiSecurityConfiguration apiSecurityConfiguration,
CoreApiConfiguration coreApiWrapperConfiguration,
IGetRequest getRequest,
IPostRequest postRequest,
IPutRequest putRequest
)
{
_apiSecurityConfiguration = apiSecurityConfiguration;
_coreApiWrapperConfiguration = coreApiWrapperConfiguration;
_getRequest = getRequest;
_postRequest = postRequest;
_putRequest = putRequest;
}
public async Task<List<MonetaryTransactionResponse>> PostMonetaryTransactions(List<GroupedMonetaryTransactionRequest> loanReserves)
{
try
{
var path = $"{_coreApiWrapperConfiguration.BaseUrl}{_coreApiWrapperConfiguration.PostMonetaryTransactions}";
var uri = new Uri(path);
var response = await _postRequest.Async<List<GroupedMonetaryTransactionRequest>, List<MonetaryTransactionResponse>>(uri, loanReserves,
HttpUtilities.GetApiKeyHeaders(ClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(ClientKeyValue, ApiKeySetName.InternalKeySet)),
0, Convert.ToInt16(_coreApiWrapperConfiguration.ApiTimeOutInSeconds));
return response;
}
catch (Exception ex)
{
Log.Error(ex, "Error in posting MonetaryTransactions.");
throw;
}
}
public async Task<List<UpdateDealerOriginalBalanceResponse>> PutDealerOriginalBalance(string accountNumber)
{
try
{
var path = $"{_coreApiWrapperConfiguration.BaseUrl}{_coreApiWrapperConfiguration.PutDealerOriginalBalance}";
var uri = new Uri(path);
var response = await _putRequest.Async<string, List<UpdateDealerOriginalBalanceResponse>>(uri, accountNumber,
HttpUtilities.GetApiKeyHeaders(ClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(ClientKeyValue, ApiKeySetName.InternalKeySet)),
0, Convert.ToUInt16(_coreApiWrapperConfiguration.ApiTimeOutInSeconds));
return response;
}
catch (Exception ex)
{
Log.Error(ex, "Error updating Dealer Original Balance");
throw;
}
}
public async Task<List<IndirectLoanDetail>> GetIndirectLoansByPostedDate(string afterPostDate)
{
try
{
var path = $"{_coreApiWrapperConfiguration.BaseUrl}{_coreApiWrapperConfiguration.GetIndirectLoansByPostedDate}{afterPostDate}";
var response = await _getRequest.AsyncWithNewton<List<IndirectLoanDetail>>(path, null, 0, Convert.ToUInt16(_coreApiWrapperConfiguration.ApiTimeOutInSeconds));
return response;
}
catch (Exception ex)
{
Log.Error(ex, "Error getting Indirect Loans By Posted Date");
return null;
}
}
public async Task<List<ClosedIndirectLoan>> GetClosedLoansByPostedDate(string afterPostDate)
{
try
{
var path = $"{_coreApiWrapperConfiguration.BaseUrl}{_coreApiWrapperConfiguration.GetClosedLoansByPostedDate}{afterPostDate}";
var response = await _getRequest.AsyncWithNewton<List<ClosedIndirectLoan>>(path);
return response;
}
catch (Exception ex)
{
Log.Error(ex, "Error getting Closed Loans By Posted Date");
}
return null;
}
public async Task<List<IndirectLoanDetail>> GetClosedLoansWithDetailByClosedDate(string afterClosedDate)
{
try
{
var path = $"{_coreApiWrapperConfiguration.BaseUrl}{_coreApiWrapperConfiguration.GetClosedIndirectLoansWithDetailByPostedDate}{afterClosedDate}";
var response = await _getRequest.AsyncWithNewton<List<IndirectLoanDetail>>(path);
return response;
}
catch (Exception ex)
{
Log.Error(ex, "Error getting Closed Loans With Detail");
}
return null;
}
}
}
@@ -0,0 +1,19 @@
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
namespace ReserveManagementSystemApi.ServiceClients
{
public interface ICoreApiServiceClient
{
Task<List<MonetaryTransactionResponse>> PostMonetaryTransactions(List<GroupedMonetaryTransactionRequest> loans);
Task<List<IndirectLoanDetail>> GetIndirectLoansByPostedDate(string afterPostDate);
Task<List<ClosedIndirectLoan>> GetClosedLoansByPostedDate(string afterPostDate);
Task<List<IndirectLoanDetail>> GetClosedLoansWithDetailByClosedDate(string afterClosedDate);
Task<List<UpdateDealerOriginalBalanceResponse>> PutDealerOriginalBalance(string accountNumber);
}
}