Skip to content
This repository was archived by the owner on Dec 22, 2022. It is now read-only.

Commit 1c3ded0

Browse files
authored
Adding support for deal prefixes (prebid#1183)
1 parent 417d47f commit 1c3ded0

19 files changed

+442
-58
lines changed

adapters/appnexus/appnexus.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type appnexusBidExtAppnexus struct {
8787
BrandId int `json:"brand_id"`
8888
BrandCategory int `json:"brand_category_id"`
8989
CreativeInfo appnexusBidExtCreative `json:"creative_info"`
90+
DealPriority int `json:"deal_priority"`
9091
}
9192

9293
type appnexusBidExt struct {
@@ -543,9 +544,10 @@ func (a *AppNexusAdapter) MakeBids(internalRequest *openrtb.BidRequest, external
543544
}
544545

545546
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
546-
Bid: &bid,
547-
BidType: bidType,
548-
BidVideo: impVideo,
547+
Bid: &bid,
548+
BidType: bidType,
549+
BidVideo: impVideo,
550+
DealPriority: bidExt.Appnexus.DealPriority,
549551
})
550552
} else {
551553
errs = append(errs, err)

adapters/appnexus/appnexusplatformtest/exemplary/simple-auction.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"auction_id": 8189378542222915032,
8181
"bid_ad_type": 1,
8282
"bidder_id": 2,
83-
"ranking_price": 0.000000
83+
"ranking_price": 0.000000,
84+
"deal_priority": 5
8485
}
8586
}
8687
}]
@@ -118,7 +119,8 @@
118119
"auction_id": 8189378542222915032,
119120
"bid_ad_type": 1,
120121
"bidder_id": 2,
121-
"ranking_price": 0.000000
122+
"ranking_price": 0.000000,
123+
"deal_priority": 5
122124
}
123125
}
124126
},

adapters/appnexus/appnexusplatformtest/video/simple-video.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"auction_id": 8189378542222915032,
8181
"bid_ad_type": 1,
8282
"bidder_id": 2,
83-
"ranking_price": 0.000000
83+
"ranking_price": 0.000000,
84+
"deal_priority": 5
8485
}
8586
}
8687
}]
@@ -118,7 +119,8 @@
118119
"auction_id": 8189378542222915032,
119120
"bid_ad_type": 1,
120121
"bidder_id": 2,
121-
"ranking_price": 0.000000
122+
"ranking_price": 0.000000,
123+
"deal_priority": 5
122124
}
123125
}
124126
},

adapters/appnexus/appnexustest/amp/simple-banner.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
"auction_id": 8189378542222915032,
9292
"bid_ad_type": 0,
9393
"bidder_id": 2,
94-
"ranking_price": 0.000000
94+
"ranking_price": 0.000000,
95+
"deal_priority": 5
9596
}
9697
}
9798
}]
@@ -129,7 +130,8 @@
129130
"auction_id": 8189378542222915032,
130131
"bid_ad_type": 0,
131132
"bidder_id": 2,
132-
"ranking_price": 0.000000
133+
"ranking_price": 0.000000,
134+
"deal_priority": 5
133135
}
134136
}
135137
},

adapters/appnexus/appnexustest/amp/simple-video.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"auction_id": 8189378542222915032,
8383
"bid_ad_type": 1,
8484
"bidder_id": 2,
85-
"ranking_price": 0.000000
85+
"ranking_price": 0.000000,
86+
"deal_priority": 5
8687
}
8788
}
8889
}]
@@ -120,7 +121,8 @@
120121
"auction_id": 8189378542222915032,
121122
"bid_ad_type": 1,
122123
"bidder_id": 2,
123-
"ranking_price": 0.000000
124+
"ranking_price": 0.000000,
125+
"deal_priority": 5
124126
}
125127
}
126128
},

adapters/appnexus/appnexustest/exemplary/native-1.1.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@
9696
"brand_category_id": 350,
9797
"auction_id": 5607483846416358664,
9898
"bidder_id": 2,
99-
"bid_ad_type": 3
99+
"bid_ad_type": 3,
100+
"deal_priority": 5
100101
}
101102
}
102103
}
@@ -136,7 +137,8 @@
136137
"brand_category_id": 350,
137138
"auction_id": 5607483846416358664,
138139
"bidder_id": 2,
139-
"bid_ad_type": 3
140+
"bid_ad_type": 3,
141+
"deal_priority": 5
140142
}
141143
}
142144
},

