Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Threading.Tasks;
- using CollectorAPI.Business.Logging;
- using CollectorAPI.Business.Models;
- using CollectorAPI.Business.Models.Response;
- using CollectorAPI.DataAccess.TestWorkSpace;
- namespace CollectorAPI.DataAccess
- {
- public class StatisticaDataAccess : DataAccessBase, IDataAccess
- {
- private readonly LiveScoreClient _client;
- public StatisticaDataAccess(ILogger logger) : base(logger)
- {
- // Instantiate LiveScoreSoap client and add requestInspectorBehavior to be able to log SOAP request and response
- _client = new LiveScoreClient();
- // Add base endpointbehaviour to client
- _client.Endpoint.Behaviors.Add(EndpointBehavior);
- }
- public async Task<CreditEvaluationResponse> GetCreditEvaluationAsync(string countryCode, string civicRegNo, string currencySymbol, decimal requestedAmount, decimal productNumber, string channel, decimal repaymentTimeInMonths, decimal currentDebtBalance, decimal applicationsLast24Hours, decimal applicationsLast7Days, decimal applicationsLast30Days, decimal activeApplications, string applicationInformation)
- {
- var workSpace = new LiveTestWorkSpace()
- {
- CountryCode = countryCode,
- CivicRegNo = civicRegNo,
- CurrencySymbol = currencySymbol,
- RequestedAmount = requestedAmount,
- ProductNumber = productNumber,
- Channel = channel,
- RepaymentTimeInMonths = repaymentTimeInMonths,
- CurrentDebtBalance = currentDebtBalance,
- ApplicationsLast24Hours = applicationsLast24Hours,
- ApplicationsLast7Days = applicationsLast7Days,
- ApplicationsLast30Days = applicationsLast30Days,
- ActiveApplications = activeApplications,
- ApplicationInformation = applicationInformation,
- };
- var authentication = GetAuthentication();
- var response = await CreateRequestAsync(_client, async client => await client.LiveTestWorkSpaceAsync(workSpace, authentication));
- return new CreditEvaluationResponse
- {
- ApprovedAmount = response.LiveTestWorkSpaceResponse.ApprovedAmount,
- Decision = CreditEvaluationDecision.Accepted,
- DecisionReason = response.LiveTestWorkSpaceResponse.DecisionReason,
- InterestRate = response.LiveTestWorkSpaceResponse.InterestRate,
- Score = response.LiveTestWorkSpaceResponse.Score,
- ScoreWeightedTotalScore = response.LiveTestWorkSpaceResponse.WeightedTotalScore,
- CreditProvider = response.LiveTestWorkSpaceResponse.CreditProvider,
- CreditReportId = response.LiveTestWorkSpaceResponse.CreditReportId,
- };
- }
- private Authentication GetAuthentication()
- {
- //TODO: move to configuration
- return new Authentication() { Username = "test_user", Password = "Smartboard1234" };
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement