-
Notifications
You must be signed in to change notification settings - Fork 220
Unruly: Include GPID in request payload #4259
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
Open
zxPhoenix
wants to merge
1
commit into
prebid:master
Choose a base branch
from
zxPhoenix:unruly-support-gpid
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+64
−7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comment on lines
37
to
75
| private static final TypeReference<UnrulyExtImp<?, ExtImpUnruly>> UNRULY_EXT_TYPE_REFERENCE = | ||
| new TypeReference<>() { | ||
| }; | ||
|
|
||
| private final String endpointUrl; | ||
| private final JacksonMapper mapper; | ||
|
|
||
| public UnrulyBidder(String endpointUrl, JacksonMapper mapper) { | ||
| this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); | ||
| this.mapper = Objects.requireNonNull(mapper); | ||
| } | ||
|
|
||
| @Override | ||
| public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest request) { | ||
| final List<HttpRequest<BidRequest>> httpRequests = request.getImp().stream() | ||
| .map(this::modifyImp) | ||
| .map(imp -> createSingleRequest(imp, request)) | ||
| .toList(); | ||
|
|
||
| return Result.withValues(httpRequests); | ||
| } | ||
|
|
||
| private Imp modifyImp(Imp imp) { | ||
|
|
||
| final UnrulyExtImp<?, ExtImpUnruly> unrulyExtImp = parseImpExt(imp); | ||
| return imp.toBuilder() | ||
| .ext(mapper.mapper().valueToTree(ExtPrebid.of(null, parseImpExt(imp)))) | ||
| .ext(mapper.mapper().valueToTree(UnrulyExtImp.of( | ||
| null, | ||
| unrulyExtImp.getBidder(), | ||
| unrulyExtImp.getGpid()))) | ||
| .build(); | ||
| } | ||
|
|
||
| private ExtImpUnruly parseImpExt(Imp imp) { | ||
| private UnrulyExtImp<?, ExtImpUnruly> parseImpExt(Imp imp) { | ||
| try { | ||
| return mapper.mapper().convertValue(imp.getExt(), UNRULY_EXT_TYPE_REFERENCE).getBidder(); | ||
| return mapper.mapper().convertValue(imp.getExt(), UNRULY_EXT_TYPE_REFERENCE); | ||
| } catch (IllegalArgumentException e) { | ||
| throw new PreBidException(e.getMessage()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the bidder has to parse the imp.ext while it should be passing through as-is, so I suggest the following approach
@Override
public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest request) {
final List<HttpRequest<BidRequest>> httpRequests = request.getImp().stream()
.map(this::modifyImp)
.map(imp -> createSingleRequest(imp, request))
.toList();
return Result.withValues(httpRequests);
}
private Imp modifyImp(Imp imp) {
final ObjectNode impExt = imp.getExt();
final ObjectNode modifiedImpExt = mapper.mapper().createObjectNode();
modifiedImpExt.set("bidder", impExt.get("bidder"));
modifiedImpExt.set("gpid", impExt.get("gpid"));
return imp.toBuilder().ext(modifiedImpExt).build();
}
private HttpRequest<BidRequest> createSingleRequest(Imp imp, BidRequest request) {
final BidRequest outgoingRequest = request.toBuilder().imp(Collections.singletonList(imp)).build();
return BidderUtil.defaultRequest(outgoingRequest, endpointUrl, mapper);
}Also don't forget to clean up unused constants and classes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔧 Type of changes
✨ What's the context?
Make Unruly's PBS adapter sending the GPID to the Unruly endpoint. [Issue #4252]
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
Unit tests are updated
Manual testing is done
🏎 Quality check