Skip to content

Commit

Permalink
ORBIDDER: BidType detection, web-sites new types (#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
arneschulz1984 authored Aug 10, 2023
1 parent e53a25b commit ca7d115
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.iab.openrtb.request.BidRequest;
import com.iab.openrtb.request.Imp;
import com.iab.openrtb.response.Bid;
import com.iab.openrtb.response.BidResponse;
import com.iab.openrtb.response.SeatBid;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -103,14 +104,16 @@ public Result<List<BidderBid>> makeBids(BidderCall<BidRequest> httpCall, BidRequ
return Result.withError(BidderError.badServerResponse(e.getMessage()));
}

final List<BidderError> errors = new ArrayList<>();
final List<BidderBid> bidderBids = bidResponse.getSeatbid().stream()
.filter(Objects::nonNull)
.map(SeatBid::getBid)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.map(bid -> BidderBid.of(bid, BidType.banner, bidResponse.getCur()))
.map(bid -> toBidderBid(bid, bidResponse.getCur(), errors))
.filter(Objects::nonNull)
.toList();
return Result.of(bidderBids, Collections.emptyList());
return Result.of(bidderBids, errors);
}

private BidResponse decodeBodyToBidResponse(BidderCall<BidRequest> httpCall) {
Expand All @@ -120,4 +123,27 @@ private BidResponse decodeBodyToBidResponse(BidderCall<BidRequest> httpCall) {
throw new PreBidException(e.getMessage(), e);
}
}

private BidderBid toBidderBid(Bid bid, String cur, List<BidderError> errors) {
final BidType bidType;
try {
bidType = getBidType(bid.getMtype());
} catch (PreBidException e) {
errors.add(BidderError.badServerResponse(e.getMessage()));
return null;
}

return BidderBid.of(bid, bidType, cur);
}

private static BidType getBidType(Integer mType) {
return switch (mType) {
case 1 -> BidType.banner;
case 2 -> BidType.video;
case 3 -> BidType.audio;
case 4 -> BidType.xNative;

default -> throw new PreBidException("Unsupported mType " + mType);
};
}
}
2 changes: 2 additions & 0 deletions src/main/resources/bidder-config/orbidder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ adapters:
app-media-types:
- banner
site-media-types:
- banner
- native
supported-vendors:
vendor-id: 559
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
},
"id": "bid_id",
"impid": "imp_id",
"price": 0.01
"price": 0.01,
"mtype": 1
}
],
"group": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"price": 0.01,
"ext": {
"format": "BANNER"
}
},
"mtype": 1
}
]
}
]
}
}

0 comments on commit ca7d115

Please sign in to comment.