fix: update endpoints
This commit is contained in:
@@ -6,11 +6,12 @@ from src.application.domain.exceptions import ApplicationException
|
||||
|
||||
|
||||
FIELD_ALIASES = {
|
||||
'first_name': {'first_name','name','given_name','имя'},
|
||||
'last_name': {'last_name','surname','family_name','фамилия'},
|
||||
'middle_name': {'middle_name','patronymic','отчество'},
|
||||
'birth_date': {'birth_date','birthdate','date_birth','birthday','дата рождения'},
|
||||
'inn': {'inn','tax_id','инн'},
|
||||
'full_name': {'full_name','fullname','fio','фио'},
|
||||
'first_name': {'first_name','firstname','name','given_name','givenname','имя'},
|
||||
'last_name': {'last_name','lastname','surname','family_name','familyname','фамилия'},
|
||||
'middle_name': {'middle_name','middlename','patronymic','отчество'},
|
||||
'birth_date': {'birth_date','birthdate','date_birth','datebirth','birthday','дата_рождения'},
|
||||
'inn': {'inn','tax_id','taxid','инн'},
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +23,14 @@ def extract_personal_data(data: Any) -> KycPersonalData:
|
||||
if field not in values and normalized in aliases and value not in (None,''):
|
||||
values[field] = str(value).strip()
|
||||
|
||||
if values.get('full_name') and (not values.get('first_name') or not values.get('last_name')):
|
||||
parts = values['full_name'].split()
|
||||
if len(parts) >= 2:
|
||||
values.setdefault('last_name',parts[0])
|
||||
values.setdefault('first_name',parts[1])
|
||||
if len(parts) >= 3:
|
||||
values.setdefault('middle_name',' '.join(parts[2:]))
|
||||
|
||||
missing = [field for field in ('first_name','last_name','birth_date') if not values.get(field)]
|
||||
if missing:
|
||||
raise ApplicationException(status_code=422,message='KYC personal data is incomplete')
|
||||
|
||||
Reference in New Issue
Block a user