[update]: RACChecks
This commit was merged in pull request #10.
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import requests
|
import httpx
|
||||||
import json
|
import json
|
||||||
from requests.auth import HTTPBasicAuth
|
|
||||||
from app.utils.logger import logger
|
from app.utils.logger import logger
|
||||||
from app.config import settings
|
from app.config import settings
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class SimbrellaIntegration:
|
class SimbrellaIntegration:
|
||||||
BASE_URL = settings.SIMBRELLA_BASE_URL
|
BASE_URL = settings.SIMBRELLA_BASE_URL
|
||||||
@@ -13,42 +14,41 @@ class SimbrellaIntegration:
|
|||||||
Calls the RACCheck endpoit
|
Calls the RACCheck endpoit
|
||||||
"""
|
"""
|
||||||
url = f"{SimbrellaIntegration.BASE_URL}/RACCheck"
|
url = f"{SimbrellaIntegration.BASE_URL}/RACCheck"
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"customerId": customer_id,
|
"customerId": customer_id,
|
||||||
"accountId": account_id,
|
"accountId": account_id,
|
||||||
"transactionId": transaction_id,
|
"transactionId": str(transaction_id),
|
||||||
|
"fbnTransactionId": f"FBN{transaction_id}",
|
||||||
"RAC_Array": [
|
"RAC_Array": [
|
||||||
{
|
"SalaryAccount",
|
||||||
"salaryAccount": True,
|
"BVN",
|
||||||
"bvn": "12345678901",
|
"BVNAttachedtoAccount",
|
||||||
"crc": False,
|
"CRC",
|
||||||
"crms": True,
|
"CRMS",
|
||||||
"accountStatus": "active",
|
"AccountStatus",
|
||||||
"lien": False,
|
"Lien",
|
||||||
"noBouncedCheck": True,
|
"NoBouncedCheck",
|
||||||
"existingLoan": False,
|
"Whitelist",
|
||||||
"whitelist": True,
|
"NoPastDueSalaryLoan",
|
||||||
"noPastDueSalaryLoan": True,
|
"NoPastDueOtherLoan",
|
||||||
"noPastDueOtherLoans": False
|
],
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.error(f"This is PayLoad: {str(payload)}",exc_info=True)
|
logger.error(f"This is PayLoad: {str(payload)}", exc_info=True)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
'x-api-key': f'{settings.VALID_API_KEY}',
|
"x-api-key": f"{settings.VALID_API_KEY}",
|
||||||
'App-Id': f'{settings.VALID_APP_ID}'
|
"App-Id": f"{settings.VALID_APP_ID}",
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(url, json=payload, timeout=10, headers=headers)
|
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
|
||||||
|
|
||||||
logger.error(f"This is Response: {str(response)}", exc_info=True)
|
logger.error(f"This is Response: {str(response)}", exc_info=True)
|
||||||
|
|
||||||
return response.json()
|
return response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"RACCheck API call failed: {str(e)}", exc_info=True)
|
logger.error(f"RACCheck API call failed: {str(e)}", exc_info=True)
|
||||||
raise Exception(f"RACCheck API call failed: {str(e)}")
|
raise Exception(f"RACCheck API call failed: {str(e)}")
|
||||||
|
|||||||
@@ -48,17 +48,17 @@ class EligibilityCheckService(BaseService):
|
|||||||
"message": "Invalid Customer or Account"
|
"message": "Invalid Customer or Account"
|
||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
|
db.session.flush()
|
||||||
|
|
||||||
# Call RACCheck
|
# Call RACCheck
|
||||||
response = SimbrellaIntegration.rac_check(
|
response = SimbrellaIntegration.rac_check(
|
||||||
customer_id = customer_id,
|
customer_id = customer_id,
|
||||||
account_id = account_id,
|
account_id = account_id,
|
||||||
transaction_id = transaction.id,
|
transaction_id = transaction.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.error(f"This is Response Returned ****** : {str(response)}")
|
|
||||||
|
|
||||||
# this chck for error is not valid
|
# this chck for error is not valid
|
||||||
if response.get("status") != 200:
|
if response.status_code != 200:
|
||||||
return jsonify({"message": "RACCheck failed"}), 400
|
return jsonify({"message": "RACCheck failed"}), 400
|
||||||
|
|
||||||
offers = [offer.to_dict() for offer in Offer.get_all_offers()]
|
offers = [offer.to_dict() for offer in Offer.get_all_offers()]
|
||||||
|
|||||||
+2
-1
@@ -25,7 +25,8 @@ flask-swagger-ui
|
|||||||
python-dotenv
|
python-dotenv
|
||||||
|
|
||||||
# Requests
|
# Requests
|
||||||
requests
|
httpx
|
||||||
|
|
||||||
|
|
||||||
# JWT
|
# JWT
|
||||||
flask-jwt-extended
|
flask-jwt-extended
|
||||||
|
|||||||
Reference in New Issue
Block a user