class AisConsentMapper {

    public AisConsent mapToAisConsent(ConsentEntity entity, List<AuthorisationEntity> authorisations) {
        AisConsentData aisConsentData = consentDataMapper.mapToAisConsentData(entity.getData());

        Map<String, Integer> usageCounterMap = aisConsentUsageService.getUsageCounterMap(entity);

        return new AisConsent(aisConsentData,
                              entity.getExternalId(),
                              entity.getInternalRequestId(),
                              entity.getConsentStatus(),
                              entity.getFrequencyPerDay(),
                              entity.isRecurringIndicator(),
                              entity.isMultilevelScaRequired(),
                              entity.getValidUntil(),
                              entity.getExpireDate(),
                              entity.getLastActionDate(),
                              entity.getCreationTimestamp(),
                              entity.getStatusChangeTimestamp(),
                              consentTppInformationMapper.mapToConsentTppInformation(entity.getTppInformation()),
                              authorisationTemplateMapper.mapToAuthorisationTemplate(entity.getAuthorisationTemplate()),
                              psuDataMapper.mapToPsuIdDataList(entity.getPsuDataList()),
                              mapToAccountConsentAuthorisations(authorisations),
                              usageCounterMap,
                              accessMapper.mapTppAccessesToAccountAccess(entity.getTppAccountAccesses(),
                                                                         entity.getOwnerNameType(),
                                                                         entity.getTrustedBeneficiariesType()),
                              accessMapper.mapAspspAccessesToAccountAccess(entity.getAspspAccountAccesses(),
                                                                           entity.getOwnerNameType(),
                                                                           entity.getTrustedBeneficiariesType()),
                              entity.getInstanceId(), entity.isSigningBasketBlocked());
    }

}