adapters/appnexus/appnexustest/exemplary/simple-banner.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
"auction_id": 8189378542222915032,
9090
"bid_ad_type": 0,
9191
"bidder_id": 2,
92-
"ranking_price": 0.000000
92+
"ranking_price": 0.000000,
93+
"deal_priority": 5
9394
}
9495
}
9596
}]
@@ -127,7 +128,8 @@
127128
"auction_id": 8189378542222915032,
128129
"bid_ad_type": 0,
129130
"bidder_id": 2,
130-
"ranking_price": 0.000000
131+
"ranking_price": 0.000000,
132+
"deal_priority": 5
131133
}
132134
}
133135
},

adapters/appnexus/appnexustest/exemplary/simple-video.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"auction_id": 8189378542222915032,
8181
"bid_ad_type": 1,
8282
"bidder_id": 2,
83-
"ranking_price": 0.000000
83+
"ranking_price": 0.000000,
84+
"deal_priority": 5
8485
}
8586
}
8687
}]
@@ -118,7 +119,8 @@
118119
"auction_id": 8189378542222915032,
119120
"bid_ad_type": 1,
120121
"bidder_id": 2,
121-
"ranking_price": 0.000000
122+
"ranking_price": 0.000000,
123+
"deal_priority": 5
122124
}
123125
}
124126
},

adapters/appnexus/appnexustest/exemplary/video-invalid-category.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
"auction_id": 8189378542222915032,
8080
"bid_ad_type": 1,
8181
"bidder_id": 2,
82-
"ranking_price": 0.000000
82+
"ranking_price": 0.000000,
83+
"deal_priority": 5
8384
}
8485
}
8586
}]
@@ -116,7 +117,8 @@
116117
"auction_id": 8189378542222915032,
117118
"bid_ad_type": 1,
118119
"bidder_id": 2,
119-
"ranking_price": 0.000000
120+
"ranking_price": 0.000000,
121+
"deal_priority": 5
120122
}
121123
}
122124
},

adapters/appnexus/appnexustest/supplemental/displaymanager-test.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
"auction_id": 8189378542222915032,
107107
"bid_ad_type": 0,
108108
"bidder_id": 2,
109-
"ranking_price": 0.000000
109+
"ranking_price": 0.000000,
110+
"deal_priority": 5
110111
}
111112
}
112113
}]
@@ -144,7 +145,8 @@
144145
"auction_id": 8189378542222915032,
145146
"bid_ad_type": 0,
146147
"bidder_id": 2,
147-
"ranking_price": 0.000000
148+
"ranking_price": 0.000000,
149+
"deal_priority": 5
148150
}
149151
}
150152
},

adapters/appnexus/appnexustest/supplemental/multi-bid.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
"auction_id": 8189378542222915032,
9090
"bid_ad_type": 0,
9191
"bidder_id": 2,
92-
"ranking_price": 0.000000
92+
"ranking_price": 0.000000,
93+
"deal_priority": 4
9394
}
9495
}
9596
},
@@ -112,7 +113,8 @@
112113
"auction_id": 8189378542222915032,
113114
"bid_ad_type": 0,
114115
"bidder_id": 2,
115-
"ranking_price": 0.000000
116+
"ranking_price": 0.000000,
117+
"deal_priority": 5
116118
}
117119
}
118120
}]
@@ -150,7 +152,8 @@
150152
"auction_id": 8189378542222915032,
151153
"bid_ad_type": 0,
152154
"bidder_id": 2,
153-
"ranking_price": 0.000000
155+
"ranking_price": 0.000000,
156+
"deal_priority": 4
154157
}
155158
}
156159
},
@@ -177,7 +180,8 @@
177180
"auction_id": 8189378542222915032,
178181
"bid_ad_type": 0,
179182
"bidder_id": 2,
180-
"ranking_price": 0.000000
183+
"ranking_price": 0.000000,
184+
"deal_priority": 5
181185
}
182186
}
183187
},

