-
Notifications
You must be signed in to change notification settings - Fork 16
feat(MSDK-4088): Support PL-5714 new COP restriction fields across TS, Android and iOS #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -238,6 +238,7 @@ extension TCF2Settings { | |
| "resurfacePeriod": self.resurfacePeriod, | ||
| "consentOrPay": self.consentOrPay?.toDictionary() as Any, | ||
| "mandatoryLabel": self.mandatoryLabel, | ||
| "specialFeaturesConsentOrPay": self.specialFeaturesConsentOrPay?.map { $0.toDictionary() } as Any, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [REFACTORING] You added "specialFeaturesConsentOrPay": self.specialFeaturesConsentOrPay?.map { $0.toDictionary() } as Any. Ensure the resulting array elements are JSON-serializable types (String/Int/Bool/NSDictionary). If ConsentOrPayRestriction.value is an enum on the native SDK, convert it to rawValue or String(describing:) in toDictionary() so the JS bridge receives plain strings (matching the TS 'FLEXIBLE'|'MANDATORY' expectation). extension ConsentOrPayRestriction {
func toDictionary() -> [String: Any] {
return [
"id": self.id,
"value": (self.value as? CustomStringConvertible)?.description ?? String(describing: self.value),
]
}
} |
||
| ] | ||
| } | ||
| } | ||
|
|
@@ -497,7 +498,17 @@ extension TCF2ChangedPurposes { | |
| func toDictionary() -> Any { | ||
| return [ | ||
| "purposes": purposes, | ||
| "legIntPurposes": legIntPurposes | ||
| "legIntPurposes": legIntPurposes, | ||
| "consentOrPay": consentOrPay?.map { $0.toDictionary() } as Any, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| extension ConsentOrPayRestriction { | ||
| func toDictionary() -> [String: Any] { | ||
| return [ | ||
| "id": self.id, | ||
| "value": self.value, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ export class TCF2Settings { | |
| selectedATPIds: number[] | ||
| consentOrPay?: TCF2ConsentOrPaySettings | ||
| mandatoryLabel: string | ||
| specialFeaturesConsentOrPay?: ConsentOrPayRestriction[] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [REFACTORING] You introduced specialFeaturesConsentOrPay?: ConsentOrPayRestriction[] and the ConsentOrPayRestriction class with value: string. For stronger type-safety, change the value type to a string literal union: value: 'FLEXIBLE' | 'MANDATORY'. This prevents invalid values being created in TypeScript consumers. Also remove the unnecessary optional-chaining in isFlexible(): use return this.value.toUpperCase() === 'FLEXIBLE' (value is non-nullable if typed as the union). export class ConsentOrPayRestriction {
id: number
value: 'FLEXIBLE' | 'MANDATORY'
constructor(id: number, value: 'FLEXIBLE' | 'MANDATORY') {
this.id = id
this.value = value
}
isFlexible(): boolean {
return this.value.toUpperCase() === 'FLEXIBLE'
}
} |
||
|
|
||
| constructor( | ||
| firstLayerTitle: string, | ||
|
|
@@ -123,6 +124,7 @@ export class TCF2Settings { | |
| dataSharedOutsideEUText?: string, | ||
| consentOrPay?: TCF2ConsentOrPaySettings, | ||
| mandatoryLabel: string = 'Mandatory', | ||
| specialFeaturesConsentOrPay?: ConsentOrPayRestriction[], | ||
| ) { | ||
| this.firstLayerTitle = firstLayerTitle | ||
| this.secondLayerTitle = secondLayerTitle | ||
|
|
@@ -185,6 +187,7 @@ export class TCF2Settings { | |
| this.selectedATPIds = selectedATPIds | ||
| this.consentOrPay = consentOrPay | ||
| this.mandatoryLabel = mandatoryLabel | ||
| this.specialFeaturesConsentOrPay = specialFeaturesConsentOrPay | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -204,13 +207,30 @@ export class TCF2ChangedPurposes { | |
|
|
||
| purposes: [number] | ||
| legIntPurposes: [number] | ||
| consentOrPay?: ConsentOrPayRestriction[] | ||
|
|
||
| constructor( | ||
| purposes: [number], | ||
| legIntPurposes: [number], | ||
| consentOrPay?: ConsentOrPayRestriction[], | ||
| ) { | ||
| this.purposes = purposes | ||
| this.legIntPurposes = legIntPurposes | ||
| this.consentOrPay = consentOrPay | ||
| } | ||
| } | ||
|
|
||
| export class ConsentOrPayRestriction { | ||
| id: number | ||
| value: string | ||
|
|
||
| constructor(id: number, value: string) { | ||
| this.id = id | ||
| this.value = value | ||
| } | ||
|
|
||
| isFlexible(): boolean { | ||
| return this.value?.toUpperCase() === 'FLEXIBLE' | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[VALIDATION] ConsentOrPayRestriction.serialize() returns id and value directly. Ensure the SDK's ConsentOrPayRestriction.value is a JSON-friendly type (String). If the SDK defines value as an enum, explicitly serialize it to a string (e.g. value.name or value.toString().uppercase()) so the JS side receives the expected 'FLEXIBLE'|'MANDATORY' strings. Also consider normalizing casing (uppercase) to match the TypeScript expectation.