From 0bdc11423f36442c405794ce3d1ec6cc190edfdb Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 24 May 2025 05:37:21 -0400 Subject: [PATCH] Rack analysis --- app/api/services/eligibility_check.py | 5 ++++- app/api/services/offer_analysis.py | 24 ++++++++++++++++++++++-- app/config.py | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/api/services/eligibility_check.py b/app/api/services/eligibility_check.py index 3458c8f..5678b4f 100644 --- a/app/api/services/eligibility_check.py +++ b/app/api/services/eligibility_check.py @@ -81,6 +81,8 @@ class EligibilityCheckService(BaseService): if not rac_check: logger.error(f"Failed to save RACCheck") return ResponseHelper.error(result_description="Failed to save RACCheck.") + + rack_checks_response = response['racResponse'] # -----------------TIME FOR ANALYSIS TO REGISTER OFFER ---------------------- # eligible_offers = [] try: @@ -88,7 +90,8 @@ class EligibilityCheckService(BaseService): transaction_id=transactionId, rac_check=rac_check, validated_data=validated_data, - customer_id=customer_id + customer_id=customer_id, + rack_checks_response =rack_checks_response ) except ValueError as ve: logger.error(str(ve)) diff --git a/app/api/services/offer_analysis.py b/app/api/services/offer_analysis.py index 01469c1..123cb6b 100644 --- a/app/api/services/offer_analysis.py +++ b/app/api/services/offer_analysis.py @@ -32,12 +32,32 @@ class OfferAnalysis: original_transaction = transaction_id return transaction_offer, offer, eligible_amount, original_transaction + @staticmethod + def _analyze_rack_checks(rack_response): + + # "racResponse": { + # "accountStatus": true, + # "bvnValidated": true, + # "creditBureauCheck": false, + # "crmsCheck": true, + # "hasLien": false, + # "hasPastDueLoan": false, + # "hasSalaryAccount": true, + # "isWhitelisted": true, + # "noBouncedCheck": true + # }, + # + + return 0 @staticmethod - def decide_offer(transaction_id, rac_check, validated_data, customer_id): + def decide_offer(transaction_id, rac_check, validated_data, customer_id, rack_checks_response): eligible_offers = [] # if we have active offers - we have to feed off it - logger.info(f"LOOOOOOOOOOOOOOOOOO** {customer_id}") + logger.info(f"**RACK ANALYSIS** {customer_id}") + # Analyze Rack Checks + self._analyze_rack_checks(rack_checks_response) + # we can now find the origin transactions # Find the last loan - it will have original_transaction diff --git a/app/config.py b/app/config.py index 13f7a9a..6ee6817 100644 --- a/app/config.py +++ b/app/config.py @@ -1,7 +1,6 @@ import os from datetime import timedelta - class Config: """Base configuration for Flask app""" @@ -12,17 +11,18 @@ class Config: BASIC_AUTH_USERNAME = os.environ.get("BASIC_AUTH_USERNAME", "user") BASIC_AUTH_PASSWORD = os.environ.get("BASIC_AUTH_PASSWORD", "password") + # Database Configuration DATABASE_USER = os.environ.get("DATABASE_USER") DATABASE_PASSWORD = os.environ.get("DATABASE_PASSWORD") DATABASE_HOST = os.environ.get("DATABASE_HOST") DATABASE_PORT = os.environ.get("DATABASE_PORT", 10532) DATABASE_NAME = os.environ.get("DATABASE_NAME") + # Database Connection SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DATABASE_USER}:{DATABASE_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_NAME}" SQLALCHEMY_TRACK_MODIFICATIONS = False - JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "secret-key") JWT_ACCESS_TOKEN_EXPIRES = os.getenv("JWT_ACCESS_TOKEN_EXPIRES", timedelta(hours=1)) JWT_REFRESH_TOKEN_EXPIRES = os.getenv( @@ -34,9 +34,19 @@ class Config: # SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS", "RACCheck") VALID_APP_ID = os.getenv("SIMBRELLA_APP_ID", "app1") - VALID_API_KEY = os.getenv("SIMBRELLA_API_KEY", "test-api-key-12345") + VALID_API_KEY = os.getenv("SIMBRELLA_API_KEY", "testtest-api-key-12345") SIMBRELLA_BASE_URL = os.getenv("SIMBRELLA_BASE_URL", "http://127.0.0.1:6337") SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS","api/rac-check") + RAC_RESULT_accountStatus = os.environ.get("RAC_RESULT_accountStatus", true) + RAC_RESULT_bvnValidated = os.environ.get("RAC_RESULT_bvnValidated", true) + RAC_RESULT_creditBureauCheck = os.environ.get("RAC_RESULT_creditBureauCheck", false) + RAC_RESULT_crmsCheck = os.environ.get("RAC_RESULT_crmsCheck", true) + RAC_RESULT_hasLien = os.environ.get("RAC_RESULT_hasLien", false) + RAC_RESULT_hasPastDueLoan = os.environ.get("RAC_RESULT_hasPastDueLoan", false) + RAC_RESULT_hasSalaryAccount = os.environ.get("RAC_RESULT_hasSalaryAccount", true) + RAC_RESULT_isWhitelisted = os.environ.get("RAC_RESULT_isWhitelisted", true) + RAC_RESULT_noBouncedCheck = os.environ.get("RAC_RESULT_noBouncedCheck", true) + settings = Config()