Skip to content

Commit 7771256

Browse files
authored
Add /openrtb2/video endpoint (prebid#514)
* start video endpoint * start video endpoint * Add some validation and basic workflow * Add core logic. * Add test for VideoRequestFactoryTest Fix tests. Get strange bug in VideoHandlerTest jdk.nashorn.internal.ir.ObjectNode$Access4JacksonSerializer199eafba': com.fasterxml.jackson.module.afterburner.ser.BeanPropertyAccessor * Add VideoHandler Unit test. Add logic to pass PodError logic (need refactor mb) Fix tests. * Finish video endpoint and clear test. * Small Fixes * fix after review * Add more test for CCPA AMP request * Update AppnexusBidder and add some category parameters. Need add test. (and start working to add categories) * Update AppnexusBidder and add test * Small code Style * remove bidVideo * After review * Pass regs to BidRequest * Refactor. Test failing... * Finish with tests * Minor changes * Minor changes * Minor changes
1 parent 3d24e92 commit 7771256

File tree

91 files changed

+3978
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3978
-301
lines changed

docs/config-app.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ Removes and downloads file again if depending service cant process probably corr
6767
- `amp.timeout-adjustment-ms` - reduces timeout value passed in Amp request so that Prebid Server can handle timeouts from adapters and respond to the AMP RTC request before it times out.
6868
- `amp.custom-targeting` - a list of bidders whose custom targeting should be included in AMP responses.
6969

70+
## Video
71+
- `auction.video.stored-required` - flag forces to merge with stored request
72+
- `auction.blacklisted-accounts` - comma separated list of blacklisted account IDs.
73+
- `auction.stored-requests-timeout-ms` - timeout for stored requests fetching.
74+
- `auction.ad-server-currency` - default currency for video auction, if its value was not specified in request. Important note: PBS uses ISO-4217 codes for the representation of currencies.
75+
7076
## Setuid
7177
- `setuid.default-timeout-ms` - default operation timeout for requests to `/setuid` endpoint.
7278

@@ -180,6 +186,7 @@ For database data source available next options:
180186
For HTTP data source available next options:
181187
- `settings.http.endpoint` - the url to fetch stored requests.
182188
- `settings.http.amp-endpoint` - the url to fetch AMP stored requests.
189+
- `settings.http.video-endpoint` - the url to fetch video stored requests.
183190

184191
For account processing rules available next options:
185192
- `settings.enforce-valid-account` - if equals to `true` then request without account id will be rejected with 401.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import com.iab.openrtb.request.App;
4+
import com.iab.openrtb.request.Content;
5+
import com.iab.openrtb.request.Device;
6+
import com.iab.openrtb.request.Regs;
7+
import com.iab.openrtb.request.Site;
8+
import lombok.Builder;
9+
import lombok.Value;
10+
import org.prebid.server.auction.PriceGranularity;
11+
12+
import java.util.List;
13+
14+
@Builder(toBuilder = true)
15+
@Value
16+
public class BidRequestVideo {
17+
18+
String storedrequestid;
19+
20+
Podconfig podconfig;
21+
22+
Site site;
23+
24+
App app;
25+
26+
VideoVideo video;
27+
28+
IncludeBrandCategory includebrandcategory;
29+
30+
Content content;
31+
32+
CacheConfig cacheconfig;
33+
34+
Integer test;
35+
36+
Long tmax;
37+
38+
List<String> bcat;
39+
40+
List<String> badv;
41+
42+
Regs regs;
43+
44+
VideoUser user;
45+
46+
Device device;
47+
48+
PriceGranularity priceGranularity;
49+
}
50+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Value;
5+
6+
@AllArgsConstructor(staticName = "of")
7+
@Value
8+
public class CacheConfig {
9+
10+
Integer ttl;
11+
}
12+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Value;
6+
7+
@AllArgsConstructor(staticName = "of")
8+
@Value
9+
public class Gdpr {
10+
11+
@JsonProperty("consentrequired")
12+
Boolean consentRequired;
13+
14+
@JsonProperty("consentstring")
15+
String consentString;
16+
}
17+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Value;
6+
7+
@AllArgsConstructor(staticName = "of")
8+
@Value
9+
public class IncludeBrandCategory {
10+
11+
@JsonProperty("primaryadserver")
12+
Integer primaryAdserver;
13+
14+
String publisher;
15+
}
16+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Value;
6+
7+
@AllArgsConstructor(staticName = "of")
8+
@Value
9+
public class Pod {
10+
11+
@JsonProperty("podid")
12+
Integer podId;
13+
14+
@JsonProperty("adpoddurationsec")
15+
Integer adpodDurationSec;
16+
17+
@JsonProperty("configid")
18+
String configId;
19+
}
20+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Value;
5+
6+
import java.util.List;
7+
8+
@AllArgsConstructor(staticName = "of")
9+
@Value
10+
public class PodError {
11+
12+
Integer podId;
13+
14+
Integer podIndex;
15+
16+
List<String> podErrors;
17+
}
18+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Builder;
5+
import lombok.Value;
6+
7+
import java.util.List;
8+
9+
@Builder(toBuilder = true)
10+
@Value
11+
public class Podconfig {
12+
13+
@JsonProperty("durationrangesec")
14+
List<Integer> durationRangeSec;
15+
16+
@JsonProperty("requireexactduration")
17+
Boolean requireExactDuration;
18+
19+
List<Pod> pods;
20+
}
21+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import lombok.Builder;
4+
import lombok.Value;
5+
6+
import java.util.Map;
7+
8+
@Builder
9+
@Value
10+
public class VideoUser {
11+
12+
Map<String, String> buyeruids;
13+
14+
/**
15+
* Year of birth as a 4-digit integer.
16+
*/
17+
Integer yob;
18+
19+
/**
20+
* Comma separated list of keywords, interests, or intent.
21+
*/
22+
String keywords;
23+
24+
/**
25+
* Gender, where “M” = male, “F” = female, “O” = known to be other (i.e.,
26+
* omitted is unknown).
27+
*/
28+
String gender;
29+
30+
Gdpr gdpr;
31+
}
32+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.iab.openrtb.request.video;
2+
3+
import lombok.Builder;
4+
import lombok.Value;
5+
6+
import java.util.List;
7+
8+
@Builder
9+
@Value
10+
public class VideoVideo {
11+
/**
12+
* Content MIME types supported (e.g., “video/x-ms-wmv”, “video/mp4”).
13+
* (required)
14+
*/
15+
List<String> mimes;
16+
17+
/**
18+
* Width of the video player in device independent pixels (DIPS).
19+
* (recommended)
20+
*/
21+
Integer w;
22+
23+
/**
24+
* Height of the video player in device independent pixels (DIPS).
25+
* (recommended)
26+
*/
27+
Integer h;
28+
29+
/**
30+
* Array of supported video protocols. Refer to List 5.8. At least one
31+
* supported protocol must be specified in either the protocol or protocols
32+
* attribute. (recommended)
33+
*/
34+
List<Integer> protocols;
35+
}
36+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.prebid.server.analytics.model;
2+
3+
import lombok.Builder;
4+
import lombok.Value;
5+
import org.prebid.server.auction.model.AuctionContext;
6+
import org.prebid.server.proto.response.VideoResponse;
7+
8+
import java.util.List;
9+
10+
/**
11+
* Represents a transaction at /openrtb2/video endpoint.
12+
*/
13+
@Builder
14+
@Value
15+
public class VideoEvent {
16+
17+
Integer status;
18+
19+
List<String> errors;
20+
21+
HttpContext httpContext;
22+
23+
AuctionContext auctionContext;
24+
25+
VideoResponse bidResponse;
26+
}
27+

src/main/java/org/prebid/server/auction/AmpRequestFactory.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,12 @@ private static ExtRequestTargeting createTargetingWithDefaults(ExtRequestPrebid
516516
final boolean includeBidderKeys = isTargetingNull || targeting.getIncludebidderkeys() == null
517517
|| targeting.getIncludebidderkeys();
518518

519-
return ExtRequestTargeting.of(outgoingPriceGranularityNode, mediaTypePriceGranularity, currency,
520-
includeWinners, includeBidderKeys);
519+
return ExtRequestTargeting.builder()
520+
.pricegranularity(outgoingPriceGranularityNode)
521+
.mediatypepricegranularity(mediaTypePriceGranularity)
522+
.currency(currency)
523+
.includewinners(includeWinners)
524+
.includebidderkeys(includeBidderKeys)
525+
.build();
521526
}
522527
}

