Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid code duplication #15

Open
tshemsedinov opened this issue Mar 16, 2024 · 0 comments
Open

Avoid code duplication #15

tshemsedinov opened this issue Mar 16, 2024 · 0 comments

Comments

@tshemsedinov
Copy link

This code do nothing, it just duplicate contracts should be replaced to single line solution + collection to convert pointers:

static getSharingRenderDataByDocumentType(
documentType: DocumentType,
data: unknown,
requester: string,
requestDateTime: string,
requestIdentifier: string,
): GenericData {
switch (documentType) {
case DocumentType.DriverLicense:
return PdfUtils.getDriverLicenseSharingRenderData(<DriverLicense>data, requester, requestDateTime, requestIdentifier)
case DocumentType.VehicleLicense:
return PdfUtils.getVehicleLicenseSharingRenderData(<VehicleLicense>data, requester, requestDateTime, requestIdentifier)
case DocumentType.StudentIdCard:
return PdfUtils.getStudentIdCardSharingRenderData(<StudentCard>data, requester, requestDateTime, requestIdentifier)
case DocumentType.ForeignPassport:
return PdfUtils.getForeignPassportSharingRenderData(<ForeignPassport>data, requester, requestDateTime, requestIdentifier)
case DocumentType.ResidencePermitPermanent:
return PdfUtils.getResidencePermitPermanentSharingRenderData(
<ResidencePermit>data,
requester,
requestDateTime,
requestIdentifier,
)
case DocumentType.TaxpayerCard:
return PdfUtils.getTaxpayerCardSharingRenderData(<TaxpayerCard>data, requester, requestDateTime, requestIdentifier)
case DocumentType.RefInternallyDisplacedPerson:
return this.getRefInternallyDisplacedPersonSharingRenderData(
<RefInternallyDisplacedPerson>data,
requester,
requestDateTime,
requestIdentifier,
)
case DocumentType.BirthCertificate:
return PdfUtils.getBirthCertificateSharingRenderData(<BirthCertificate>data, requester, requestDateTime, requestIdentifier)
case DocumentType.InternalPassport:
return PdfUtils.getInternalPassportSharingRenderData(<InternalPassport>data, requester, requestDateTime, requestIdentifier)
case DocumentType.PensionCard:
return PdfUtils.getPensionCardSharingRenderData(<PensionCard>data, requester, requestDateTime, requestIdentifier)
case DocumentType.EducationDocument:
return PdfUtils.getEducationDocumentSharingRenderData(
<EducationDocument>data,
requester,
requestDateTime,
requestIdentifier,
)
default: {
throw new TypeError(`Unknown scope ${documentType}`)
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant