65 lines
2.0 KiB
Python
65 lines
2.0 KiB
Python
"""
|
|
Controller for lien check endpoints.
|
|
"""
|
|
from flask import Blueprint, request, jsonify
|
|
from app.middleware import api_key_required
|
|
from app.models import LienCheckRequest, LienCheckResponse
|
|
import logging
|
|
|
|
# Configure logger
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Create blueprint
|
|
lien_bp = Blueprint('lien', __name__)
|
|
|
|
@lien_bp.route('/LienCheck', methods=['POST'])
|
|
@api_key_required
|
|
def lien_check():
|
|
"""
|
|
Endpoint to check lien amount on an account.
|
|
|
|
This method is used to get the applied lien amount for a specific account.
|
|
|
|
Returns:
|
|
JSON response with lien amount details
|
|
"""
|
|
try:
|
|
# Parse and validate request
|
|
data = request.get_json()
|
|
if not data:
|
|
return jsonify({
|
|
'resultCode': '400',
|
|
'resultDescription': 'Invalid JSON payload'
|
|
}), 400
|
|
|
|
# Validate required fields
|
|
required_fields = ['transactionId', 'customerId', 'accountId', 'countryId']
|
|
for field in required_fields:
|
|
if field not in data:
|
|
return jsonify({
|
|
'resultCode': '422',
|
|
'resultDescription': f'Missing required field: {field}'
|
|
}), 422
|
|
|
|
# Create request model
|
|
req = LienCheckRequest.from_dict(data)
|
|
|
|
# Process lien check (this would connect to the business logic)
|
|
# For demonstration, we'll return a mock response
|
|
|
|
# Create response
|
|
response = LienCheckResponse(
|
|
lienAmount=20000.0,
|
|
resultCode="00",
|
|
resultDescription="Successful"
|
|
)
|
|
|
|
logger.info(f"Processed lien check for customer {req.customerId}, account {req.accountId}")
|
|
return jsonify(response.to_dict())
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error processing lien check: {str(e)}")
|
|
return jsonify({
|
|
'resultCode': '500',
|
|
'resultDescription': 'Internal server error'
|
|
}), 500 |