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

Commit

Permalink
Adding support for deal prefixes (prebid#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
camrice authored Feb 26, 2020
1 parent e0f5b70 commit 74656fa
Show file tree
Hide file tree
Showing 19 changed files with 442 additions and 58 deletions.
8 changes: 5 additions & 3 deletions adapters/appnexus/appnexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type appnexusBidExtAppnexus struct {
BrandId int `json:"brand_id"`
BrandCategory int `json:"brand_category_id"`
CreativeInfo appnexusBidExtCreative `json:"creative_info"`
DealPriority int `json:"deal_priority"`
}

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

bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: bidType,
BidVideo: impVideo,
Bid: &bid,
BidType: bidType,
BidVideo: impVideo,
DealPriority: bidExt.Appnexus.DealPriority,
})
} else {
errs = append(errs, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -118,7 +119,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -118,7 +119,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions adapters/appnexus/appnexustest/amp/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -129,7 +130,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions adapters/appnexus/appnexustest/amp/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -120,7 +121,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions adapters/appnexus/appnexustest/exemplary/native-1.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"brand_category_id": 350,
"auction_id": 5607483846416358664,
"bidder_id": 2,
"bid_ad_type": 3
"bid_ad_type": 3,
"deal_priority": 5
}
}
}
Expand Down Expand Up @@ -136,7 +137,8 @@
"brand_category_id": 350,
"auction_id": 5607483846416358664,
"bidder_id": 2,
"bid_ad_type": 3
"bid_ad_type": 3,
"deal_priority": 5
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions adapters/appnexus/appnexustest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -127,7 +128,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions adapters/appnexus/appnexustest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -118,7 +119,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -116,7 +117,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 1,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -144,7 +145,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
12 changes: 8 additions & 4 deletions adapters/appnexus/appnexustest/supplemental/multi-bid.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 4
}
}
},
Expand All @@ -112,7 +113,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
}]
Expand Down Expand Up @@ -150,7 +152,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 4
}
}
},
Expand All @@ -177,7 +180,8 @@
"auction_id": 8189378542222915032,
"bid_ad_type": 0,
"bidder_id": 2,
"ranking_price": 0.000000
"ranking_price": 0.000000,
"deal_priority": 5
}
}
},
Expand Down
8 changes: 5 additions & 3 deletions adapters/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ func NewBidderResponse() *BidderResponse {
// TypedBid.Bid.Ext will become "response.seatbid[i].bid.ext.bidder" in the final OpenRTB response.
// TypedBid.BidType will become "response.seatbid[i].bid.ext.prebid.type" in the final OpenRTB response.
// TypedBid.BidVideo will become "response.seatbid[i].bid.ext.prebid.video" in the final OpenRTB response.
// TypedBid.DealPriority will become "response.seatbid[i].bid.dealPriority" in the final OpenRTB response.
type TypedBid struct {
Bid *openrtb.Bid
BidType openrtb_ext.BidType
BidVideo *openrtb_ext.ExtBidPrebidVideo
Bid *openrtb.Bid
BidType openrtb_ext.BidType
BidVideo *openrtb_ext.ExtBidPrebidVideo
DealPriority int
}

// RequestData and ResponseData exist so that prebid-server core code can implement its "debug" functionality
Expand Down
5 changes: 3 additions & 2 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,9 @@ func createBidExtension(videoRequest *openrtb_ext.BidRequestVideo) ([]byte, erro
}

prebid := openrtb_ext.ExtRequestPrebid{
Cache: &cache,
Targeting: &targeting,
Cache: &cache,
Targeting: &targeting,
SupportDeals: videoRequest.SupportDeals,
}
extReq := openrtb_ext.ExtRequest{Prebid: prebid}

Expand Down
17 changes: 10 additions & 7 deletions exchange/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ type adaptedBidder interface {
// pbsOrtbBid.bidType will become "response.seatbid[i].bid.ext.prebid.type" in the final OpenRTB response.
// pbsOrtbBid.bidTargets does not need to be filled out by the Bidder. It will be set later by the exchange.
// pbsOrtbBid.bidVideo is optional but should be filled out by the Bidder if bidType is video.
// pbsOrtbBid.dealPriority will become "response.seatbid[i].bid.dealPriority" in the final OpenRTB response.
type pbsOrtbBid struct {
bid *openrtb.Bid
bidType openrtb_ext.BidType
bidTargets map[string]string
bidVideo *openrtb_ext.ExtBidPrebidVideo
bid *openrtb.Bid
bidType openrtb_ext.BidType
bidTargets map[string]string
bidVideo *openrtb_ext.ExtBidPrebidVideo
dealPriority int
}

// pbsOrtbSeatBid is a SeatBid returned by an adaptedBidder.
Expand Down Expand Up @@ -183,9 +185,10 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi
bidResponse.Bids[i].Bid.Price = bidResponse.Bids[i].Bid.Price * bidAdjustment * conversionRate
}
seatBid.bids = append(seatBid.bids, &pbsOrtbBid{
bid: bidResponse.Bids[i].Bid,
bidType: bidResponse.Bids[i].BidType,
bidVideo: bidResponse.Bids[i].BidVideo,
bid: bidResponse.Bids[i].Bid,
bidType: bidResponse.Bids[i].BidType,
bidVideo: bidResponse.Bids[i].BidVideo,
dealPriority: bidResponse.Bids[i].DealPriority,
})
}
} else {
Expand Down
9 changes: 7 additions & 2 deletions exchange/bidder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ func TestSingleBidder(t *testing.T) {
Bid: &openrtb.Bid{
Price: firstInitialPrice,
},
BidType: openrtb_ext.BidTypeBanner,
BidType: openrtb_ext.BidTypeBanner,
DealPriority: 4,
},
{
Bid: &openrtb.Bid{
Price: secondInitialPrice,
},
BidType: openrtb_ext.BidTypeVideo,
BidType: openrtb_ext.BidTypeVideo,
DealPriority: 5,
},
},
}
Expand Down Expand Up @@ -88,6 +90,9 @@ func TestSingleBidder(t *testing.T) {
if typedBid.BidType != seatBid.bids[index].bidType {
t.Errorf("Bid %d did not have the right type. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType)
}
if typedBid.DealPriority != seatBid.bids[index].dealPriority {
t.Errorf("Bid %d did not have the right deal priority. Expected %s, got %s", index, typedBid.BidType, seatBid.bids[index].bidType)
}
}
if mockBidderResponse.Bids[0].Bid.Price != bidAdjustment*firstInitialPrice {
t.Errorf("Bid[0].Price was not adjusted properly. Expected %f, got %f", bidAdjustment*firstInitialPrice, mockBidderResponse.Bids[0].Bid.Price)
Expand Down
Loading

0 comments on commit 74656fa

Please sign in to comment.