Skip to content

Commit

Permalink
add ccpa to messages request/response
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilveirah committed Sep 9, 2024
1 parent ffe118d commit 07317b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.sourcepoint.mobile_core.models.SPIDFAStatus
import com.sourcepoint.mobile_core.models.SPMessageLanguage
import com.sourcepoint.mobile_core.models.SPPropertyName
import com.sourcepoint.mobile_core.models.SPTargetingParams
import com.sourcepoint.mobile_core.models.consents.CCPAConsent
import kotlinx.serialization.Serializable

@Serializable
Expand Down Expand Up @@ -51,11 +52,18 @@ data class MessagesRequest(
val hasLocalData: Boolean,
val consentStatus: ConsentStatus
)

@Serializable
data class CCPA(
val targetingParams: SPTargetingParams?,
val hasLocalData: Boolean,
val consentStatus: CCPAConsent.CCPAConsentStatus
)
}
}

@Serializable
data class MetaData(val gdpr: Campaign?, val usnat: Campaign?) {
data class MetaData(val gdpr: Campaign?, val usnat: Campaign?, val ccpa: Campaign?) {
@Serializable
data class Campaign(val applies: Boolean)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.sourcepoint.mobile_core.network.responses

import com.sourcepoint.mobile_core.models.consents.ConsentStatus
import com.sourcepoint.mobile_core.models.SPMessageLanguage
import com.sourcepoint.mobile_core.models.consents.CCPAConsent
import com.sourcepoint.mobile_core.models.consents.ConsentStrings
import com.sourcepoint.mobile_core.models.consents.SPGDPRVendorGrants
import com.sourcepoint.mobile_core.models.consents.USNatConsent
Expand Down Expand Up @@ -106,6 +107,15 @@ data class MessagesResponse(
@SerialName("GPPData") val gppData: JsonObject
): Campaign()

@Serializable
@SerialName("CCPA")
data class CCPA(
override val type: String = "CCPA",
val expirationDate: String,
val status: CCPAConsent.CCPAConsentStatus,
@SerialName("GPPData") val gppData: JsonObject
): Campaign()

@Serializable
data class MessageMetaData(
val categoryId: MessageCategory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.sourcepoint.mobile_core.network.requests.ConsentStatusRequest
import com.sourcepoint.mobile_core.network.requests.MetaDataRequest
import com.sourcepoint.mobile_core.models.SPCampaignEnv
import com.sourcepoint.mobile_core.models.SPMessageLanguage
import com.sourcepoint.mobile_core.models.consents.CCPAConsent
import com.sourcepoint.mobile_core.models.consents.ConsentStatus
import com.sourcepoint.mobile_core.network.responses.MessagesResponse
import com.sourcepoint.mobile_core.network.requests.MessagesRequest
Expand Down Expand Up @@ -74,6 +75,7 @@ class SourcepointClientTest {
when(campaign) {
is MessagesResponse.GDPR -> assertCampaignConsents(campaign)
is MessagesResponse.USNat -> assertCampaignConsents(campaign)
is MessagesResponse.CCPA -> assertCampaignConsents(campaign)
}
}

Expand All @@ -90,6 +92,11 @@ class SourcepointClientTest {
assertTrue(usnat.userConsents.categories.isNotEmpty())
}

private fun assertCampaignConsents(ccpa: MessagesResponse.CCPA) {
assertTrue(ccpa.gppData.isNotEmpty())
assertNotEquals(CCPAConsent.CCPAConsentStatus.Unknown, ccpa.status)
}

@Test
fun getMessages() = runTest {
val response = api.getMessages(
Expand All @@ -115,7 +122,8 @@ class SourcepointClientTest {
),
metadata = MessagesRequest.MetaData(
gdpr = MessagesRequest.MetaData.Campaign(applies = true),
usnat = MessagesRequest.MetaData.Campaign(applies = true)
usnat = MessagesRequest.MetaData.Campaign(applies = true),
ccpa = MessagesRequest.MetaData.Campaign(applies = true)
),
localState = null,
nonKeyedLocalState = null
Expand Down

0 comments on commit 07317b5

Please sign in to comment.