src/main/java/org/prebid/server/auction/AuctionRequestFactory.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,16 @@ private ExtRequestTargeting targetingOrNull(ExtRequestPrebid prebid, Set<BidType
471471

472472
final ExtRequestTargeting result;
473473
if (isPriceGranularityNull || isPriceGranularityTextual || isIncludeWinnersNull || isIncludeBidderKeysNull) {
474-
result = ExtRequestTargeting.of(
475-
populatePriceGranularity(targeting, isPriceGranularityNull, isPriceGranularityTextual,
476-
impMediaTypes),
477-
targeting.getMediatypepricegranularity(),
478-
targeting.getCurrency(),
479-
isIncludeWinnersNull ? true : targeting.getIncludewinners(),
480-
isIncludeBidderKeysNull ? !isWinningOnly(prebid.getCache()) : targeting.getIncludebidderkeys());
474+
result = ExtRequestTargeting.builder()
475+
.pricegranularity(populatePriceGranularity(targeting, isPriceGranularityNull,
476+
isPriceGranularityTextual, impMediaTypes))
477+
.mediatypepricegranularity(targeting.getMediatypepricegranularity())
478+
.currency(targeting.getCurrency())
479+
.includewinners(isIncludeWinnersNull ? true : targeting.getIncludewinners())
480+
.includebidderkeys(isIncludeBidderKeysNull
481+
? !isWinningOnly(prebid.getCache())
482+
: targeting.getIncludebidderkeys())
483+
.build();
481484
} else {
482485
result = null;
483486
}

src/main/java/org/prebid/server/auction/BidResponseCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ private Bid toBid(BidderBid bidderBid, String bidder, ExtRequestTargeting target
553553
cache = null;
554554
}
555555

556-
final ExtBidPrebid prebidExt = ExtBidPrebid.of(bidType, targetingKeywords, cache, events);
556+
final ExtBidPrebid prebidExt = ExtBidPrebid.of(bidType, targetingKeywords, cache, events, null);
557557
final ExtPrebid<ExtBidPrebid, ObjectNode> bidExt = ExtPrebid.of(prebidExt, bid.getExt());
558558
bid.setExt(Json.mapper.valueToTree(bidExt));
559559

0 commit comments

Comments
 (0)