Skip to content

Commit

Permalink
delete redundant method to generate message body request for DIA-2458…
Browse files Browse the repository at this point in the history
…-review-message-param
  • Loading branch information
bohdan-go-wombat committed Jul 31, 2023
1 parent 6a94a43 commit c04158e
Showing 1 changed file with 0 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,72 +1,12 @@
package com.sourcepoint.cmplibrary.data.network.model.optimized

import android.os.Build
import com.sourcepoint.cmplibrary.data.network.converter.JsonConverter
import com.sourcepoint.cmplibrary.data.network.converter.converter
import com.sourcepoint.cmplibrary.data.network.util.CampaignsEnv
import com.sourcepoint.cmplibrary.exception.CampaignType
import com.sourcepoint.cmplibrary.model.CampaignReq
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.* // ktlint-disable

private const val GET_MESSAGES_REQ_BODY_ACCOUNT_ID_KEY = "accountId"
private const val GET_MESSAGES_REQ_BODY_PROPERTY_HREF_KEY = "propertyHref"
private const val GET_MESSAGES_REQ_BODY_CAMPAIGNS_KEY = "campaigns"
private const val GET_MESSAGES_REQ_BODY_CAMPAIGN_ENV_KEY = "campaignEnv"
private const val GET_MESSAGES_REQ_BODY_CONSENT_LANGUAGE_KEY = "consentLanguage"
private const val GET_MESSAGES_REQ_BODY_HAS_CSP_KEY = "hasCSP"
private const val GET_MESSAGES_REQ_INCLUDE_DATA_KEY = "includeData"
private const val GET_MESSAGES_REQ_LOCAL_STATE_KEY = "localState"
private const val GET_MESSAGES_REQ_OS_KEY = "os"

internal fun createGetMessagesRequestBody(
accountId: Long,
propertyHref: String,
campaigns: List<CampaignReq>,
gdprConsentStatus: ConsentStatus?,
ccpaConsentStatus: String?,
campaignEnv: CampaignsEnv?,
consentLanguage: String?,
localState: JsonObject?,
): JsonObject {
return buildJsonObject {

put(GET_MESSAGES_REQ_BODY_ACCOUNT_ID_KEY, accountId)

put(GET_MESSAGES_REQ_BODY_PROPERTY_HREF_KEY, "https://$propertyHref")

put(
GET_MESSAGES_REQ_BODY_CAMPAIGNS_KEY,
campaigns.toMetadataBody(gdprConsentStatus, ccpaConsentStatus)
)

campaignEnv?.env?.let { put(GET_MESSAGES_REQ_BODY_CAMPAIGN_ENV_KEY, it) }

put(GET_MESSAGES_REQ_BODY_CONSENT_LANGUAGE_KEY, consentLanguage)

put(GET_MESSAGES_REQ_BODY_HAS_CSP_KEY, false)

putJsonObject(GET_MESSAGES_REQ_INCLUDE_DATA_KEY) {
putJsonObject("TCData") {
put("type", "RecordString")
}
putJsonObject("campaigns") {
put("type", "RecordString")
}
putJsonObject("webConsentPayload") {
put("type", "RecordString")
}
}

put(GET_MESSAGES_REQ_LOCAL_STATE_KEY, localState ?: JsonObject(mapOf()))

putJsonObject(GET_MESSAGES_REQ_OS_KEY) {
put("name", "android")
put("version", "${Build.VERSION.SDK_INT}")
}
}
}

internal fun List<CampaignReq>.toMetadataBody(
gdprConsentStatus: ConsentStatus? = null,
ccpaConsentStatus: String? = null
Expand Down

0 comments on commit c04158e

Please sign in to comment.