Skip to content
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

Conversant: Enable audio requests #3605 #3616

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -260,11 +260,12 @@ private Bid updateBidWithId(Bid bid) {
}

private static BidType getType(String impId, List<Imp> imps) {
for (Imp imp : imps) {
if (imp.getId().equals(impId)) {
return imp.getVideo() != null ? BidType.video : BidType.banner;
}
}
return BidType.banner;
return imps.stream()
.filter(imp -> impId.equals(imp.getId()))
.findFirst()
.map(imp -> imp.getAudio() != null ? BidType.audio
: (imp.getVideo() != null ? BidType.video
: BidType.banner))
.orElse(BidType.banner);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably go this way, because it's closer to the existing bidders style

    private static BidType getType(String impId, List<Imp> imps) {
        for (Imp imp : imps) {
            if (imp.getId().equals(impId)) {
                if (imp.getVideo() != null) {
                    return BidType.video;
                } else if (imp.getAudio() != null) {
                    return BidType.audio;
                } else {
                    return BidType.banner;
                }
            }
        }
        return BidType.banner;
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
2 changes: 2 additions & 0 deletions src/main/resources/bidder-config/epsilon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ adapters:
app-media-types:
- banner
- video
- audio
site-media-types:
- banner
- video
- audio
supported-vendors:
vendor-id: 24
usersync:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.iab.openrtb.request.App;
import com.iab.openrtb.request.Audio;
import com.iab.openrtb.request.Banner;
import com.iab.openrtb.request.BidRequest;
import com.iab.openrtb.request.Imp;
Expand Down Expand Up @@ -41,6 +42,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.prebid.server.proto.openrtb.ext.response.BidType.audio;
import static org.prebid.server.proto.openrtb.ext.response.BidType.banner;
import static org.prebid.server.proto.openrtb.ext.response.BidType.video;

Expand Down Expand Up @@ -610,6 +612,25 @@ public void makeBidsShouldReturnVideoBidIfRequestImpHasVideo() throws JsonProces
.containsExactly(BidderBid.of(Bid.builder().impid("123").build(), video, "USD"));
}

@Test
public void makeBidsShouldReturnAudioBidIfRequestImpHasAudio() throws JsonProcessingException {
// given
final BidderCall<BidRequest> httpCall = givenHttpCall(
givenBidRequest(builder -> builder.id("123")
.audio(Audio.builder().build())
.banner(Banner.builder().build())),
mapper.writeValueAsString(
givenBidResponse(bidBuilder -> bidBuilder.impid("123"))));

// when
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.containsExactly(BidderBid.of(Bid.builder().impid("123").build(), audio, "USD"));
}

@Test
public void makeBidsShouldUpdateBidWithUUIDIfGenerateBidIdIsTrue() throws JsonProcessingException {
// given
Expand Down
Loading