OMS: add video support#3779
Conversation
|
|
||
| String pid; | ||
|
|
||
| Integer publisherId; |
There was a problem hiding this comment.
add JsonProperty
also I would change the integration test payload to cover publisherId parameter
There was a problem hiding this comment.
I have cheanged pid to publisherId but IMO its indifferent
There was a problem hiding this comment.
the pid is declared as deprecated
There was a problem hiding this comment.
I meant, it makes sense to add a publisherId to the test instead of deprecated pid, but pid is still can be used, it's deprecated, not removed, please revert this change
| public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest request) { | ||
| String uri = endpointUrl; | ||
|
|
||
| if (!request.getImp().isEmpty()) { | ||
| try { | ||
| final ExtImpOms impExt = parseImpExt(request.getImp().get(0)); | ||
| if (impExt != null) { | ||
| if (impExt.getPid() != null && !impExt.getPid().isEmpty()) { | ||
| uri = String.format("%s?publisherId=%s", endpointUrl, impExt.getPid()); | ||
| } else if (impExt.getPublisherId() != null && impExt.getPublisherId() > 0) { | ||
| uri = String.format("%s?publisherId=%d", endpointUrl, impExt.getPublisherId()); | ||
| } | ||
| } | ||
| } catch (PreBidException e) { | ||
| return Result.withError(BidderError.badInput(e.getMessage())); | ||
| } | ||
| } | ||
|
|
||
| return Result.withValue(BidderUtil.defaultRequest(request, uri, mapper)); | ||
| } |
There was a problem hiding this comment.
I believe it can work this way
try {
final ExtImpOms impExt = parseImpExt(request.getImp().getFirst());
final String publisherId = impExt.getPid() == null && impExt.getPublisherId() != null && impExt.getPublisherId() > 0
? String.valueOf(impExt.getPublisherId())
: impExt.getPid();
final String url = "%s?publisherId=%s".formatted(endpointUrl, publisherId);
return Result.withValue(BidderUtil.defaultRequest(request, url, mapper));
} catch (PreBidException e) {
return Result.withError(BidderError.badInput(e.getMessage()));
}| .filter(Objects::nonNull) | ||
| .flatMap(Collection::stream) | ||
| .map(bid -> BidderBid.of(bid, BidType.banner, bidResponse.getCur())) | ||
| .map(bid -> BidderBid.of(bid, getBidType(bid.getMtype()), bidResponse.getCur())) |
There was a problem hiding this comment.
the following is not ported
func getBidVideo(bidType openrtb_ext.BidType, bid *openrtb2.Bid) *openrtb_ext.ExtBidPrebidVideo {
if bidType != openrtb_ext.BidTypeVideo {
return nil
}
var primaryCategory string
if len(bid.Cat) > 0 {
primaryCategory = bid.Cat[0]
}
return &openrtb_ext.ExtBidPrebidVideo{
Duration: int(bid.Dur),
PrimaryCategory: primaryCategory,
}
}| return catNotEmpty || durationValid | ||
| ? ExtBidPrebidVideo.of( | ||
| durationValid ? duration : null, | ||
| catNotEmpty ? cat.getFirst() : null) | ||
| : null; |
There was a problem hiding this comment.
In Go they always create a video object
also a duration validation seems redundant (again, according to Go)
| final Integer markupType = bid.getMtype(); | ||
| return switch (markupType) { | ||
| case 1 -> BidType.banner; | ||
| case 2 -> BidType.video; | ||
| case null, default -> throw new PreBidException("Unsupported mType " + mType); | ||
| case null, default -> BidType.banner; |
There was a problem hiding this comment.
return Objects.equals(bid.getMtype(), 2) ? BidType.video : BidType.banner;
| } | ||
|
|
||
| private static ExtBidPrebidVideo videoInfo(Bid bid) { | ||
| if (!Integer.valueOf(2).equals(bid.getMtype())) { |
There was a problem hiding this comment.
I'd use a bid type resolved on the previous step
|
|
||
| String pid; | ||
|
|
||
| Integer publisherId; |
There was a problem hiding this comment.
the pid is declared as deprecated
| public class ExtImpOms { | ||
|
|
||
| String pid; | ||
| @JsonProperty("publisherId") |
| final String publisherId = impExt.getPublisherId() != null && impExt.getPublisherId() > 0 | ||
| ? String.valueOf(impExt.getPublisherId()) : null; |
There was a problem hiding this comment.
why did you change it? I believe in the last commit it was correct
There was a problem hiding this comment.
because U said that pid is deprecated
There was a problem hiding this comment.
deprecated doesn't mean removed
There was a problem hiding this comment.
so i should add only annotation @deprecated on pid filed ?
There was a problem hiding this comment.
the initial point was about using publisherId in the integration test instead of pid, that's it, everything else was fine, the pid is still supported
There was a problem hiding this comment.
In the integration test I used only publisherId.
I used pid only in unit test.
Should it look like this?
| : null; | ||
| return ExtBidPrebidVideo.of( | ||
| duration != null ? duration : 0, | ||
| CollectionUtils.isNotEmpty(cat) ? cat.getFirst() : "" |
| @Value(staticConstructor = "of") | ||
| public class ExtImpOms { | ||
|
|
||
| String pid; |
There was a problem hiding this comment.
do not need to remove, since it's present in Go
|
|
||
| String pid; | ||
|
|
||
| Integer publisherId; |
There was a problem hiding this comment.
I meant, it makes sense to add a publisherId to the test instead of deprecated pid, but pid is still can be used, it's deprecated, not removed, please revert this change
| final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); | ||
| return Result.withValues(extractBids(bidResponse)); | ||
| } catch (DecodeException e) { | ||
| } catch (DecodeException | PreBidException e) { |
There was a problem hiding this comment.
Is PrebidException expected anywhere?
| final Integer duration = bid.getDur(); | ||
|
|
||
| return ExtBidPrebidVideo.of( | ||
| duration != null ? duration : 0, |
There was a problem hiding this comment.
ObjectUtils.defaultIfNull
🔧 Type of changes
✨ What's the context?
#3770