Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.usercentrics.sdk.v2.settings.data.CustomizationFont
import com.usercentrics.sdk.v2.settings.data.FirstLayer
import com.usercentrics.sdk.v2.settings.data.PublishedApp
import com.usercentrics.sdk.v2.settings.data.SecondLayer
import com.usercentrics.sdk.v2.settings.data.ConsentOrPaySettings
import com.usercentrics.sdk.v2.settings.data.TCF2ChangedPurposes
import com.usercentrics.sdk.v2.settings.data.TCF2Settings
import com.usercentrics.sdk.v2.settings.data.UsercentricsCategory
Expand Down Expand Up @@ -225,10 +226,18 @@ private fun TCF2Settings.serialize(): Any {
"scope" to scope.name,
"changedPurposes" to changedPurposes?.serialize(),
"acmV2Enabled" to acmV2Enabled,
"selectedATPIds" to selectedATPIds
"selectedATPIds" to selectedATPIds,
"consentOrPay" to consentOrPay?.serialize()
)
}

private fun ConsentOrPaySettings.serialize(): Map<String, Any?> = mapOf(
"enableConsentOrPay" to enableConsentOrPay,
"showTogglesForVendors" to showTogglesForVendors,
"publisherRestrictions" to publisherRestrictions,
"specialFeatures" to specialFeatures
)

private fun UsercentricsCustomization.serialize(): Any {
return mapOf(
"color" to color?.serialize(),
Expand Down
13 changes: 12 additions & 1 deletion ios/Classes/Serializer/CMPDataSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,22 @@ extension TCF2Settings {
"scope": self.scope.name,
"changedPurposes": self.changedPurposes?.serialize() as Any,
"acmV2Enabled" : self.acmV2Enabled,
"selectedATPIds" : self.selectedATPIds
"selectedATPIds" : self.selectedATPIds,
"consentOrPay": self.consentOrPay?.serialize() as Any
]
}
}

extension ConsentOrPaySettings {
func serialize() -> [String: Any] {
return [
"enableConsentOrPay": self.enableConsentOrPay,
"showTogglesForVendors": self.showTogglesForVendors,
"publisherRestrictions": self.publisherRestrictions,
"specialFeatures": self.specialFeatures
]
}
}

extension UsercentricsCustomization {
func serialize() -> Any {
Expand Down
18 changes: 17 additions & 1 deletion lib/src/internal/serializer/tcf2_settings_serializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class TCF2SettingsSerializer {
changedPurposes:
TCF2ChangedPurposesSerializer.deserialize(value['changedPurposes']),
acmV2Enabled: value['acmV2Enabled'] ?? false,
selectedATPIds: value['selectedATPIds']?.cast<int>() ?? []);
selectedATPIds: value['selectedATPIds']?.cast<int>() ?? [],
consentOrPay: TCF2ConsentOrPaySettingsSerializer.deserialize(
value['consentOrPay']));
}
}

Expand Down Expand Up @@ -107,3 +109,17 @@ class TCF2ChangedPurposesSerializer {
legIntPurposes: value['legIntPurposes']?.cast<int>() ?? []);
}
}

class TCF2ConsentOrPaySettingsSerializer {
static TCF2ConsentOrPaySettings? deserialize(value) {
if (value == null) return null;
return TCF2ConsentOrPaySettings(
enableConsentOrPay: value['enableConsentOrPay'] ?? false,
showTogglesForVendors: value['showTogglesForVendors'] ?? true,
publisherRestrictions:
(value['publisherRestrictions'] as Map?)?.cast<String, String>() ??
{},
specialFeatures:
(value['specialFeatures'] as Map?)?.cast<String, String>() ?? {});
}
}
44 changes: 41 additions & 3 deletions lib/src/model/tcf2_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class TCF2Settings {
required this.scope,
required this.changedPurposes,
required this.acmV2Enabled,
required this.selectedATPIds});
required this.selectedATPIds,
this.consentOrPay});

final String firstLayerTitle;
final String secondLayerTitle;
Expand Down Expand Up @@ -121,6 +122,7 @@ class TCF2Settings {
final TCF2ChangedPurposes changedPurposes;
final bool acmV2Enabled;
final List<int> selectedATPIds;
final TCF2ConsentOrPaySettings? consentOrPay;

@override
bool operator ==(Object other) =>
Expand Down Expand Up @@ -189,7 +191,8 @@ class TCF2Settings {
scope == other.scope &&
changedPurposes == other.changedPurposes &&
acmV2Enabled == other.acmV2Enabled &&
listEquals(selectedATPIds, other.selectedATPIds);
listEquals(selectedATPIds, other.selectedATPIds) &&
consentOrPay == other.consentOrPay;

@override
int get hashCode =>
Expand Down Expand Up @@ -251,7 +254,8 @@ class TCF2Settings {
scope.hashCode +
changedPurposes.hashCode +
acmV2Enabled.hashCode +
selectedATPIds.hashCode;
selectedATPIds.hashCode +
consentOrPay.hashCode;

@override
String toString() => "$TCF2Settings($hashCode)";
Expand Down Expand Up @@ -279,3 +283,37 @@ class TCF2ChangedPurposes {
@override
int get hashCode => purposes.hashCode ^ legIntPurposes.hashCode;
}

class TCF2ConsentOrPaySettings {
const TCF2ConsentOrPaySettings(
{required this.enableConsentOrPay,
required this.showTogglesForVendors,
required this.publisherRestrictions,
required this.specialFeatures});

final bool enableConsentOrPay;
final bool showTogglesForVendors;

/// Maps TCF Purpose ID (as string) to "flexible". Absent entries are mandatory.
final Map<String, String> publisherRestrictions;

/// Maps Special Feature ID (as string) to "flexible". Absent entries are mandatory.
final Map<String, String> specialFeatures;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TCF2ConsentOrPaySettings &&
runtimeType == other.runtimeType &&
enableConsentOrPay == other.enableConsentOrPay &&
showTogglesForVendors == other.showTogglesForVendors &&
mapEquals(publisherRestrictions, other.publisherRestrictions) &&
mapEquals(specialFeatures, other.specialFeatures);

@override
int get hashCode =>
enableConsentOrPay.hashCode ^
showTogglesForVendors.hashCode ^
publisherRestrictions.hashCode ^
specialFeatures.hashCode;
}
Loading