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.ConsentOrPayRestriction
import com.usercentrics.sdk.v2.settings.data.ConsentOrPaySettings
import com.usercentrics.sdk.v2.settings.data.TCF2ChangedPurposes
import com.usercentrics.sdk.v2.settings.data.TCF2Settings
Expand Down Expand Up @@ -228,7 +229,8 @@ private fun TCF2Settings.serialize(): Any {
"acmV2Enabled" to acmV2Enabled,
"selectedATPIds" to selectedATPIds,
"consentOrPay" to consentOrPay?.serialize(),
"mandatoryLabel" to mandatoryLabel
"mandatoryLabel" to mandatoryLabel,
"specialFeaturesConsentOrPay" to specialFeaturesConsentOrPay?.map { it.serialize() },
)
}

Expand Down Expand Up @@ -428,6 +430,12 @@ private fun TCF2ChangedPurposes?.serialize(): Any? {
}
return mapOf(
"purposes" to purposes,
"legIntPurposes" to legIntPurposes
"legIntPurposes" to legIntPurposes,
"consentOrPay" to consentOrPay?.map { it.serialize() },
)
}

private fun ConsentOrPayRestriction.serialize(): Map<String, Any?> = mapOf(
"id" to id,
"value" to value,
)
15 changes: 13 additions & 2 deletions ios/Classes/Serializer/CMPDataSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ extension TCF2Settings {
"acmV2Enabled" : self.acmV2Enabled,
"selectedATPIds" : self.selectedATPIds,
"consentOrPay": self.consentOrPay?.serialize() as Any,
"mandatoryLabel": self.mandatoryLabel
"mandatoryLabel": self.mandatoryLabel,
"specialFeaturesConsentOrPay": self.specialFeaturesConsentOrPay?.map { $0.serialize() } as Any,
]
}
}
Expand Down Expand Up @@ -409,7 +410,17 @@ extension TCF2ChangedPurposes {
func serialize() -> Any {
return [
"purposes": purposes,
"legIntPurposes": legIntPurposes
"legIntPurposes": legIntPurposes,
"consentOrPay": consentOrPay?.map { $0.serialize() } as Any,
]
}
}

extension ConsentOrPayRestriction {
func serialize() -> [String: Any] {
return [
"id": self.id,
"value": self.value,
]
}
}
Expand Down
19 changes: 17 additions & 2 deletions lib/src/internal/serializer/tcf2_settings_serializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class TCF2SettingsSerializer {
selectedATPIds: value['selectedATPIds']?.cast<int>() ?? [],
consentOrPay: TCF2ConsentOrPaySettingsSerializer.deserialize(
value['consentOrPay']),
mandatoryLabel: value['mandatoryLabel'] ?? "Mandatory");
mandatoryLabel: value['mandatoryLabel'] ?? "Mandatory",
specialFeaturesConsentOrPay:
ConsentOrPayRestrictionSerializer.deserializeList(
value['specialFeaturesConsentOrPay']));
}
}

Expand Down Expand Up @@ -107,7 +110,19 @@ class TCF2ChangedPurposesSerializer {
static TCF2ChangedPurposes deserialize(value) {
return TCF2ChangedPurposes(
purposes: value['purposes']?.cast<int>() ?? [],
legIntPurposes: value['legIntPurposes']?.cast<int>() ?? []);
legIntPurposes: value['legIntPurposes']?.cast<int>() ?? [],
consentOrPay: ConsentOrPayRestrictionSerializer.deserializeList(
value['consentOrPay']));
}
}

class ConsentOrPayRestrictionSerializer {
static List<ConsentOrPayRestriction>? deserializeList(value) {
if (value == null) return null;
return (value as List)
.map((e) => ConsentOrPayRestriction(
id: e['id'] as int, value: e['value'] as String))
.toList();
}
}

Expand Down
35 changes: 31 additions & 4 deletions lib/src/model/tcf2_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class TCF2Settings {
required this.acmV2Enabled,
required this.selectedATPIds,
this.consentOrPay,
this.mandatoryLabel = "Mandatory"});
this.mandatoryLabel = "Mandatory",
this.specialFeaturesConsentOrPay});

final String firstLayerTitle;
final String secondLayerTitle;
Expand Down Expand Up @@ -125,6 +126,7 @@ class TCF2Settings {
final List<int> selectedATPIds;
final TCF2ConsentOrPaySettings? consentOrPay;
final String mandatoryLabel;
final List<ConsentOrPayRestriction>? specialFeaturesConsentOrPay;

@override
bool operator ==(Object other) =>
Expand Down Expand Up @@ -271,21 +273,46 @@ enum TCF2Scope { global, service }

class TCF2ChangedPurposes {
const TCF2ChangedPurposes(
{required this.purposes, required this.legIntPurposes});
{required this.purposes,
required this.legIntPurposes,
this.consentOrPay});

final List<int> purposes;
final List<int> legIntPurposes;
final List<ConsentOrPayRestriction>? consentOrPay;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TCF2ChangedPurposes &&
runtimeType == other.runtimeType &&
listEquals(purposes, other.purposes) &&
listEquals(legIntPurposes, other.legIntPurposes);
listEquals(legIntPurposes, other.legIntPurposes) &&
listEquals(consentOrPay, other.consentOrPay);

@override
int get hashCode => purposes.hashCode ^ legIntPurposes.hashCode;
int get hashCode =>
purposes.hashCode ^ legIntPurposes.hashCode ^ consentOrPay.hashCode;
}

class ConsentOrPayRestriction {
const ConsentOrPayRestriction({required this.id, required this.value});

final int id;
final String value;

bool isFlexible() => value.toUpperCase() == 'FLEXIBLE';

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ConsentOrPayRestriction &&
runtimeType == other.runtimeType &&
id == other.id &&
value == other.value;

@override
int get hashCode => id.hashCode ^ value.hashCode;
}

class TCF2ConsentOrPaySettings {
Expand Down
Loading