adapters/bidder.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ func NewBidderResponse() *BidderResponse {
108108
// TypedBid.Bid.Ext will become "response.seatbid[i].bid.ext.bidder" in the final OpenRTB response.
109109
// TypedBid.BidType will become "response.seatbid[i].bid.ext.prebid.type" in the final OpenRTB response.
110110
// TypedBid.BidVideo will become "response.seatbid[i].bid.ext.prebid.video" in the final OpenRTB response.
111+
// TypedBid.DealPriority will become "response.seatbid[i].bid.dealPriority" in the final OpenRTB response.
111112
type TypedBid struct {
112-
Bid *openrtb.Bid
113-
BidType openrtb_ext.BidType
114-
BidVideo *openrtb_ext.ExtBidPrebidVideo
113+
Bid *openrtb.Bid
114+
BidType openrtb_ext.BidType
115+
BidVideo *openrtb_ext.ExtBidPrebidVideo
116+
DealPriority int
115117
}
116118

117119
// RequestData and ResponseData exist so that prebid-server core code can implement its "debug" functionality

endpoints/openrtb2/video_auction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,9 @@ func createBidExtension(videoRequest *openrtb_ext.BidRequestVideo) ([]byte, erro
550550
}
551551

552552
prebid := openrtb_ext.ExtRequestPrebid{
553-
Cache: &cache,
554-
Targeting: &targeting,
553+
Cache: &cache,
554+
Targeting: &targeting,
555+
SupportDeals: videoRequest.SupportDeals,
555556
}
556557
extReq := openrtb_ext.ExtRequest{Prebid: prebid}
557558

exchange/bidder.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ type adaptedBidder interface {
5151
// pbsOrtbBid.bidType will become "response.seatbid[i].bid.ext.prebid.type" in the final OpenRTB response.
5252
// pbsOrtbBid.bidTargets does not need to be filled out by the Bidder. It will be set later by the exchange.
5353
// pbsOrtbBid.bidVideo is optional but should be filled out by the Bidder if bidType is video.
54+
// pbsOrtbBid.dealPriority will become "response.seatbid[i].bid.dealPriority" in the final OpenRTB response.
5455
type pbsOrtbBid struct {
55-
bid *openrtb.Bid
56-
bidType openrtb_ext.BidType
57-
bidTargets map[string]string
58-
bidVideo *openrtb_ext.ExtBidPrebidVideo
56+
bid *openrtb.Bid
57+
bidType openrtb_ext.BidType
58+
bidTargets map[string]string
59+
bidVideo *openrtb_ext.ExtBidPrebidVideo
60+
dealPriority int
5961
}
6062

6163
// pbsOrtbSeatBid is a SeatBid returned by an adaptedBidder.
@@ -183,9 +185,10 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi
183185
bidResponse.Bids[i].Bid.Price = bidResponse.Bids[i].Bid.Price * bidAdjustment * conversionRate
184186
}
185187
seatBid.bids = append(seatBid.bids, &pbsOrtbBid{
186-
bid: bidResponse.Bids[i].Bid,
187-
bidType: bidResponse.Bids[i].BidType,
188-
bidVideo: bidResponse.Bids[i].BidVideo,
188+
bid: bidResponse.Bids[i].Bid,
189+
bidType: bidResponse.Bids[i].BidType,
190+
bidVideo: bidResponse.Bids[i].BidVideo,
191+
dealPriority: bidResponse.Bids[i].DealPriority,
189192
})
190193
}
191194
} else {

exchange/bidder_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ func TestSingleBidder(t *testing.T) {
3939
Bid: &openrtb.Bid{
4040
Price: firstInitialPrice,
4141
},
42-
BidType: openrtb_ext.BidTypeBanner,
42+
BidType: openrtb_ext.BidTypeBanner,
43+
DealPriority: 4,
4344
},
4445
{
4546
Bid: &openrtb.Bid{
4647
Price: secondInitialPrice,
4748
},
48-
BidType: openrtb_ext.BidTypeVideo,
49+
BidType: openrtb_ext.BidTypeVideo,
50+
DealPriority: 5,
4951
},
5052
},
5153
}
@@ -88,6 +90,9 @@ func TestSingleBidder(t *testing.T) {
8890
if typedBid.BidType != seatBid.bids[index].bidType {
8991
t.Errorf("Bid %d did not have the right type. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType)
9092
}
93+
if typedBid.DealPriority != seatBid.bids[index].dealPriority {
94+
t.Errorf("Bid %d did not have the right deal priority. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType)
95+
}
9196
}
9297
if mockBidderResponse.Bids[0].Bid.Price != bidAdjustment*firstInitialPrice {
9398
t.Errorf("Bid[0].Price was not adjusted properly. Expected %f, got %f", bidAdjustment*firstInitialPrice, mockBidderResponse.Bids[0].Bid.Price)

0 commit comments

Comments
 (0)