-
Notifications
You must be signed in to change notification settings - Fork 245
NextMillennium: Adapter and server version #3814
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
Changes from 2 commits
333befd
99a129e
34fad7e
961a9c8
40fdf2f
9b6a05e
249843e
97ab21e
8e6da2f
fa02a9c
95c2a5c
4ac1dc4
2225a20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,11 @@ | |
| import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; | ||
| import org.prebid.server.proto.openrtb.ext.request.ExtStoredRequest; | ||
| import org.prebid.server.proto.openrtb.ext.request.nextmillennium.ExtImpNextMillennium; | ||
| import org.prebid.server.proto.openrtb.ext.request.nextmillennium.ExtRequestNextMillennium; | ||
| import org.prebid.server.proto.openrtb.ext.response.BidType; | ||
| import org.prebid.server.util.HttpUtil; | ||
| import org.prebid.server.util.ObjectUtil; | ||
| import org.prebid.server.version.PrebidVersionProvider; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
|
|
@@ -46,15 +48,21 @@ public class NextMillenniumBidder implements Bidder<BidRequest> { | |
| new TypeReference<>() { | ||
| }; | ||
|
|
||
| private static final String NM_ADAPTER_VERSION = "v1.0.0"; | ||
|
|
||
| private final String endpointUrl; | ||
| private final JacksonMapper mapper; | ||
| private final List<String> nmmFlags; | ||
| private final PrebidVersionProvider versionProvider; | ||
|
|
||
| public NextMillenniumBidder(String endpointUrl, JacksonMapper mapper, List<String> nmmFlags) { | ||
| public NextMillenniumBidder(String endpointUrl, | ||
| JacksonMapper mapper, | ||
| List<String> nmmFlags, | ||
| PrebidVersionProvider versionProvider) { | ||
|
CTMBNara marked this conversation as resolved.
|
||
| this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); | ||
| this.mapper = Objects.requireNonNull(mapper); | ||
| this.nmmFlags = nmmFlags; | ||
|
|
||
| this.versionProvider = Objects.requireNonNull(versionProvider); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -97,16 +105,17 @@ private BidRequest updateBidRequest(BidRequest bidRequest, ExtImpNextMillennium | |
| .map(prebid -> prebid.toBuilder().storedrequest(storedRequest).build()) | ||
| .orElse(createdExtRequestPrebid); | ||
|
|
||
| return bidRequest.toBuilder() | ||
| .imp(updateImps(bidRequest, createdExtRequestPrebid)) | ||
| .ext(ExtRequest.of(extRequestPrebid)) | ||
| final ExtRequestPrebid updatedExt = extRequestPrebid.toBuilder() | ||
| .nextMillennium(ExtRequestNextMillennium.of( | ||
| nmmFlags, | ||
| NM_ADAPTER_VERSION, | ||
| versionProvider.getNameVersionRecord())) | ||
| .build(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Go they don't update |
||
| } | ||
|
|
||
| private List<Imp> updateImps(BidRequest bidRequest, ExtRequestPrebid extRequestPrebid) { | ||
| return bidRequest.getImp().stream() | ||
| .map(imp -> imp.toBuilder().ext(createImpExt(extRequestPrebid)).build()) | ||
| .toList(); | ||
| return bidRequest.toBuilder() | ||
| .imp(bidRequest.getImp()) | ||
| .ext(ExtRequest.of(updatedExt)) | ||
| .build(); | ||
|
Comment on lines
+115
to
+113
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| private static String resolveStoredRequestId(BidRequest bidRequest, ExtImpNextMillennium extImpNextMillennium) { | ||
|
|
@@ -146,16 +155,6 @@ private static String formatSize(Integer w, Integer h) { | |
| : null; | ||
| } | ||
|
|
||
| private ObjectNode createImpExt(ExtRequestPrebid prebid) { | ||
| final ObjectNode impExt = mapper.mapper().createObjectNode(); | ||
| impExt.set("prebid", mapper.mapper().valueToTree(prebid)); | ||
| if (CollectionUtils.isNotEmpty(nmmFlags)) { | ||
| impExt.putObject("nextMillennium") | ||
| .set("nmmFlags", mapper.mapper().valueToTree(nmmFlags)); | ||
| } | ||
| return impExt; | ||
| } | ||
|
|
||
| private HttpRequest<BidRequest> makeHttpRequest(BidRequest bidRequest) { | ||
| return HttpRequest.<BidRequest>builder() | ||
| .method(HttpMethod.POST) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import org.prebid.server.auction.model.PaaFormat; | ||
| import org.prebid.server.floors.model.PriceFloorRules; | ||
| import org.prebid.server.json.deserializer.IntegerFlagDeserializer; | ||
| import org.prebid.server.proto.openrtb.ext.request.nextmillennium.ExtRequestNextMillennium; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -190,4 +191,9 @@ public class ExtRequestPrebid { | |
| */ | ||
| @JsonProperty("paaformat") | ||
| PaaFormat paaFormat; | ||
|
|
||
| /** | ||
| * Defines the contract for bidrequest.ext.prebid.nextMillennium | ||
| */ | ||
| ExtRequestNextMillennium nextMillennium; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deserialization is incorrect here |
||
| } | ||
|
CTMBNara marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.prebid.server.proto.openrtb.ext.request.nextmillennium; | ||
|
|
||
| import lombok.Value; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Value(staticConstructor = "of") | ||
| public class ExtRequestNextMillennium { | ||
|
|
||
| List<String> nmmFlags; | ||
|
CTMBNara marked this conversation as resolved.
Outdated
|
||
|
|
||
| String nmVersion; | ||
|
|
||
| String serverVersion; | ||
| } | ||
|
CTMBNara marked this conversation as resolved.
|
|
CTMBNara marked this conversation as resolved.
|
Uh oh!
There was an error while loading. Please reload this page.