Skip to content

Commit 2451f72

Browse files
CpmStar: Adapter Update bidder implementation to allow imp.ext passthrough with the correct custom parameters.
1 parent 0dc4424 commit 2451f72

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/main/java/org/prebid/server/bidder/cpmstar/CpmStarBidder.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.prebid.server.bidder.cpmstar;
22

33
import com.fasterxml.jackson.core.type.TypeReference;
4+
import com.fasterxml.jackson.databind.node.ObjectNode;
45
import com.iab.openrtb.request.BidRequest;
56
import com.iab.openrtb.request.Imp;
67
import com.iab.openrtb.response.Bid;
@@ -26,6 +27,7 @@
2627
import java.util.Collection;
2728
import java.util.Collections;
2829
import java.util.List;
30+
import java.util.Map;
2931
import java.util.Objects;
3032

3133
public class CpmStarBidder implements Bidder<BidRequest> {
@@ -79,7 +81,14 @@ private Imp createImp(ExtImpCpmStar extImpCpmStar, Imp imp) {
7981
if (extImpCpmStar == null) {
8082
throw new PreBidException("imp id=%s: bidder.ext is null".formatted(imp.getId()));
8183
}
82-
return imp.toBuilder().ext(mapper.mapper().valueToTree(extImpCpmStar)).build();
84+
final Map<String, Object> extMap = mapper.mapper().convertValue(imp.getExt(), new TypeReference<>() {
85+
});
86+
final Map<String, Object> bidderMap = (Map<String, Object>) extMap.remove("bidder");
87+
if (bidderMap != null) {
88+
extMap.putAll(bidderMap);
89+
}
90+
final ObjectNode newExt = mapper.mapper().valueToTree(extMap);
91+
return imp.toBuilder().ext(newExt).build();
8392
}
8493

8594
@Override

src/test/resources/org/prebid/server/it/openrtb2/cpmstar/test-auction-cpmstar-request.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
"gdpr": 0
2222
}
2323
}
24-
}
24+
}

src/test/resources/org/prebid/server/it/openrtb2/cpmstar/test-cpmstar-bid-request.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
"h": 250
1010
},
1111
"ext": {
12+
"tid" : "${json-unit.any-string}",
1213
"placementId": 1234,
1314
"subpoolId": 1234
1415
}
1516
}
1617
],
17-
"source": {
18-
"tid": "${json-unit.any-string}"
19-
},
2018
"site": {
2119
"domain": "www.example.com",
2220
"page": "http://www.example.com",
@@ -36,6 +34,8 @@
3634
"cur": [
3735
"USD"
3836
],
37+
"source" :
38+
{"tid" : "${json-unit.any-string}"},
3939
"regs": {
4040
"ext": {
4141
"gdpr": 0
@@ -52,3 +52,4 @@
5252
}
5353
}
5454
}
55+

0 commit comments

Comments
 (0)