Skip to content

Commit

Permalink
fix ccpa consent status serializer always unknown
Browse files Browse the repository at this point in the history
use kotlin serializer's default serializer for enums instead of custom made one
  • Loading branch information
andresilveirah committed Oct 14, 2024
1 parent dcbfc4f commit a67d7d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sourcepoint.mobile_core.models.consents

import com.sourcepoint.mobile_core.utils.StringEnumWithDefaultSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -14,18 +13,16 @@ data class CCPAConsent(
var uspstring: String? = null,
val rejectedVendors: List<String> = emptyList(),
val rejectedCategories: List<String> = emptyList(),
val status: CCPAConsentStatus = CCPAConsentStatus.Unknown,
val status: CCPAConsentStatus? = null,
val webConsentPayload: String? = null,
@SerialName("GPPData") val gppData: IABData = emptyMap(),
) {
@Serializable(with = CCPAConsentStatus.Serializer::class)
@Serializable
enum class CCPAConsentStatus {
@SerialName("consentedAll") ConsentedAll,
@SerialName("rejectedAll") RejectedAll,
@SerialName("rejectedSome") RejectedSome,
@SerialName("rejectedNone") RejectedNone,
@SerialName("linkedNoAction") LinkedNoAction,
Unknown;
object Serializer: StringEnumWithDefaultSerializer<CCPAConsentStatus>(entries, Unknown)
@SerialName("linkedNoAction") LinkedNoAction
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class SourcepointClientTest {
assertNotNull(consents)
assertTrue(consents.gppData.isNotEmpty())
assertNotNull(consents.signedLspa)
assertNotEquals(CCPAConsent.CCPAConsentStatus.Unknown, consents.status)
assertNotEquals(CCPAConsent.CCPAConsentStatus.RejectedNone, consents.status)
assertTrue(consents.rejectedCategories.isNotEmpty())
assertTrue(consents.rejectedVendors.isNotEmpty())
assertTrue(consents.dateCreated!!.isNotEmpty())
Expand Down

0 comments on commit a67d7d0

Please sign in to comment.