using LCU.API.Internal.Operations.IncentiveApi.Configuration; using LCU.API.Internal.Operations.IncentiveApi.DataAccess; using LCU.Library.Internal.IncentiveApiModels.Entities; using NewAtmCheckCardActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewAtmCheckCardActivity; using NewCheckingAccountActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewCheckingAccountActivity; using NewLoanSaleActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewLoanSaleActivity; using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction; using System.Web; using LCU.Library.Internal.Exceptions; namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices; public class CoreApiWrapperService : ICoreApiWrapperService { private readonly ICoreApiWrapperDao _coreApiWrapperDao; private readonly CoreApiWrapperConfiguration _coreApiWrapperConfiguration; public CoreApiWrapperService(CoreApiWrapperConfiguration coreApiWrapperConfiguration, ICoreApiWrapperDao coreApiWrapperDao) { _coreApiWrapperDao = coreApiWrapperDao; _coreApiWrapperConfiguration = coreApiWrapperConfiguration; } public async Task> GetNewCheckingAccountSalesActivity(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewCheckingAccountSalesActivity(activityDt); } catch (Exception ex) { var error = $"Failed to get New Checking Account Sales from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetNewCheckingDigitalBankingAccountSalesActivity(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewCheckingDigitalBankingAccountSalesActivity(activityDt); } catch (Exception ex) { var error = $"Failed to get New Digital Banking Checking Account Sales from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetNewAtmCheckCardSalesActivity(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewAtmCheckCardSalesActivity(activityDt); } catch (Exception ex) { var error = $"Failed to get New ATM and Check Card Sales from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetNewActivityManagerReferralsActivity(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewActivityManagerReferralsActivity(activityDt); } catch (Exception ex) { var error = $"Failed to get New Activity Manager Referrals from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetNewMortgageSaleActivities(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewMortgageSaleActivities(activityDt); } catch (Exception ex) { var error = $"Failed to get New Mortgage Sales from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetNewVehicleSaleActivities(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewVehicleSaleActivities(activityDt); } catch (Exception ex) { var error = $"Failed to get New Vehicle Sales from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetNewDpEligibleSaleActivities(DateTime activityDt) { try { return await _coreApiWrapperDao.GetNewDpEligibleSaleActivities(activityDt); } catch (Exception ex) { var error = $"Failed to get New DP Eligible Sales and Actvities from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetUpdatedAccountInformation(List accountNumbers) { try { return await _coreApiWrapperDao.GetUpdatedAccountInformation(accountNumbers); } catch (Exception ex) { var error = $"Failed to get Updated Account Information from DNA after: {string.Join(",", accountNumbers)}" + $"Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetActivityManagerActivities(ActivityQueryRequest request) { try { return await _coreApiWrapperDao.GetActivityManagerActivities(request); } catch (Exception ex) { var error = $"Failed to get Activity Manager Activities from DNA after: {request.ActivityIds} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public async Task> GetTransactionHistory(string accountNumber, DateTime startDate, DateTime endDate, List transactionCodes) { try { return await _coreApiWrapperDao.GetTransactionHistory(accountNumber, startDate, endDate, transactionCodes); } catch (Exception ex) { var error = $"Failed to get Transaction History for Account Number: {accountNumber} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } public string DateTimeToUrlString(DateTime dateTime) { var dtstring = dateTime.ToString("yyyy-MM-ddTHH:mm:ss"); return HttpUtility.UrlEncode(dtstring); } public async Task> GetEStatmentDeliveryMethods(DateTime activityDt) { try { return await _coreApiWrapperDao.GetEStatmentDeliveryMethods(activityDt); } catch (Exception ex) { var error = $"Failed to get EStatement Delivery Methods from DNA after: {activityDt} Exception Message: {ex.Message}"; Log.Error(error); throw new ServiceException(error); } } }