fromOtherNames static method
Implementation
static PdfSignatureIcpBrasilIds? fromOtherNames(
List<PdfSignatureOtherName> otherNames,
) {
if (otherNames.isEmpty) return null;
String? cpf;
String? cnpj;
String? nis;
String? responsavelCpf;
String? responsavelNome;
String? tituloEleitor;
String? cei;
DateTime? dateOfBirth;
final raw = <String, String>{};
for (final entry in otherNames) {
final oid = entry.oid;
final value = entry.value;
raw[oid] = value;
final digits = _onlyDigits(value);
switch (oid) {
case '2.16.76.1.3.1': // CPF
final parsed = _parseDobCpfFromIcpOtherName(value);
if (parsed != null) {
dateOfBirth ??= parsed.dob;
cpf ??= parsed.cpf;
} else {
cpf ??= _extractCpfFromDigits(digits);
}
break;
case '2.16.76.1.3.2': // Nome do responsável (PJ)
if (value.trim().isNotEmpty) {
responsavelNome ??= value.trim();
}
break;
case '2.16.76.1.3.3': // CNPJ
cnpj ??= _extractCnpjFromDigits(digits);
break;
case '2.16.76.1.3.4': // CPF responsável
final parsedResp = _parseDobCpfFromIcpOtherName(value);
if (parsedResp != null) {
responsavelCpf ??= parsedResp.cpf;
dateOfBirth ??= parsedResp.dob;
} else {
responsavelCpf ??= _extractCpfFromDigits(digits, allowLast11: true);
}
break;
case '2.16.76.1.3.5': // Título de eleitor
tituloEleitor ??= digits.isEmpty ? null : digits;
break;
case '2.16.76.1.3.6': // CEI
cei ??= digits.isEmpty ? null : digits;
break;
case '2.16.76.1.3.7': // NIS/PIS/PASEP (em alguns layouts)
case '2.16.76.1.3.8':
nis ??= _extractNisFromDigits(digits);
break;
}
}
if (cpf == null &&
cnpj == null &&
nis == null &&
responsavelCpf == null &&
responsavelNome == null &&
tituloEleitor == null &&
cei == null &&
dateOfBirth == null) {
return null;
}
return PdfSignatureIcpBrasilIds(
cpf: cpf,
cnpj: cnpj,
nis: nis,
responsavelCpf: responsavelCpf,
responsavelNome: responsavelNome,
tituloEleitor: tituloEleitor,
cei: cei,
dateOfBirth: dateOfBirth,
raw: raw.isEmpty ? null : raw,
);
}