All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 29s
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
from rest_framework import serializers
|
|
from .models import VendorConfig, VerificationTransaction, VendorAttemptLog
|
|
|
|
|
|
class VerifyDocumentRequestSerializer(serializers.Serializer):
|
|
"""Input payload serializer for document verification API."""
|
|
document_type = serializers.CharField(
|
|
required=True,
|
|
help_text="Type of document, e.g. 'pan', 'aadhaar', 'driving_license', 'voter_id', 'bank_account', 'gstin'",
|
|
)
|
|
data = serializers.DictField(
|
|
required=True,
|
|
help_text="Document verification attributes (e.g. pan_number, name, dob, etc.)",
|
|
)
|
|
preferred_vendor = serializers.CharField(
|
|
required=False,
|
|
allow_null=True,
|
|
allow_blank=True,
|
|
help_text="Optional vendor to prioritize at head of fallback waterfall (e.g. 'codeplus')",
|
|
)
|
|
|
|
|
|
class VendorAttemptLogSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = VendorAttemptLog
|
|
fields = [
|
|
"attempt_number",
|
|
"vendor_name",
|
|
"status",
|
|
"is_success",
|
|
"error_code",
|
|
"error_message",
|
|
"latency_ms",
|
|
"created_at",
|
|
]
|
|
|
|
|
|
class VerificationTransactionSerializer(serializers.ModelSerializer):
|
|
attempts = VendorAttemptLogSerializer(many=True, read_only=True)
|
|
|
|
class Meta:
|
|
model = VerificationTransaction
|
|
fields = [
|
|
"reference_id",
|
|
"document_type",
|
|
"status",
|
|
"successful_vendor",
|
|
"final_data",
|
|
"response_payload",
|
|
"attempts_count",
|
|
"total_latency_ms",
|
|
"created_at",
|
|
"attempts",
|
|
]
|
|
|
|
|
|
class VendorConfigSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = VendorConfig
|
|
fields = [
|
|
"name",
|
|
"display_name",
|
|
"priority",
|
|
"is_active",
|
|
"supported_documents",
|
|
"base_url",
|
|
"updated_at",
|
|
]
|