92 lines
4.3 KiB
Python
92 lines
4.3 KiB
Python
from flask import render_template
|
|
|
|
from services.dbservice import DbService
|
|
from flask import Response, request
|
|
from flask_restful import Resource,reqparse
|
|
from services.utilityservices import sendRestResponse
|
|
from services.CibilBusinessOperationService import CibilBusinessOperationService
|
|
from flask_restful_swagger import swagger
|
|
import json
|
|
|
|
#this one for sample of individual modules/components in flask
|
|
class CIBIL(Resource):
|
|
|
|
@swagger.operation(
|
|
notes='This API is entry point of Credit Bureau Summary of single applicant',
|
|
responseClass='None',
|
|
nickname='CIBIL Single Applicant Credit Bureau Summary API',
|
|
parameters=[
|
|
{
|
|
"name": "reference_number",
|
|
"description": "member reference number or applicant individual id",
|
|
"required": True,
|
|
"allowMultiple": False,
|
|
"dataType": 'int',
|
|
"paramType": "query"
|
|
},
|
|
{
|
|
"name": "los_id",
|
|
"description": "LOSID",
|
|
"required": True,
|
|
"allowMultiple": False,
|
|
"dataType": 'int',
|
|
"paramType": "query"
|
|
}
|
|
],
|
|
responseMessages=[
|
|
{
|
|
"code": 200,
|
|
"message": "Process Started...!"
|
|
},
|
|
{
|
|
"code": 404,
|
|
"message": "Some Err"
|
|
}
|
|
]
|
|
)
|
|
|
|
|
|
def get(self):
|
|
return_data = []
|
|
los_id = request.args.get('los_id') if request.args.get('los_id') is not None else None
|
|
reference_number = request.args.get('reference_number') if request.args.get('reference_number') is not None else None
|
|
cibil_type = request.args.get('cibil_type') if request.args.get('cibil_type') is not None and request.args.get('cibil_type') in ['1','2'] else None # consumer = 1,commercial = 2
|
|
output_type = request.args.get('output_type') if request.args.get('los_id') is not None else None
|
|
# print(output_type,'--',type(output_type))
|
|
# print(request.args.get('cibil_type') == 2)
|
|
# print(cibil_type,request.args.get('cibil_type'))
|
|
action = request.args.get('action') if request.args.get('action') is not None and request.args.get('action') in ['1','2','3'] else None
|
|
# print(request.args.get('action') in [1,2,3])
|
|
# print(action,request.args.get('action'))
|
|
if los_id == None or reference_number == None or cibil_type == None or action == None:
|
|
return sendRestResponse(404,{'msg':'insufficient/invalid params'})
|
|
if int(action) == 1:#active&closedloans
|
|
print('active&closed Loans-')
|
|
return_data = CibilBusinessOperationService.doCIBILActiveCloseLoansSummary(los_id,reference_number,cibil_type)
|
|
return sendRestResponse(200,{'msg':'success','data':return_data})
|
|
|
|
elif int(action) == 2:#sanctioned loans summary
|
|
if output_type in ['1','2']:output_type = int(output_type)
|
|
else:return sendRestResponse(404,{'msg':'insufficient/invalid params'})
|
|
print('sanctioned loans summary')
|
|
return_data = CibilBusinessOperationService.doCIBILSanctionedLoansSummary(los_id,reference_number,cibil_type,output_type)
|
|
return sendRestResponse(200,{'msg':'success','data':return_data})
|
|
|
|
elif int(action) == 3:#enquiry summary
|
|
print('enquiry summary')
|
|
if output_type in ['1','2']:output_type = int(output_type)
|
|
else:return sendRestResponse(404,{'msg':'insufficient/invalid params'})
|
|
return_data = CibilBusinessOperationService.doCIBILEnquirySummary(los_id,reference_number,cibil_type,output_type)
|
|
return sendRestResponse(200,{'msg':'success','data':return_data})
|
|
|
|
else:
|
|
return sendRestResponse(200,{'msg':'success','data':return_data})
|
|
|
|
|
|
# raise Exception('manual stop')
|
|
# print('cool')
|
|
# CibilBusinessOperationServiceObj = CibilBusinessOperationService()
|
|
# data = CibilBusinessOperationService.doConsumerCIBILOperations(member_reference_number)
|
|
# return render_template('about.html', name='ponniy')
|
|
return sendRestResponse(200,return_data)
|
|
# return sendRestResponse(200,{'msg':return_data}) |