Skip to content

Commit

Permalink
Gumgum: Add product support (#2724)
Browse files Browse the repository at this point in the history
  • Loading branch information
gg-natalia authored Oct 30, 2023
1 parent 11c143e commit 7194912
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
11 changes: 10 additions & 1 deletion src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

public class GumgumBidder implements Bidder<BidRequest> {

private static final String REQUEST_EXT_PRODUCT = "product";

private static final TypeReference<ExtPrebid<?, ExtImpGumgum>> GUMGUM_EXT_TYPE_REFERENCE =
new TypeReference<>() {
};
Expand Down Expand Up @@ -116,6 +118,13 @@ private ExtImpGumgum parseImpExt(Imp imp) {

private Imp modifyImp(Imp imp, ExtImpGumgum extImp) {
final Imp.ImpBuilder impBuilder = imp.toBuilder();

final String product = extImp.getProduct();
if (StringUtils.isNotEmpty(product)) {
final ObjectNode productExt = mapper.mapper().createObjectNode().put(REQUEST_EXT_PRODUCT, product);
impBuilder.ext(productExt);
}

final Banner banner = imp.getBanner();
if (banner != null) {
final Banner resolvedBanner = resolveBanner(banner, extImp);
Expand All @@ -133,7 +142,6 @@ private Imp modifyImp(Imp imp, ExtImpGumgum extImp) {
impBuilder.video(resolvedVideo);
}
}

return impBuilder.build();
}

Expand Down Expand Up @@ -256,3 +264,4 @@ private static String resolveAdm(String bidAdm, BigDecimal price) {
return StringUtils.isNotBlank(bidAdm) ? bidAdm.replace("${AUCTION_PRICE}", String.valueOf(price)) : bidAdm;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public class ExtImpGumgum {
String irisId;

Long slot;

String product;
}
5 changes: 4 additions & 1 deletion src/main/resources/static/bidder-params/gumgum.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"slot": {
"type": "integer",
"description": "A slot id used to identify a slot placement mapped to a GumGum zone or publisher"
},
"product": {
"type": "string",
"description": "A product"
}
},
"anyOf": [
Expand All @@ -35,4 +39,3 @@
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void makeHttpRequestsShouldReturnErrorIfVideoFieldsAreNotValid() {
.imp(singletonList(Imp.builder()
.video(Video.builder().w(0).build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpGumgum.of("zone", BigInteger.TEN, "irisId", null))))
ExtImpGumgum.of("zone", BigInteger.TEN, "irisId", null, null))))
.build()))
.build();

Expand Down Expand Up @@ -124,7 +124,7 @@ public void makeHttpRequestsShouldModifyVideoExtOfIrisIdIsPresent() {
.linearity(233)
.build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpGumgum.of("zone", BigInteger.TEN, "irisId", null))))
ExtImpGumgum.of("zone", BigInteger.TEN, "irisId", null, null))))
.build()))
.build();

Expand Down Expand Up @@ -231,7 +231,7 @@ public void makeHttpRequestsShouldSetSiteIdFromLastValidImpExtZone() {
givenImp(impBuilder -> impBuilder
.banner(Banner.builder().build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpGumgum.of("ignored zone", BigInteger.TEN, "irisId", null))))),
ExtImpGumgum.of("ignored zone", BigInteger.TEN, "irisId", null, null))))),
givenImp(identity())))
.build();

Expand Down Expand Up @@ -259,14 +259,14 @@ public void makeHttpRequestsShouldNotModifyBannerExtIfSlotIsZeroOrNull() {
.format(singletonList(Format.builder().w(1).h(1).build()))
.build())
.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpGumgum.of("ignored zone",
BigInteger.TEN, "irisId", 0L))))),
BigInteger.TEN, "irisId", 0L, null))))),
givenImp(impBuilder -> impBuilder
.id("345")
.banner(Banner.builder()
.format(singletonList(Format.builder().w(1).h(1).build()))
.build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpGumgum.of("ignored zone", BigInteger.TEN, "irisId", null))))
ExtImpGumgum.of("ignored zone", BigInteger.TEN, "irisId", null, null))))
)))
.build();

Expand Down Expand Up @@ -295,7 +295,7 @@ public void makeHttpRequestsShouldSetBannerExtWithBiggestBannerFormatIfSlotIsNot
Format.builder().w(100).h(100).build()))
.build())
.ext(mapper.valueToTree(ExtPrebid.of(null, ExtImpGumgum.of("ignored zone",
BigInteger.TEN, "irisId", 42L)))));
BigInteger.TEN, "irisId", 42L, null)))));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
Expand Down Expand Up @@ -441,7 +441,7 @@ private static Imp givenImp(Function<Imp.ImpBuilder, Imp.ImpBuilder> impCustomiz
.id("123")
.banner(Banner.builder().id("banner_id").build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpGumgum.of("zone", BigInteger.TEN, "irisId", 1L)))))
ExtImpGumgum.of("zone", BigInteger.TEN, "irisId", 1L, null)))))
.build();
}

Expand All @@ -461,3 +461,4 @@ private static BidderCall<BidRequest> givenHttpCall(BidRequest bidRequest, Strin
null);
}
}

0 comments on commit 7194912

Please sign in to comment.