Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -53,6 +53,7 @@ public class ConnatixBidder implements Bidder<BidRequest> {

private static final String BIDDER_CURRENCY = "USD";
private static final String FORMATTING = "%s-%s";
private static final String GPID_KEY = "gpid";

private final String endpointUrl;
private final JacksonMapper mapper;
Expand Down Expand Up @@ -173,6 +174,11 @@ private Imp modifyImp(Imp imp, ExtImpConnatix extImpConnatix, String displayMana
final ObjectNode impExt = mapper.mapper()
.createObjectNode().set("connatix", mapper.mapper().valueToTree(extImpConnatix));

Optional.ofNullable(imp.getExt())
.map(ext -> ext.get(GPID_KEY))
.filter(JsonNode::isTextual)
.ifPresent(gpidNode -> impExt.set(GPID_KEY, gpidNode));

return imp.toBuilder()
.ext(impExt)
.banner(modifyImpBanner(imp.getBanner()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,33 @@ public void makeHttpRequestsShouldExcludeDataCenterWhenUserIdIsMissing() {
assertThat(result.getValue()).extracting(HttpRequest::getUri).containsOnly(CONNATIX_ENDPOINT);
}

@Test
public void makeHttpRequestsShouldIncludeGpidWhenPresent() {
// given
final ObjectNode impExt = mapper.createObjectNode();
impExt.set("bidder", mapper.valueToTree(ExtImpConnatix.of("placementId", null)));
impExt.put("gpid", "test-gpid");

final BidRequest bidRequest = givenBidRequest(
UnaryOperator.identity(),
givenImp(impBuilder -> impBuilder.ext(impExt)));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
final ObjectNode expectedExt = mapper.createObjectNode();
expectedExt.set("connatix", mapper.valueToTree(ExtImpConnatix.of("placementId", null)));
expectedExt.put("gpid", "test-gpid");

assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt)
.containsExactly(expectedExt);
}

@Test
public void makeBidsShouldErrorIfResponseBodyCannotBeParsed() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"ext": {
"connatix": {
"placementId": "some-placement-id"
}
},
"gpid": "test-gpid"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"ext": {
"connatix": {
"placementId": "some-placement-id"
}
},
"gpid": "test-gpid"
}
}
],
Expand Down
Loading