-
- All Implemented Interfaces:
public final class ConsentRepository
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classConsentRepository.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Set<String>requiredEssentialPurposesIdsprivate final GoogleRepositorygoogleRepositoryprivate final StringconsentStringprivate final StringgoogleAdditionalConsentprivate final IntegertcfVersionprivate final ConsentTokenconsentToken
-
Constructor Summary
Constructors Constructor Description ConsentRepository(SharedPreferences sharedPreferences, VendorRepository vendorRepository, ConfigurationRepository configurationRepository, IABStorageRepository iabStorageRepository, LanguagesHelper languagesHelper, CountryHelper countryHelper)
-
Method Summary
Modifier and Type Method Description final Set<String>getRequiredEssentialPurposesIds()final GoogleRepositorygetGoogleRepository()final StringgetConsentString()final StringgetGoogleAdditionalConsent()final IntegergetTcfVersion()final ConsentTokengetConsentToken()final UnitresetConsentToken()Create a new consent token and store it final ConsentTokenloadConsentToken(Integer tcfVersion, Date ignoreConsentBefore, Long consentDurationInSeconds, Long deniedConsentDurationInSeconds)Load the consent token from the shared preferences final UnitsaveConsentToken()Save the consent token to the local storage. final UnitsetLastSync(Date lastSyncDate, String lastSyncedUserId)Set the last sync date and user id final ConsentStatusgetUserConsentStatusForVendor(String vendorId)Check if the current user has given consent for a specific vendor (independently from purposes) final ConsentStatusgetUserLegitimateInterestStatusForVendor(String vendorId)Check if the user has given legitimate interest for a specific vendor. final ConsentStatusgetUserConsentStatusForPurpose(String purposeId)Check if the user has given consent for a specific purpose or if the ID passed belongs to an essential purpose. final ConsentStatusgetUserLegitimateInterestStatusForPurpose(String purposeId)Check if the user has given legitimate interest for a specific purpose or if the ID passed belongs to an essential purpose. final BooleanisEssentialPurpose(String purposeID)Method used to detect if a purpose ID corresponds to an essential purpose. final ConsentStatusgetUserConsentStatusForVendorAndRequiredPurposes(String vendorId)Check if a vendor has consent for all the purposes that it requires final ConsentStatusgetUserLegitimateInterestStatusForVendorAndRequiredPurposes(String vendorId)Check if a vendor has consent for all the legitimate interest purposes that it requires final Set<Purpose>removeEssentialPurposes(Collection<Purpose> purposeSet)Remove essential purposes from a set of purposes. final BooleanhasAllConsentStatus(Set<Purpose> purposes, Set<Vendor> vendors)Check if all consent information is available (ie not consent status ! final BooleanhasAllLegitimateInterestStatus(Set<Purpose> purposes, Set<Vendor> vendors)Check if all consent information is available (ie not consent status ! final BooleanhasAnyConsentStatus()Check if we have collected any consent status from the user final BooleannumberOfDaysHasExceeded()Determine if the number of days given by the client on the configuration before we could display the banner again if we need new consents has been exceeded: final Set<Purpose>getEnabledPurposes()Method used to get a set of enabled purposes. final Set<String>getEnabledPurposeIds()Method used to get a set of enabled purpose IDs. final BooleansetUserStatusFromObjects(Set<Purpose> enabledConsentPurposes, Set<Purpose> disabledConsentPurposes, Set<Purpose> enabledLIPurposes, Set<Purpose> disabledLIPurposes, Set<Vendor> enabledConsentVendors, Set<Vendor> disabledConsentVendors, Set<Vendor> enabledLIVendors, Set<Vendor> disabledLIVendors, Boolean sendAPIEvent, String eventAction, ApiEventsRepository apiEventsRepository, EventsRepository eventsRepository)Set the user status with Purpose/Vendor objectsThis function is also responsible for triggering the app and API events so all consent changes have to go through it. final UnitfireConsentChangedEvents(Set<String> previouslyEnabledPurposeIds, Set<String> previouslyDisabledPurposeIds, Set<String> previouslyEnabledLegitimatePurposeIds, Set<String> previouslyDisabledLegitimatePurposeIds, Set<String> previouslyEnabledVendorIds, Set<String> previouslyDisabledVendorIds, Set<String> previouslyEnabledLegIntVendorIds, Set<String> previouslyDisabledLegIntVendorIds, Boolean sendAPIEvent, String eventAction, EventsRepository eventsRepository, ApiEventsRepository apiEventsRepository)Fire SDK event and API event corresponding to a change of consent, with the updated token values final BooleansetUserStatus(UserStatusParameters parameters, ApiEventsRepository apiEventsRepository, EventsRepository eventsRepository)Set the user status final BooleansetUserStatus(Boolean purposesConsentStatus, Boolean purposesLIStatus, Boolean vendorsConsentStatus, Boolean vendorsLIStatus, String eventAction, ApiEventsRepository apiEventsRepository, EventsRepository eventsRepository)Set the user status globally final UnitsaveLIInTCFStatusIfRequired()Enable all LI purposes and vendors respecting what has already been disabled (if applies). final BooleanisUserConsentStatusPartial()Determine if consent information is available for all purposes and vendors that are required final BooleanisUserLegitimateInterestStatusPartial()Determine if legitimate interest information is available for all purposes and vendors that are required final BooleanisUserStatusPartial()Check if consent or legitimate interest status is partial final BooleanshouldConsentBeCollected()Check if the consent should be collected depending on if we have any consents or if we have some consents but the number of days before displaying the notice again has not expired yet -
-
Constructor Detail
-
ConsentRepository
ConsentRepository(SharedPreferences sharedPreferences, VendorRepository vendorRepository, ConfigurationRepository configurationRepository, IABStorageRepository iabStorageRepository, LanguagesHelper languagesHelper, CountryHelper countryHelper)
-
-
Method Detail
-
getRequiredEssentialPurposesIds
final Set<String> getRequiredEssentialPurposesIds()
-
getGoogleRepository
final GoogleRepository getGoogleRepository()
-
getConsentString
final String getConsentString()
-
getGoogleAdditionalConsent
final String getGoogleAdditionalConsent()
-
getTcfVersion
final Integer getTcfVersion()
-
getConsentToken
final ConsentToken getConsentToken()
-
resetConsentToken
final Unit resetConsentToken()
Create a new consent token and store it
-
loadConsentToken
final ConsentToken loadConsentToken(Integer tcfVersion, Date ignoreConsentBefore, Long consentDurationInSeconds, Long deniedConsentDurationInSeconds)
Load the consent token from the shared preferences
- Parameters:
tcfVersion- Version of the TCF to loadignoreConsentBefore- If token was updated before this date, it will not be loadedconsentDurationInSeconds- If token update date is older than this duration, it will not be loaded
-
saveConsentToken
final Unit saveConsentToken()
Save the consent token to the local storage.
-
setLastSync
final Unit setLastSync(Date lastSyncDate, String lastSyncedUserId)
Set the last sync date and user id
-
getUserConsentStatusForVendor
final ConsentStatus getUserConsentStatusForVendor(String vendorId)
Check if the current user has given consent for a specific vendor (independently from purposes)
-
getUserLegitimateInterestStatusForVendor
final ConsentStatus getUserLegitimateInterestStatusForVendor(String vendorId)
Check if the user has given legitimate interest for a specific vendor.
-
getUserConsentStatusForPurpose
final ConsentStatus getUserConsentStatusForPurpose(String purposeId)
Check if the user has given consent for a specific purpose or if the ID passed belongs to an essential purpose.
-
getUserLegitimateInterestStatusForPurpose
final ConsentStatus getUserLegitimateInterestStatusForPurpose(String purposeId)
Check if the user has given legitimate interest for a specific purpose or if the ID passed belongs to an essential purpose.
-
isEssentialPurpose
final Boolean isEssentialPurpose(String purposeID)
Method used to detect if a purpose ID corresponds to an essential purpose.
- Parameters:
purposeID- : purpose ID.
-
getUserConsentStatusForVendorAndRequiredPurposes
final ConsentStatus getUserConsentStatusForVendorAndRequiredPurposes(String vendorId)
Check if a vendor has consent for all the purposes that it requires
-
getUserLegitimateInterestStatusForVendorAndRequiredPurposes
final ConsentStatus getUserLegitimateInterestStatusForVendorAndRequiredPurposes(String vendorId)
Check if a vendor has consent for all the legitimate interest purposes that it requires
-
removeEssentialPurposes
final Set<Purpose> removeEssentialPurposes(Collection<Purpose> purposeSet)
Remove essential purposes from a set of purposes.
- Parameters:
purposeSet- set of purposes.
-
hasAllConsentStatus
final Boolean hasAllConsentStatus(Set<Purpose> purposes, Set<Vendor> vendors)
Check if all consent information is available (ie not consent status != unknown) for a set of purpose and vendor IDs
-
hasAllLegitimateInterestStatus
final Boolean hasAllLegitimateInterestStatus(Set<Purpose> purposes, Set<Vendor> vendors)
Check if all consent information is available (ie not consent status != unknown) for a set of purpose and vendor IDs
-
hasAnyConsentStatus
final Boolean hasAnyConsentStatus()
Check if we have collected any consent status from the user
-
numberOfDaysHasExceeded
final Boolean numberOfDaysHasExceeded()
Determine if the number of days given by the client on the configuration before we could display the banner again if we need new consents has been exceeded:
-
getEnabledPurposes
final Set<Purpose> getEnabledPurposes()
Method used to get a set of enabled purposes. The purposes that we consider as enabled from this point on, are those that have been enabled by the user (that are stored in the form of the consent token) and those that are essential purposes.
-
getEnabledPurposeIds
final Set<String> getEnabledPurposeIds()
Method used to get a set of enabled purpose IDs. The purposes that we consider as enabled from this point on, are those that have been enabled by the user (that are stored in the form of the consent token) and those that are essential purposes.
-
setUserStatusFromObjects
@Synchronized() final Boolean setUserStatusFromObjects(Set<Purpose> enabledConsentPurposes, Set<Purpose> disabledConsentPurposes, Set<Purpose> enabledLIPurposes, Set<Purpose> disabledLIPurposes, Set<Vendor> enabledConsentVendors, Set<Vendor> disabledConsentVendors, Set<Vendor> enabledLIVendors, Set<Vendor> disabledLIVendors, Boolean sendAPIEvent, String eventAction, ApiEventsRepository apiEventsRepository, EventsRepository eventsRepository)
Set the user status with Purpose/Vendor objects
This function is also responsible for triggering the app and API events so all consent changes have to go through it.
- Parameters:
enabledConsentPurposes- Consent purposes to enabledisabledConsentPurposes- Consent purposes to disableenabledLIPurposes- Legitimate interest purposes to enabledisabledLIPurposes- Legitimate interest purposes to disableenabledConsentVendors- Consent vendors to enabledisabledConsentVendors- Consent vendors to disableenabledLIVendors- Legitimate interest vendors to enabledisabledLIVendors- Legitimate interest vendors do disablesendAPIEvent- Whether to send an event to the API to report a user choiceeventAction- Action associated to the API event (should be "click" or "external")apiEventsRepository- The API events repositoryeventsRepository- The events repository
-
fireConsentChangedEvents
final Unit fireConsentChangedEvents(Set<String> previouslyEnabledPurposeIds, Set<String> previouslyDisabledPurposeIds, Set<String> previouslyEnabledLegitimatePurposeIds, Set<String> previouslyDisabledLegitimatePurposeIds, Set<String> previouslyEnabledVendorIds, Set<String> previouslyDisabledVendorIds, Set<String> previouslyEnabledLegIntVendorIds, Set<String> previouslyDisabledLegIntVendorIds, Boolean sendAPIEvent, String eventAction, EventsRepository eventsRepository, ApiEventsRepository apiEventsRepository)
Fire SDK event and API event corresponding to a change of consent, with the updated token values
- Parameters:
previouslyEnabledPurposeIds- Previously enabled consent purpose idspreviouslyDisabledPurposeIds- Previously disabled consent purpose idspreviouslyEnabledLegitimatePurposeIds- Previously enabled LI purpose idspreviouslyDisabledLegitimatePurposeIds- Previously disabled LI purpose idspreviouslyEnabledVendorIds- Previously enabled consent vendor idspreviouslyDisabledVendorIds- Previously disabled consent vendor idspreviouslyEnabledLegIntVendorIds- Previously enabled LI vendor idspreviouslyDisabledLegIntVendorIds- Previously disabled LI vendor idssendAPIEvent- Whether to send an event to the API to report a user choiceeventAction- Action associated to the API event (should be "click" or "external")eventsRepository- The events repositoryapiEventsRepository- The API events repository
-
setUserStatus
final Boolean setUserStatus(UserStatusParameters parameters, ApiEventsRepository apiEventsRepository, EventsRepository eventsRepository)
Set the user status
- Parameters:
parameters- Parameters describing consent status to set
-
setUserStatus
final Boolean setUserStatus(Boolean purposesConsentStatus, Boolean purposesLIStatus, Boolean vendorsConsentStatus, Boolean vendorsLIStatus, String eventAction, ApiEventsRepository apiEventsRepository, EventsRepository eventsRepository)
Set the user status globally
- Parameters:
purposesConsentStatus- true if purposes on a consent basis should be enabled, false if they should be disabledpurposesLIStatus- true if purposes on a legitimate interest basis should be enabled, false if they should be disabledvendorsConsentStatus- true if vendors on a consent basis should be enabled, false if they should be disabledvendorsLIStatus- true if vendors on a legitimate interest basis should be enabled, false if they should be disabledeventAction- Action associated to the API event (should be "click" or "external")
-
saveLIInTCFStatusIfRequired
final Unit saveLIInTCFStatusIfRequired()
Enable all LI purposes and vendors respecting what has already been disabled (if applies).
-
isUserConsentStatusPartial
final Boolean isUserConsentStatusPartial()
Determine if consent information is available for all purposes and vendors that are required
-
isUserLegitimateInterestStatusPartial
final Boolean isUserLegitimateInterestStatusPartial()
Determine if legitimate interest information is available for all purposes and vendors that are required
-
isUserStatusPartial
final Boolean isUserStatusPartial()
Check if consent or legitimate interest status is partial
-
shouldConsentBeCollected
final Boolean shouldConsentBeCollected()
Check if the consent should be collected depending on if we have any consents or if we have some consents but the number of days before displaying the notice again has not expired yet
-
-
-
-