Adding
This commit is contained in:
+351
@@ -0,0 +1,351 @@
|
||||
using LCU.Api.Internal.DispatcherSharedLib.Configurations;
|
||||
using LCU.Api.Internal.FTPLib.Models;
|
||||
using LCU.API.Internal.BlendApiWrapperModels.Models.Request;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Models;
|
||||
using LCU.Library.Internal.DialerApiModels.Requests;
|
||||
using LCU.Library.Internal.DialerApiModels.Requests.CreateVoAppsCampaign;
|
||||
using LCU.Library.Internal.DialerApiModels.Requests.UploadVoAppsCampaignResults;
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
using LCU.Library.Internal.DocumentIngestorModels.Models;
|
||||
using LCU.Library.Internal.DocumentIngestorModels.Requests;
|
||||
using LCU.Library.Internal.DocumentTypeCleanupModels.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.Requests;
|
||||
using LCU.Library.Internal.FileUpdaterModels.Models.Requests;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using LCU.Library.Internal.MomBotModels.Models;
|
||||
using LCU.Library.Internal.NoticeProcessorModel.Models;
|
||||
using LCU.Library.Internal.NotificationsModels.Models;
|
||||
using LCU.Library.Internal.RealTimeAlertsModels.Models.Requests;
|
||||
using LCU.Library.Internal.RemoteDepositCaptureModel.Models;
|
||||
using LCU.Library.Internal.RepoApiModels.Models.Requests;
|
||||
using LCU.Library.Internal.TemenosNotificationApiModels.Requests;
|
||||
using System;
|
||||
|
||||
namespace LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
|
||||
public class ActionBuilderService : IActionBuilderService
|
||||
{
|
||||
private readonly FileOperationsApiConfiguration _fileOperationsApiConfiguration;
|
||||
private readonly FtpApiConfiguration _ftpApiConfiguration;
|
||||
private readonly NotificationApiConfiguration _notificationApiConfiguration;
|
||||
private readonly ArchiverApiConfiguration _archiverApiConfiguration;
|
||||
private readonly DocumentIngestorApiConfiguration _documentIngestorApiConfiguration;
|
||||
private readonly DocumentTypeCleanupApiConfiguration _documentTypeCleanupApiConfiguration;
|
||||
private readonly HistoricalDocumentIngestorApiConfiguration _historicalDocumentIngestorApiConfiguration;
|
||||
private readonly RemoteDepositCaptureApiConfiguration _remoteDepositCaptureApiConfiguration;
|
||||
private readonly DataCleanUpApiConfiguration _dataCleanUpApiConfiguration;
|
||||
private readonly NoticeProcessorApiConfiguration _noticeProcessorApiConfiguration;
|
||||
private readonly MomBotApiConfiguration _momBotApiConfiguration;
|
||||
private readonly BlendApiConfiguration _blendApiConfiguration;
|
||||
private readonly DialerApiConfiguration _dialerApiConfiguration;
|
||||
private readonly IncentiveManagerConfiguration _incentiveManagerApiConfiguration;
|
||||
private readonly FileUpdaterApiConfiguration _fileUpdaterApiConfiguration;
|
||||
private readonly TemenosNotificationApiConfiguration _temenosNotificationApiConfiguration;
|
||||
private readonly RealTimeAlertsApiConfiguration _realTimeAlertsApiConfiguration;
|
||||
private readonly RepoApiConfiguration _repoApiConfiguration;
|
||||
|
||||
public ActionBuilderService(FileOperationsApiConfiguration fileOperationsApiConfiguration,
|
||||
FtpApiConfiguration ftpApiConfiguration,
|
||||
NotificationApiConfiguration notificationApiConfiguration,
|
||||
ArchiverApiConfiguration archiverApiConfiguration,
|
||||
DocumentIngestorApiConfiguration documentIngestorApiConfiguration,
|
||||
DocumentTypeCleanupApiConfiguration documentTypeCleanupApiConfiguration,
|
||||
HistoricalDocumentIngestorApiConfiguration historicalDocumentIngestorApiConfiguration,
|
||||
RemoteDepositCaptureApiConfiguration remoteDepositCaptureApiConfiguration,
|
||||
DataCleanUpApiConfiguration dataCleanUpApiConfiguration,
|
||||
NoticeProcessorApiConfiguration noticeProcessorApiConfiguration,
|
||||
MomBotApiConfiguration momBotApiConfiguration,
|
||||
BlendApiConfiguration blendApiConfiguration,
|
||||
DialerApiConfiguration dialerApiConfiguration,
|
||||
IncentiveManagerConfiguration incentiveManagerConfiguration,
|
||||
FileUpdaterApiConfiguration fileUpdaterApiConfiguration,
|
||||
TemenosNotificationApiConfiguration temenosNotificationApiConfiguration,
|
||||
RealTimeAlertsApiConfiguration realTimeAlertsApiConfiguration,
|
||||
RepoApiConfiguration repoApiConfiguration)
|
||||
{
|
||||
_fileOperationsApiConfiguration = fileOperationsApiConfiguration;
|
||||
_ftpApiConfiguration = ftpApiConfiguration;
|
||||
_notificationApiConfiguration = notificationApiConfiguration;
|
||||
_archiverApiConfiguration = archiverApiConfiguration;
|
||||
_documentIngestorApiConfiguration = documentIngestorApiConfiguration;
|
||||
_documentTypeCleanupApiConfiguration = documentTypeCleanupApiConfiguration;
|
||||
_historicalDocumentIngestorApiConfiguration = historicalDocumentIngestorApiConfiguration;
|
||||
_remoteDepositCaptureApiConfiguration = remoteDepositCaptureApiConfiguration;
|
||||
_dataCleanUpApiConfiguration = dataCleanUpApiConfiguration;
|
||||
_noticeProcessorApiConfiguration = noticeProcessorApiConfiguration;
|
||||
_momBotApiConfiguration = momBotApiConfiguration;
|
||||
_blendApiConfiguration = blendApiConfiguration;
|
||||
_dialerApiConfiguration = dialerApiConfiguration;
|
||||
_incentiveManagerApiConfiguration = incentiveManagerConfiguration;
|
||||
_fileUpdaterApiConfiguration = fileUpdaterApiConfiguration;
|
||||
_temenosNotificationApiConfiguration = temenosNotificationApiConfiguration;
|
||||
_realTimeAlertsApiConfiguration = realTimeAlertsApiConfiguration;
|
||||
_repoApiConfiguration = repoApiConfiguration;
|
||||
}
|
||||
|
||||
public IActionService BuildAction(ActionType actionType)
|
||||
{
|
||||
var actionTypeStringified = Enum.GetName(typeof(ActionType), actionType);
|
||||
return BuildAction(actionTypeStringified);
|
||||
}
|
||||
|
||||
public IActionService BuildAction(string actionType)
|
||||
{
|
||||
return actionType switch
|
||||
{
|
||||
#region FileOperationsApi
|
||||
nameof(ActionType.MoveFile) => new ActionService<MoveFileRequest>(_fileOperationsApiConfiguration.MoveFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.MoveFile),
|
||||
nameof(ActionType.ModifyFile) => new ActionService<ModifyFileRequest>(_fileOperationsApiConfiguration.ModifyFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ModifyFile),
|
||||
nameof(ActionType.CopyFile) => new ActionService<CopyFileRequest>(_fileOperationsApiConfiguration.CopyFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.CopyFile),
|
||||
nameof(ActionType.DeleteFile) => new ActionService<DeleteFileRequest>(_fileOperationsApiConfiguration.DeleteFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DeleteFile),
|
||||
nameof(ActionType.RenameFile) => new ActionService<RenameFileRequest>(_fileOperationsApiConfiguration.RenameFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.RenameFile),
|
||||
nameof(ActionType.ZipDirectory) => new ActionService<ZipDirectoryRequest>(_fileOperationsApiConfiguration.ZipDirectoryEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ZipDirectory),
|
||||
nameof(ActionType.CreateDirectory) => new ActionService<CreateDirectoryRequest>(_fileOperationsApiConfiguration.CreateDirectoryEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.CreateDirectory),
|
||||
nameof(ActionType.RenameDirectory) => new ActionService<RenameDirectoryRequest>(_fileOperationsApiConfiguration.RenameDirectoryEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.RenameDirectory),
|
||||
nameof(ActionType.UnzipFile) => new ActionService<UnzipFileRequest>(_fileOperationsApiConfiguration.UnzipFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.UnzipFile),
|
||||
nameof(ActionType.EncryptFileData) => new ActionService<EncryptFileDataRequest>(_fileOperationsApiConfiguration.EncryptFileDataEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.EncryptFileData),
|
||||
nameof(ActionType.DecryptFileData) => new ActionService<DecryptFileDataRequest>(_fileOperationsApiConfiguration.DecryptFileDataEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DecryptFileData),
|
||||
nameof(ActionType.UnzipPasswordProtectedFile) => new ActionService<UnzipPasswordProtectedFileRequest>(_fileOperationsApiConfiguration.UnzipPasswordProtectedFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.UnzipPasswordProtectedFile),
|
||||
nameof(ActionType.DeleteDirectory) => new ActionService<DeleteDirectoryRequest>(_fileOperationsApiConfiguration.DeleteDirectoryEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DeleteDirectory),
|
||||
nameof(ActionType.ExtractIndexFileData) => new ActionService<ExtractIndexFileDataRequest>(_fileOperationsApiConfiguration.ExtractIndexFileDataEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ExtractIndexFileData),
|
||||
nameof(ActionType.ValidateFileRequest) => new ActionService<ValidateFileRequest>(_fileOperationsApiConfiguration.FileValidationEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ValidateFileRequest),
|
||||
nameof(ActionType.ValidateFileSizeInRange) => new ActionService<ValidateFileSizeInRangeRequest>(_fileOperationsApiConfiguration.ValidateFileSizeInRangeUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ValidateFileSizeInRange),
|
||||
nameof(ActionType.DeleteEmptyDirectoryRequest) => new ActionService<DeleteEmptyDirectoryRequest>(_fileOperationsApiConfiguration.DeleteEmptyDirectoryEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DeleteEmptyDirectoryRequest),
|
||||
#endregion FileOperationsApi
|
||||
|
||||
#region FtpApi
|
||||
nameof(ActionType.SftpDownloadFile) => new ActionService<SftpDownloadFileRequest>(_ftpApiConfiguration.QueueSftpDownloadFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.SftpDownloadFile),
|
||||
nameof(ActionType.SftpUploadFile) => new ActionService<SftpUploadFileRequest>(_ftpApiConfiguration.QueueSftpUploadFileEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.SftpUploadFile),
|
||||
#endregion FtpApi
|
||||
|
||||
#region NotificationsApi
|
||||
nameof(ActionType.Email) => new ActionService<EmailRequest>(_notificationApiConfiguration.EmailEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.Email),
|
||||
#endregion NotificationsApi
|
||||
|
||||
#region ArchiverApi
|
||||
nameof(ActionType.CoreArchiveRequest) => new ActionService<ArchiveRequest>(_archiverApiConfiguration.QueueArchiverEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.CoreArchiveRequest),
|
||||
#endregion ArchiverApi
|
||||
|
||||
#region DocumentIngestorApi
|
||||
nameof(ActionType.DocumentIngestor) => new ActionService<IngestorRequest>(_documentIngestorApiConfiguration.QueueDocumentIngestorEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DocumentIngestor),
|
||||
nameof(ActionType.DocumentBatchIngestion) => new ActionService<BatchIngestionRequest>(_documentIngestorApiConfiguration.QueueDocumentBatchIngestionEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DocumentBatchIngestion),
|
||||
nameof(ActionType.IngestorPdfPartitioner) => new ActionService<PdfPartitionerRequest>(_documentIngestorApiConfiguration.QueueIngestorPdfPartitionerEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.IngestorPdfPartitioner),
|
||||
nameof(ActionType.MemberDocumentNotification) => new ActionService<MemberDocumentNotificationRequest>(_documentIngestorApiConfiguration.QueueMemberDocumentNotifierEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.MemberDocumentNotification),
|
||||
nameof(ActionType.IngestionFolderCleanUp) => new ActionService<IngestionFolderCleanUpRequest>(_documentIngestorApiConfiguration.QueueIngestionFolderCleanUpEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.IngestionFolderCleanUp),
|
||||
nameof(ActionType.DocumentIngestorProcessStatusEmail) => new ActionService<ProcessStatusTypeEmailRequest>(_documentIngestorApiConfiguration.QueueProcessStatusEmailRequestEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DocumentIngestorProcessStatusEmail),
|
||||
|
||||
#endregion DocumentIngestorApi
|
||||
|
||||
#region DocumentTypeCleanupApi
|
||||
nameof(ActionType.DocumentRetentionCleanupRequest) => new ActionService<DocumentRetentionLookupRequest>(_documentTypeCleanupApiConfiguration.QueueDocumentRetentionCleanupEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DocumentRetentionCleanupRequest),
|
||||
|
||||
#endregion DocumentTypeCleanupApi
|
||||
|
||||
#region HistoricalDocumentIngestorApi
|
||||
nameof(ActionType.HistoricalDocumentIngestor) => new ActionService<IngestorRequest>(_historicalDocumentIngestorApiConfiguration.QueueDocumentIngestorEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.HistoricalDocumentIngestor),
|
||||
nameof(ActionType.HistoricalDocumentBatchIngestion) => new ActionService<BatchIngestionRequest>(_historicalDocumentIngestorApiConfiguration.QueueDocumentBatchIngestionEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.HistoricalDocumentBatchIngestion),
|
||||
nameof(ActionType.HistoricalIngestorPdfPartitioner) => new ActionService<PdfPartitionerRequest>(_historicalDocumentIngestorApiConfiguration.QueueIngestorPdfPartitionerEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.HistoricalIngestorPdfPartitioner),
|
||||
#endregion HistoricalDocumentIngestorApi
|
||||
|
||||
#region RemoteDepositCaptureApi
|
||||
nameof(ActionType.RemoteDepositCaptureXmlFile) => new ActionService<RemoteDepositCaptureXmlRequest>(_remoteDepositCaptureApiConfiguration.QueueRemoteDepositCaptureXmlEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.RemoteDepositCaptureXmlFile),
|
||||
#endregion RemoteDepositCaptureApi
|
||||
|
||||
#region DataCleanUpApi
|
||||
nameof(ActionType.DataCleanUp) => new ActionService<DataCleanUpRequest>(_dataCleanUpApiConfiguration.QueueDataCleanUpEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DataCleanUp),
|
||||
nameof(ActionType.AtmPersonCheckHolds) => new ActionService<UpdatePersonForCheckHoldRequest>(_dataCleanUpApiConfiguration.QueueUpdatePersonForCheckHoldsEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.AtmPersonCheckHolds),
|
||||
nameof(ActionType.DataCleanupNcoaUpdateRequest) => new ActionService<NcoaUpdateRequest>(_dataCleanUpApiConfiguration.QueueNcoaUpdateRequestEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DataCleanupNcoaUpdateRequest),
|
||||
nameof(ActionType.DataCleanUpFannieMaeRequest) => new ActionService<FannieMaeMortgageRequest>(_dataCleanUpApiConfiguration.QueueUpdateFannieMaeMortgageRequestEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DataCleanUpFannieMaeRequest),
|
||||
nameof(ActionType.DataCleanUpIndirectFundingRequest) => new ActionService<IndirectFundingRequest>(_dataCleanUpApiConfiguration.QueueIndirectFundingEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DataCleanUpIndirectFundingRequest),
|
||||
#endregion DataCleanUpApi
|
||||
|
||||
#region NoticeProcessorApi
|
||||
nameof(ActionType.NoticeProcessorExtractRequest) => new ActionService<ExtractRequest>(_noticeProcessorApiConfiguration.QueueExtractEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.NoticeProcessorExtractRequest),
|
||||
nameof(ActionType.NoticeProcessorSummaryEmailRequest) => new ActionService<ProcessingEmailRequest>(_noticeProcessorApiConfiguration.QueueProcessingEmailSummaryEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.NoticeProcessorSummaryEmailRequest),
|
||||
#endregion DataCleanUpApi
|
||||
|
||||
#region MomBotApi
|
||||
nameof(ActionType.MomBotRequest) => new ActionService<MomBotRequest>(_momBotApiConfiguration.QueueMomBotEndpointUrl, HttpMethodType.Post, ActionType.MomBotRequest),
|
||||
#endregion MomBotApi
|
||||
|
||||
#region BlendApi
|
||||
nameof(ActionType.BlendDataRequest) => new ActionService<SyncDataFromBlendRequest>(_blendApiConfiguration.QueueDataImportEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.BlendDataRequest),
|
||||
#endregion BlendApi
|
||||
|
||||
#region DialerApi
|
||||
nameof(ActionType.DialerUploadRequest) => new ActionService<DialerUploadRequest>(_dialerApiConfiguration.QueueDialerUploadEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DialerUploadRequest),
|
||||
nameof(ActionType.UploadDoNotCallRequest) => new ActionService<UploadDoNotCallRequest>(_dialerApiConfiguration.QueueUploadDoNotCallEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.UploadDoNotCallRequest),
|
||||
nameof(ActionType.CreateVoAppsCampaignsRequest) => new ActionService<CreateVoAppsCampaignRequest>(_dialerApiConfiguration.QueueCreateVoAppsCampaignEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.CreateVoAppsCampaignsRequest),
|
||||
nameof(ActionType.UploadVoAppsCampaignResultsRequest) => new ActionService<UploadVoAppsCampaignResultsInitiateRequest>(_dialerApiConfiguration.QueueUploadVoAppsCampaignResultsEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.UploadVoAppsCampaignResultsRequest),
|
||||
nameof(ActionType.UploadVoAppsCampaignResultsErrorRequest) => new ActionService<UploadVoAppsCampaignResultsErrorRequest>(_dialerApiConfiguration.QueueUploadVoAppsCampaignErrorRequestEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.UploadVoAppsCampaignResultsErrorRequest),
|
||||
#endregion DialerApi
|
||||
|
||||
#region IncentiveManagerApi
|
||||
nameof(ActionType.ImportCreditCardSalesRequest) => new ActionService<ImportCreditCardSalesRequest>(_incentiveManagerApiConfiguration.QueueCreditCardImportEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ImportCreditCardSalesRequest),
|
||||
|
||||
nameof(ActionType.ImportIndirectVehicleSalesRequest) => new ActionService<ImportIndirectVehicleSalesRequest>(_incentiveManagerApiConfiguration.QueueVehicleImportEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ImportIndirectVehicleSalesRequest),
|
||||
|
||||
nameof(ActionType.IncentiveProcessRequest) => new ActionService<IncentiveProcessRequest>(_incentiveManagerApiConfiguration.QueueIncentiveProcessEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.IncentiveProcessRequest),
|
||||
|
||||
nameof(ActionType.NightlyIncentiveProcessRequest) => new ActionService<NightlyIncentiveProcessRequest>(_incentiveManagerApiConfiguration.QueueNightlyIncentiveProcessEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.NightlyIncentiveProcessRequest),
|
||||
|
||||
nameof(ActionType.ActionCreditCardRequest) => new ActionService<ActionCreditCardRequest>(_incentiveManagerApiConfiguration.QueueActionCreditCardEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ActionCreditCardRequest),
|
||||
|
||||
nameof(ActionType.ActionVehicleRequest) => new ActionService<ActionVehicleRequest>(_incentiveManagerApiConfiguration.QueueActionVehicleEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ActionVehicleRequest),
|
||||
|
||||
nameof(ActionType.AlliedGapMbpRequest) => new ActionService<AlliedGapMbpRequest>(_incentiveManagerApiConfiguration.QueueAlliedGapMbpEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.AlliedGapMbpRequest),
|
||||
|
||||
nameof(ActionType.DayforceProcessRequest) => new ActionService<DayforceProcessRequest>(_incentiveManagerApiConfiguration.QueueDayforceProcessEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DayforceProcessRequest),
|
||||
|
||||
nameof(ActionType.GoalDispersalRequest) => new ActionService<GoalDispersalRequest>(_incentiveManagerApiConfiguration.QueueGoalDispersalProcessEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.GoalDispersalRequest),
|
||||
|
||||
nameof(ActionType.PayoutIncentiveRequest) => new ActionService<PayoutIncentiveRequest>(_incentiveManagerApiConfiguration.QueuePayoutProcessEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.PayoutIncentiveRequest),
|
||||
|
||||
nameof(ActionType.ReportingRequest) => new ActionService<ReportingRequest>(_incentiveManagerApiConfiguration.QueueReportingProcessEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.ReportingRequest),
|
||||
#endregion IncentiveManagerApi
|
||||
|
||||
#region FileUpdaterApi
|
||||
nameof(ActionType.IndexFieldMapperRequest) => new ActionService<IndexFieldMapperRequest>(_fileUpdaterApiConfiguration.QueueIndexFieldMapperUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.IndexFieldMapperRequest),
|
||||
#endregion
|
||||
|
||||
#region TemenosNotificationApi
|
||||
nameof(ActionType.DealerAchNotificationRequest) => new ActionService<DealerAchNotificationRequest>(_temenosNotificationApiConfiguration.QueueDealerAchNotificationUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.DealerAchNotificationRequest),
|
||||
#endregion
|
||||
|
||||
#region RealTimeAlertsApi
|
||||
nameof(ActionType.InitiateRealTimeAlertsRequest) => new ActionService<InitiateTransactionAlertsRequest>(_realTimeAlertsApiConfiguration.QueueInitiateRealTimeAlertsEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.InitiateRealTimeAlertsRequest),
|
||||
nameof(ActionType.InitiateRealTimeAlertsErroredProcessingRequest) => new ActionService<InitiateErroredTransactionCleanUpRequest>(_realTimeAlertsApiConfiguration.QueueErroredTransactionCleanUpEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.InitiateRealTimeAlertsErroredProcessingRequest),
|
||||
#endregion
|
||||
|
||||
#region RepoApi
|
||||
nameof(ActionType.RepoBatchProcessRequest) => new ActionService<RepoBatchRequest>(_repoApiConfiguration.AccountBatchEndpointUrl,
|
||||
HttpMethodType.Post,
|
||||
ActionType.RepoBatchProcessRequest),
|
||||
#endregion RepoApi
|
||||
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
using LCU.Library.Internal.DispatcherModels.Entities;
|
||||
using LCU.Library.Internal.DispatcherModels.Models;
|
||||
namespace LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
|
||||
public class ActionService<TRequest> : IActionService where TRequest : ReturnResponse
|
||||
{
|
||||
private readonly string Url;
|
||||
private readonly HttpMethodType HttpMethodType;
|
||||
private readonly ActionType ActionType;
|
||||
|
||||
public ActionService(string url, HttpMethodType httpMethodType, ActionType actionType)
|
||||
{
|
||||
Url = url;
|
||||
HttpMethodType = httpMethodType;
|
||||
ActionType = actionType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NOTE: This will only work if the proper configuration has been setup.
|
||||
/// </summary>
|
||||
/// <param name="workItem"></param>
|
||||
/// <returns></returns>
|
||||
public WorkItem AddUrlAndHttpMethod(WorkItem workItem)
|
||||
{
|
||||
if (Url is null)
|
||||
{
|
||||
throw new ArgumentNullException("Url has not been set by configuration.");
|
||||
}
|
||||
|
||||
workItem.Url = Url;
|
||||
workItem.HttpMethod = HttpMethodType;
|
||||
return workItem;
|
||||
}
|
||||
|
||||
public WorkItem CreateNewWorkitem(object request, WorkItemDetails workItemDetails)
|
||||
{
|
||||
var workItemRequest = (TRequest)request;
|
||||
return new WorkItem
|
||||
{
|
||||
WorkItemId = workItemDetails.WorkItemId,
|
||||
JobId = workItemDetails.JobId,
|
||||
Name = workItemDetails.Name,
|
||||
Description = workItemDetails.Description,
|
||||
Order = workItemDetails.Order,
|
||||
Url = "",
|
||||
HttpMethod = HttpMethodType.Unknown,
|
||||
SerializedPayload = JsonConvert.SerializeObject(workItemRequest),
|
||||
ActionType = ActionType,
|
||||
CancelJobOnFailure = workItemDetails.CancelJobOnFailure,
|
||||
CancelJobLimit = workItemDetails.CancelJobLimit,
|
||||
CanceledJobCounter = 0
|
||||
};
|
||||
}
|
||||
|
||||
public Type GetActionType()
|
||||
{
|
||||
return typeof(TRequest);
|
||||
}
|
||||
|
||||
public WorkItem AddWorkItemReturnResponse(WorkItem workItem, ResponseItem responseItem)
|
||||
{
|
||||
var deserilizedObject = JsonConvert.DeserializeObject<TRequest>(workItem.SerializedPayload);
|
||||
deserilizedObject.ResponseItems = RemoveDispatcherReturnResponse(deserilizedObject.ResponseItems);
|
||||
deserilizedObject.ResponseItems.Add(responseItem);
|
||||
workItem.SerializedPayload = JsonConvert.SerializeObject(deserilizedObject);
|
||||
return workItem;
|
||||
}
|
||||
|
||||
private List<ResponseItem> RemoveDispatcherReturnResponse(List<ResponseItem> responseItems)
|
||||
{
|
||||
var toRemove = new List<ResponseItem>();
|
||||
if (responseItems == null)
|
||||
{
|
||||
return toRemove;
|
||||
}
|
||||
|
||||
foreach (var responseItem in responseItems)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existingReturnResponse = JsonConvert.DeserializeObject<DispatcherReturnResponse>(responseItem.ResponsePayload);
|
||||
toRemove.Add(responseItem);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var responseItem in toRemove)
|
||||
{
|
||||
responseItems.Remove(responseItem);
|
||||
}
|
||||
|
||||
return responseItems;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
namespace LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
|
||||
public interface IActionBuilderService
|
||||
{
|
||||
IActionService BuildAction(ActionType type);
|
||||
IActionService BuildAction(string type);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.DispatcherModels.Entities;
|
||||
using LCU.Library.Internal.DispatcherModels.Models;
|
||||
namespace LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
|
||||
public interface IActionService
|
||||
{
|
||||
WorkItem AddUrlAndHttpMethod(WorkItem workItem);
|
||||
WorkItem CreateNewWorkitem(object request, WorkItemDetails workItemDetails);
|
||||
Type GetActionType();
|
||||
WorkItem AddWorkItemReturnResponse(WorkItem workItem, ResponseItem responseItem);
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using LCU.Library.Internal.DispatcherModels.Models;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
using System.Threading.Tasks;
|
||||
namespace LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
|
||||
public interface IRequestBuilderService
|
||||
{
|
||||
void ClearJob();
|
||||
void CreateJob(JobDetails jobDetails);
|
||||
Task<bool> SendDispatcherRequest(ReturnResponse returnResponse = null);
|
||||
Type GetDispatcherTypeByString(string type);
|
||||
void AddWorkItem(object request, WorkItemDetails workItemDetails, ActionType actionType);
|
||||
void AddWorkItem(object request, WorkItemDetails workItemDetails, string actionType);
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.DispatcherModels.Entities;
|
||||
using LCU.Library.Internal.DispatcherModels.Models;
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
using LCU.Api.Internal.DispatcherSharedLib.Utilities;
|
||||
using LCU.Api.Internal.DispatcherSharedLib.Configurations;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
namespace LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
||||
|
||||
public class RequestBuilderService : IRequestBuilderService
|
||||
{
|
||||
private readonly IPostRequest _postRequest;
|
||||
private readonly IActionBuilderService _actionBuilderService;
|
||||
private readonly DispatcherRequestBuilderConfiguration _requestBuilderConfiguration;
|
||||
private Job JobRequest;
|
||||
|
||||
public RequestBuilderService(IPostRequest postRequest,
|
||||
IActionBuilderService actionBuilderService,
|
||||
DispatcherRequestBuilderConfiguration requestBuilderConfiguration)
|
||||
{
|
||||
_postRequest = postRequest;
|
||||
_actionBuilderService = actionBuilderService;
|
||||
_requestBuilderConfiguration = requestBuilderConfiguration;
|
||||
}
|
||||
|
||||
public void ClearJob()
|
||||
{
|
||||
JobRequest = null;
|
||||
}
|
||||
|
||||
public void CreateJob(JobDetails jobDetails)
|
||||
{
|
||||
ClearJob();
|
||||
|
||||
JobRequest = new Job
|
||||
{
|
||||
JobId = jobDetails.JobId,
|
||||
RequestingApplication = jobDetails.RequestingApplication,
|
||||
Name = jobDetails.Name,
|
||||
Description = jobDetails.Description,
|
||||
CreatedBy = jobDetails.CreatedBy,
|
||||
CreatedAt = jobDetails.CreatedAt,
|
||||
ModifiedBy = jobDetails.ModifiedBy,
|
||||
ModifiedDate = jobDetails.ModifiedDate,
|
||||
CronSchedule = jobDetails.CronSchedule,
|
||||
NextRunTime = jobDetails.NextRunTime,
|
||||
SkipHolidays = jobDetails.SkipHolidays,
|
||||
JobErrorRecipients = CreateJobErrorRecipients(jobDetails),
|
||||
WorkItems = new List<WorkItem>(),
|
||||
JobTags = jobDetails.JobTags,
|
||||
JobStatus = jobDetails.JobStatus
|
||||
};
|
||||
|
||||
CronHelpers.SetNextScheduledRunTime(ref JobRequest);
|
||||
}
|
||||
|
||||
public List<JobErrorRecipient> CreateJobErrorRecipients(JobDetails jobDetails)
|
||||
{
|
||||
var jobErrorRecipients = new List<JobErrorRecipient>();
|
||||
|
||||
foreach (var recipient in jobDetails.ErrorRecipients)
|
||||
{
|
||||
if (string.IsNullOrEmpty(recipient))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var newJobErrorRecipient = new JobErrorRecipient()
|
||||
{
|
||||
JobId = jobDetails.JobId,
|
||||
Recipient = recipient
|
||||
};
|
||||
jobErrorRecipients.Add(newJobErrorRecipient);
|
||||
}
|
||||
|
||||
return jobErrorRecipients;
|
||||
}
|
||||
|
||||
public async Task<bool> SendDispatcherRequest(ReturnResponse returnResponse = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (JobRequest == null)
|
||||
{
|
||||
Log.Error("Cannot send null Job.");
|
||||
return false;
|
||||
}
|
||||
|
||||
JobRequest.ReturnResponse = returnResponse;
|
||||
var serializedJobRequest = JsonConvert.SerializeObject(JobRequest);
|
||||
|
||||
var result = await _postRequest.AsyncWithNewtonSerializedNoThrow(new Uri(_requestBuilderConfiguration.Url), serializedJobRequest);
|
||||
|
||||
if (result.IsSuccessStatusCode)
|
||||
{
|
||||
ClearJob();
|
||||
}
|
||||
|
||||
return result.IsSuccessStatusCode;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure to send job request");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Type GetDispatcherTypeByString(string type)
|
||||
{
|
||||
var actionBuilder = _actionBuilderService.BuildAction(type);
|
||||
return actionBuilder.GetActionType();
|
||||
}
|
||||
|
||||
public void AddWorkItem(object request, WorkItemDetails workItemDetails, ActionType actionType)
|
||||
{
|
||||
var actionBuilder = _actionBuilderService.BuildAction(actionType);
|
||||
AddWorkItemToJob(request, workItemDetails, actionBuilder);
|
||||
}
|
||||
|
||||
public void AddWorkItem(object request, WorkItemDetails workItemDetails, string actionType)
|
||||
{
|
||||
var actionBuilder = _actionBuilderService.BuildAction(actionType);
|
||||
AddWorkItemToJob(request, workItemDetails, actionBuilder);
|
||||
}
|
||||
|
||||
private void AddWorkItemToJob(object request, WorkItemDetails workItemDetails, IActionService actionBuilder)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newWorkitem = actionBuilder.CreateNewWorkitem(request, workItemDetails);
|
||||
if (JobRequest == null)
|
||||
{
|
||||
Log.Error("Cannot add workitem to null Job.");
|
||||
throw new InvalidOperationException("Cannot add workitem to null Job.");
|
||||
}
|
||||
|
||||
JobRequest.WorkItems.Add(newWorkitem);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Error creating WorkItem.");
|
||||
ClearJob();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user