Adding
This commit is contained in:
+125
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ApiSecurity.Enums;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.CoreDbUtilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperLib.Utilities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.Constants;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess
|
||||
{
|
||||
public class TransactionDao : BaseCoreDao, ITransactionDao
|
||||
{
|
||||
private readonly CoreApiConfiguration _coreApiConfiguration;
|
||||
private readonly CoreSoapApiConfiguration _coreSoapApiConfiguration;
|
||||
private readonly ApiSecurityConfiguration _apiSecurityConfiguration;
|
||||
private readonly ICoreDbExecution _coreDbExecution;
|
||||
private readonly IPostRequest _postRequest;
|
||||
|
||||
private const string SoapClientKeyValue = "CoreSoapApiWrapper";
|
||||
|
||||
private const string GetExternalDescriptionsWithSSNQuery = "Transaction/GetExternalDescriptionsWithSSNQuery";
|
||||
private const string UpdateExternalDescriptionQuery = "Transaction/UpdateExternalDescriptionQuery";
|
||||
private const string GetTransactionsByDateSpanQuery = "Transaction/GetTransactionsByDateSpanQuery";
|
||||
|
||||
private const string RtxnTypCdQueryVerifyHolder = "{RtxnTypCdQueryVerifyHolder}";
|
||||
private const string RtxnTypCdQueryParamHolder = "{RtxnTypCdQueryParamHolder}";
|
||||
|
||||
public TransactionDao(ICoreRequest coreRequest,
|
||||
CoreConfiguration coreConfiguration,
|
||||
ApiSecurityConfiguration apiSecurityConfiguration,
|
||||
ICoreDbExecution coreDbExecution,
|
||||
IPostRequest postRequest) : base(coreRequest)
|
||||
{
|
||||
_coreApiConfiguration = coreConfiguration.CoreApiConfiguration;
|
||||
_coreSoapApiConfiguration = coreConfiguration.CoreSoapApiConfiguration;
|
||||
_apiSecurityConfiguration = apiSecurityConfiguration;
|
||||
_coreDbExecution = coreDbExecution;
|
||||
_postRequest = postRequest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls Core API to search based the AccountId and filled out TransactionHistoryRequest model.
|
||||
/// Default Included: Standard, Graph
|
||||
/// </summary>
|
||||
/// <param name="coreRequestParameters"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns>IEnumerable<TransactionHistory></returns>
|
||||
public async Task<IEnumerable<TransactionHistory>> FindTransactionHistoryById(CoreRequestParameters coreRequestParameters,
|
||||
TransactionHistoryRequest request,
|
||||
string accountId)
|
||||
{
|
||||
var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters);
|
||||
var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccountsTransactionHistoryQueryAccountNumber,
|
||||
RequestRootParameters.AccountId,
|
||||
accountId);
|
||||
var jsonBody = HttpUtilities.BuildJsonOfNonNullProperties(request);
|
||||
var result = await _coreRequest.PostRequestObject<CoreApiMessage<IEnumerable<TransactionHistory>>>(
|
||||
endpoint, endpointParameters, jsonBody);
|
||||
return result?.MessageBody;
|
||||
}
|
||||
|
||||
public async Task<List<MonetaryTransactionResponse>> AddMonetaryTransactions(List<GroupedMonetaryTransactionRequest> monetaryTransactionRequests)
|
||||
{
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostMonetaryTransactions);
|
||||
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
|
||||
|
||||
return await _postRequest.Async<List<GroupedMonetaryTransactionRequest>, List<MonetaryTransactionResponse>>(endpoint, monetaryTransactionRequests, headers, 0);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ExternalDescription>> FindExternalDescriptionsWithSsn()
|
||||
{
|
||||
var query = QueryUtilities.GetQuery(GetExternalDescriptionsWithSSNQuery);
|
||||
return await _coreDbExecution.ExecuteQuery<ExternalDescription>(query);
|
||||
}
|
||||
|
||||
public async Task<List<BasicResponse>> PostFundsToAccount(List<FundsToAccountRequest> fundsToAccount)
|
||||
{
|
||||
var endpoint = HttpUtilities.BuildHttpsUri(_coreSoapApiConfiguration.CoreSoapApiWrapperHost, _coreSoapApiConfiguration.CoreSoapEndpointConfiguration.PostFundsToAccount);
|
||||
var headers = LcuHttpClient.Utilities.HttpUtilities.GetApiKeyHeaders(SoapClientKeyValue, _apiSecurityConfiguration.ExtractApiKey(SoapClientKeyValue, ApiKeySetName.InternalKeySet));
|
||||
|
||||
return await _postRequest.Async<List<FundsToAccountRequest>, List<BasicResponse>>(endpoint, fundsToAccount, headers, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Note: ExecuteQuery does not return anything when running an Update statement.
|
||||
/// </summary>
|
||||
/// <param name="externalTransactionDescription"></param>
|
||||
public void UpdateExternalDescription(ExternalDescription externalTransactionDescription)
|
||||
{
|
||||
var query = QueryUtilities.GetQuery(UpdateExternalDescriptionQuery);
|
||||
var param = new
|
||||
{
|
||||
externaldescriptionnumber = externalTransactionDescription.ExternalDescriptionNumber,
|
||||
externaldescriptiontext = externalTransactionDescription.ExternalDescriptionText
|
||||
};
|
||||
var result = _coreDbExecution.ExecuteQuery<string, object>(query, param).Result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TransactionAlertInfo>> GetTransactionsByDateSpan(DateTime startDateRange,
|
||||
DateTime endDateRange,
|
||||
string rtxnTypCdToExcludeParams,
|
||||
string rtxnTypCdToExcludeVerify)
|
||||
{
|
||||
var query = QueryUtilities.GetQuery(GetTransactionsByDateSpanQuery);
|
||||
var alteredQuery = query.Replace(RtxnTypCdQueryVerifyHolder, rtxnTypCdToExcludeVerify)//;
|
||||
.Replace(RtxnTypCdQueryParamHolder, rtxnTypCdToExcludeParams);
|
||||
var param = new
|
||||
{
|
||||
startDateTime = startDateRange.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
endDateTime = endDateRange.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
};
|
||||
|
||||
return await _coreDbExecution.ExecuteQuery<TransactionAlertInfo, object>(alteredQuery, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user