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

Kobler: New adapter (#3667) #3684

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

przemkaczmarek
Copy link
Collaborator

🔧 Type of changes

  • new bid adapter

✨ What's the context?

#3667

@Net-burst Net-burst linked an issue Jan 21, 2025 that may be closed by this pull request
try {
final ExtImpKobler impExt = parseImpExt(imp);

if (bidRequest.getImp().indexOf(imp) == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't use indexOf, it spends unnecessary execution time to check each imp

}

final Imp modifiedImp = modifyImp(imp, impExt, bidRequest);
requests.add(makeHttpRequest(bidRequest, modifiedImp, testMode));
Copy link
Collaborator

Choose a reason for hiding this comment

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

the bidder should send only a single request with all the imps instead of a request per imp

return imp.toBuilder()
.bidfloor(resolvedBidFloor.getValue())
.bidfloorcur(resolvedBidFloor.getCurrency())
.ext(mapper.mapper().valueToTree(extImpKobler))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see imp.ext change in Go


for (Imp imp : bidRequest.getImp()) {
try {
final ExtImpKobler impExt = parseImpExt(imp);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't need to parse imp.ext if it's not the first imp

return bidsFromResponse(bidResponse, errors);
}

private List<BidderBid> bidsFromResponse(BidResponse bidResponse, List<BidderError> errors) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

the errors list is redundant

Comment on lines 155 to 163
private BidType getBidType(Bid bid) {
final Integer markupType = ObjectUtils.defaultIfNull(bid.getMtype(), 0);

return switch (markupType) {
case 1 -> BidType.banner;
default -> throw new PreBidException(
"could not define media type for impression: " + bid.getImpid());
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's just not how it works in Go

@@ -0,0 +1,12 @@
adapters:
kobler:
endpoint: "https://bid.essrtb.com/bid/prebid_server_rtb_call"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the endpoint-compression is missed

Comment on lines +32 to +35
BidderDeps koblerBidderDeps(BidderConfigurationProperties koblerConfigurationProperties,
CurrencyConversionService currencyConversionService,
@NotBlank @Value("${external-url}") String externalUrl,
JacksonMapper mapper) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation is bad

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used a checkstyle and it didnt show mistakes. How it should looks like?

final ExtImpKobler impExt = parseImpExt(imp);

if (bidRequest.getImp().indexOf(imp) == 0) {
testMode = impExt.getTest();
Copy link
Collaborator

Choose a reason for hiding this comment

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

NPE will be thrown if imp.ext.test is NULL

Copy link
Collaborator

@AntoxaAntoxic AntoxaAntoxic left a comment

Choose a reason for hiding this comment

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

Ping me when you finish addressing the comments, probably this time I commented too early

boolean testMode = false;
final List<Imp> modifiedImps = new ArrayList<>();

final List<String> currencies = bidRequest.getCur() != null
Copy link
Collaborator

Choose a reason for hiding this comment

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

bidRequest.getCur() can't be null

return Result.withErrors(errors);
}

modifiedRequest = modifiedRequest.toBuilder().imp(modifiedImps).build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

please modify the request once

Comment on lines +112 to +135
private Imp processImp(BidRequest bidRequest, Imp imp, List<BidderError> errors) {
if (imp.getBidfloor() != null
&& imp.getBidfloor().compareTo(BigDecimal.ZERO) > 0
&& imp.getBidfloorcur() != null) {
final String bidFloorCur = imp.getBidfloorcur().toUpperCase();
if (!DEFAULT_BID_CURRENCY.equals(bidFloorCur)) {
try {
final BigDecimal convertedPrice = currencyConversionService.convertCurrency(
imp.getBidfloor(),
bidRequest,
bidFloorCur,
DEFAULT_BID_CURRENCY
);
return imp.toBuilder()
.bidfloor(convertedPrice)
.bidfloorcur(DEFAULT_BID_CURRENCY)
.build();
} catch (PreBidException e) {
errors.add(BidderError.badInput(e.getMessage()));
}
}
}
return imp;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did you change the whole code here? the last time it was better

return imp;
}

public boolean extractTestMode(Imp imp) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why public?

Comment on lines +79 to +81
if (modifiedImps.size() == 1) {
testMode = extractTestMode(processedImp);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

the Go version tries to retrieve the test field only from the first imp, in your implementation it's taken from the first VALID imp

try {
final ExtPrebid<?, ExtImpKobler> extPrebid = mapper.mapper().convertValue(imp.getExt(),
KOBLER_EXT_TYPE_REFERENCE);
final ExtImpKobler extImpKobler = extPrebid != null ? extPrebid.getBidder() : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

parse the imp.ext in the same way you did before, please make it in the same style other bidders do

Comment on lines +96 to +109
try {
return Result.of(Collections.singletonList(
HttpRequest.<BidRequest>builder()
.method(HttpMethod.POST)
.uri(endpoint)
.headers(HttpUtil.headers())
.body(mapper.encodeToBytes(modifiedRequest))
.payload(modifiedRequest)
.build()
), errors);
} catch (EncodeException e) {
errors.add(BidderError.badInput("Failed to encode request: " + e.getMessage()));
return Result.withErrors(errors);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

use BidderUtil.defaultRequest instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port PR from PBS-Go: New Adapter: Kobler
3 participants