Skip to content

Removed BidResponse extension #164

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

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public class BidResponse(
@JvmField @SerialName("duration") public val duration: Int = 0,
@JvmField @SerialName("exp") public val exp: Int = -1,
@JvmField @SerialName("external_notifications") public val external_notifications: Map<String, String> = emptyMap(),
@JvmField @SerialName("ext") public val ext: Extension = Extension(),
) {
/** Urls to fire a request to when an impression is registered */
public val impression_trackers: Array<String>? get() = trackers["impression_trackers"]
Expand All @@ -81,14 +80,4 @@ public class BidResponse(
jsonSerializer: Json = BidRequest.lenientSerializer,
): String = jsonSerializer.encodeToString(serializer(), response)
}

/**
* BidResponse Extension object from Nimbus
*
* @property use_new_renderer Set to false if Nimbus has determined the creative should be rendered using IMA SDK
*/
@Serializable
public class Extension(
@JvmField @SerialName("use_new_renderer") public val use_new_renderer: Boolean = true,
)
}
21 changes: 2 additions & 19 deletions kotlin/src/commonTest/kotlin/BidResponseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldStartWith

private fun testJson(ext: String = "") = """
const val testResponse = """
{
"type": "native",
"auction_id": "d07668d6-35ba-4870-a3cd-02b18fec1a12",
Expand All @@ -34,7 +34,6 @@ private fun testJson(ext: String = "") = """
"win_response": "https://test.adsbynimbus.com/win_response/",
"loss_response": "https://test.adsbynimbus.com/loss_response/auctionPrice=[AUCTION_PRICE]&auctionMinToWin=[AUCTION_MIN_TO_WIN]&winningSource=[WINNING_SOURCE]"
}
$ext
}
"""

Expand All @@ -43,7 +42,7 @@ class BidResponseTest : StringSpec({
lateinit var response: BidResponse

beforeTest {
response = BidResponse.fromJson(testJson())
response = BidResponse.fromJson(testResponse)
}

"BidResponse fromJson deserializes the type field" {
Expand Down Expand Up @@ -110,22 +109,6 @@ class BidResponseTest : StringSpec({
response.win_response shouldBe "https://test.adsbynimbus.com/win_response/"
}

"BidResponse fromJson deserializes use_new_renderer" {
// if missing, default is true
response.ext.use_new_renderer shouldBe true
BidResponse.fromJson(testJson("""
,"ext": {
"use_new_renderer": true
}
""".trimIndent())).ext.use_new_renderer shouldBe true
BidResponse.fromJson(
testJson("""
,"ext": {
"use_new_renderer": false
}
""".trimIndent())).ext.use_new_renderer shouldBe false
}

"BidResponse fromJson deserializes loss urls" {
response.loss_response shouldStartWith "https://test.adsbynimbus.com/loss_response/"
response.loss_response shouldContain "auctionPrice=[AUCTION_PRICE]"
Expand Down