Class ConsentRepository
-
- All Implemented Interfaces:
public final class ConsentRepository
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringIAB_TIMESTAMP_GRANULARITYprivate 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, DCSRepository dcsRepository, 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 UnitaddTokenChangeCallback(Function0<Unit> callback)Add Shared preferences listener for the consent token 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 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 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<InternalPurpose>removeEssentialPurposes(Collection<InternalPurpose> purposeSet)Remove essential purposes from a set of purposes. final BooleanhasAllConsentStatus(Set<InternalPurpose> purposes, Set<InternalVendor> 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 BooleansetUserStatusFromObjects(Set<InternalPurpose> enabledConsentPurposes, Set<InternalPurpose> disabledConsentPurposes, Set<InternalPurpose> enabledLIPurposes, Set<InternalPurpose> disabledLIPurposes, Set<InternalVendor> enabledConsentVendors, Set<InternalVendor> disabledConsentVendors, Set<InternalVendor> enabledLIVendors, Set<InternalVendor> 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 user status is partial final BooleanshouldUserStatusBeCollected()Determine if the User Status (consent) should be collected or not. -
-
Constructor Detail
-
ConsentRepository
ConsentRepository(SharedPreferences sharedPreferences, VendorRepository vendorRepository, ConfigurationRepository configurationRepository, DCSRepository dcsRepository, 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()
-
addTokenChangeCallback
final Unit addTokenChangeCallback(Function0<Unit> callback)
Add Shared preferences listener for the consent token
- Parameters:
callback- as ()-> Unit
-
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
-
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.
-
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<InternalPurpose> removeEssentialPurposes(Collection<InternalPurpose> purposeSet)
Remove essential purposes from a set of purposes.
- Parameters:
purposeSet- set of purposes.
-
hasAllConsentStatus
final Boolean hasAllConsentStatus(Set<InternalPurpose> purposes, Set<InternalVendor> 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:
-
setUserStatusFromObjects
@Synchronized() final Boolean setUserStatusFromObjects(Set<InternalPurpose> enabledConsentPurposes, Set<InternalPurpose> disabledConsentPurposes, Set<InternalPurpose> enabledLIPurposes, Set<InternalPurpose> disabledLIPurposes, Set<InternalVendor> enabledConsentVendors, Set<InternalVendor> disabledConsentVendors, Set<InternalVendor> enabledLIVendors, Set<InternalVendor> 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 user status is partial
-
shouldUserStatusBeCollected
final Boolean shouldUserStatusBeCollected()
Determine if the User Status (consent) should be collected or not. User Status should be collected if:
Regulation is different from NONE and
User status is partial and
The number of days before displaying the notice again has exceeded the limit specified on the Console or no User Status has been saved
-
-
-
-