Skip to content

Commit 0ec1452

Browse files
committed
LIBMOBILE-1187
- NielsenDCRDestination reformatted
1 parent 7187ac7 commit 0ec1452

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

lib/src/main/java/com/segment/analytics/kotlin/destinations/nielsendcr/NielsenDCRDestination.kt

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class NielsenDCRDestination : DestinationPlugin() {
2828
private const val NIELSEN_DCR_FULL_KEY = "Nielsen DCR"
2929
private const val SF_CODE = "dcr"
3030

31-
// Formatter to format properties
31+
// Formatter to format properties
3232
private val CONTENT_FORMATTER = Collections.unmodifiableMap(mapOf(
3333
"session_id" to "sessionId",
3434
"asset_id" to "assetId",
@@ -344,12 +344,8 @@ class NielsenDCRDestination : DestinationPlugin() {
344344
): JSONObject {
345345
val contentMetadata: JSONObject = mapSpecialKeys(contentProperties, CONTENT_MAP)
346346
// map payload options to Nielsen content metadata fields
347-
if (options.containsKey("pipmode")) {
348-
val pipmode = options["pipmode"].toString()
349-
contentMetadata.put("pipmode", pipmode)
350-
} else {
351-
contentMetadata.put("pipmode", "false")
352-
}
347+
contentMetadata.put(
348+
"pipmode", options["pipmode"] ?: "false")
353349
if (options.containsKey("crossId1")) {
354350
val crossId1 = options["crossId1"].toString()
355351
contentMetadata.put("crossId1", crossId1)
@@ -366,13 +362,8 @@ class NielsenDCRDestination : DestinationPlugin() {
366362
val segC = options["segC"].toString()
367363
contentMetadata.put("segC", segC)
368364
}
369-
if (options.containsKey("hasAds")
370-
&& options["hasAds"] != null && "true" == options["hasAds"].toString()
371-
) {
372-
contentMetadata.put("hasAds", "1")
373-
} else {
374-
contentMetadata.put("hasAds", "0")
375-
}
365+
contentMetadata.put(
366+
"hasAds", if ((options["hasAds"] ?: "false") == "true") "1" else "0")
376367

377368
// map settings to Nielsen content metadata fields
378369
val contentAssetId = fetchContentAssetId(contentProperties)
@@ -399,7 +390,7 @@ class NielsenDCRDestination : DestinationPlugin() {
399390
// map properties with non-String values to Nielsen content metadata fields
400391
if (contentProperties.containsKey("airdate")) {
401392
var airdate: String? = contentProperties["airdate"]!!
402-
if (airdate != null && !airdate.isEmpty()) {
393+
if (airdate != null && airdate.isNotEmpty()) {
403394
airdate = formatAirDate(contentProperties["airdate"]!!)
404395
}
405396
contentMetadata.put("airdate", airdate)
@@ -413,11 +404,7 @@ class NielsenDCRDestination : DestinationPlugin() {
413404
adLoadType = contentProperties["loadType"]!!
414405
}
415406
}
416-
if (adLoadType == "dynamic") {
417-
contentMetadata.put("adloadtype", "2")
418-
} else {
419-
contentMetadata.put("adloadtype", "1")
420-
}
407+
contentMetadata.put("adloadtype", if (adLoadType == "dynamic") "2" else "1")
421408
val fullEpisodeStatus: Boolean = contentProperties["fullEpisode"]?.toBoolean() ?: false
422409
contentMetadata.put("isfullepisode", if (fullEpisodeStatus) "y" else "n")
423410
contentMetadata.put("type", "content")

0 commit comments

Comments
 (0)