New Adapter: ReVantage#4477
Open
v0idxyz wants to merge 4 commits into
Open
Conversation
CTMBNara
requested changes
May 13, 2026
| if (feedId == null) { | ||
| throw new PreBidException("imp %s: missing required param feedId".formatted(imp.getId())); | ||
| } | ||
| final Imp rewrittenImp = rewriteImpExt(imp, feedId, ext); |
Collaborator
There was a problem hiding this comment.
rewriteImpExt -> updateImp, rewrittenImp -> updatedImp
Comment on lines
+106
to
+108
| if (wrapper == null || wrapper.getBidder() == null) { | ||
| throw new PreBidException("imp %s: missing imp.ext.bidder".formatted(imp.getId())); | ||
| } |
Collaborator
There was a problem hiding this comment.
No need for this checks. At this stage, neither the wrapper nor the wrapper.getBidder() can be null
Comment on lines
+117
to
+129
| final ObjectNode bidderNode = mapper.mapper().createObjectNode(); | ||
| if (StringUtils.isNotBlank(ext.getPlacementId())) { | ||
| bidderNode.put("placementId", ext.getPlacementId()); | ||
| } | ||
| if (StringUtils.isNotBlank(ext.getPublisherId())) { | ||
| bidderNode.put("publisherId", ext.getPublisherId()); | ||
| } | ||
|
|
||
| final ObjectNode rewritten = mapper.mapper().createObjectNode(); | ||
| rewritten.put("feedId", feedId); | ||
| rewritten.set("bidder", bidderNode); | ||
|
|
||
| return imp.toBuilder().ext(rewritten).build(); |
Collaborator
There was a problem hiding this comment.
final ObjectNode newExt = mapper.mapper().createObjectNode();
newExt.put("feedId", feedId);
final ObjectNode bidderNode = rewritten.putObject("bidder");
final String placementId = ext.getPlacementId();
if (StringUtils.isNotBlank(placementId)) {
bidderNode.put("placementId", placementId);
}
final String publisherId = ext.getPublisherId();
if (StringUtils.isNotBlank(publisherId)) {
bidderNode.put("publisherId", publisherId);
}
return imp.toBuilder().ext(newExt).build();
Comment on lines
+138
to
+145
| return HttpRequest.<BidRequest>builder() | ||
| .method(HttpMethod.POST) | ||
| .uri(uri) | ||
| .headers(headers) | ||
| .body(mapper.encodeToBytes(request)) | ||
| .impIds(collectImpIds(request)) | ||
| .payload(request) | ||
| .build(); |
Collaborator
There was a problem hiding this comment.
Use BidderUtil.defaultRequest instead
|
|
||
| private static List<BidderBid> extractBids(BidResponse response, BidRequest request) { | ||
| if (response == null || CollectionUtils.isEmpty(response.getSeatbid())) { | ||
| return List.of(); |
Collaborator
There was a problem hiding this comment.
List.of -> Collections.emptyList
Comment on lines
+184
to
+196
| private static BidType resolveMediaType(Bid bid, List<Imp> imps) { | ||
| if (bid.getMtype() != null) { | ||
| switch (bid.getMtype()) { | ||
| case 1: | ||
| return BidType.banner; | ||
| case 2: | ||
| return BidType.video; | ||
| default: | ||
| // fall through | ||
| } | ||
| } | ||
|
|
||
| final JsonNode ext = bid.getExt(); |
Collaborator
There was a problem hiding this comment.
Refactor this method:
private static BidType resolveBidType(Bid bid, List<Imp> imps) {
return bidTypeFromMtype(bid.getMtype())
.or(() -> bidTypeFromExt(bid.getExt()))
.or(() -> bidTypeFromAdm(bid.getAdm()))
.or(() -> bidTypeFromImp(bid.getImpid(), imps))
.orElseThrow(() -> new PreBidException(
"Cannot determine media type for bid %s on imp %s".formatted(bid.getId(), bid.getImpid())));
}
private static Optional<BidType> bidTypeFromMtype(Integer mType) {
return Optional.ofNullable(switch (mType) {
case 1 -> BidType.banner;
case 2 -> BidType.video;
case null, default -> null;
});
}
private static Optional<BidType> bidTypeFromExt(ObjectNode bidExt) {
return Optional.ofNullable(bidExt)
.map(ext -> ext.get("mediaType"))
.filter(JsonNode::isTextual)
.map(JsonNode::asText)
.map(String::toLowerCase)
.map(mediaType -> switch (mediaType) {
case "banner" -> BidType.banner;
case "video" -> BidType.video;
default -> null;
});
}
private static Optional<BidType> bidTypeFromAdm(String adm) {
if (StringUtils.isBlank(adm)) {
return Optional.empty();
}
final String trimmed = adm.trim().toUpperCase();
return trimmed.startsWith("<VAST") || trimmed.startsWith("<?XML")
? Optional.of(BidType.video)
: Optional.empty();
}
private static Optional<BidType> bidTypeFromImp(String impId, List<Imp> imps) {
for (Imp imp : imps) {
if (!Objects.equals(imp.getId(), impId)) {
continue;
}
final boolean hasBanner = imp.getBanner() != null;
final boolean hasVideo = imp.getVideo() != null;
if (hasVideo && !hasBanner) {
return Optional.of(BidType.video);
}
if (hasBanner) {
return Optional.of(BidType.banner);
}
break;
}
return Optional.empty();
}
|
|
||
| @Bean("revantageConfigurationProperties") | ||
| @ConfigurationProperties("adapters.revantage") | ||
| @Validated |
Removed detailed class-level documentation and some comments in the makeHttpRequests method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Type of changes
✨ What's the context?
What's the context for the changes?
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check