diff --git a/endpoints/openrtb2/video_auction_test.go b/endpoints/openrtb2/video_auction_test.go index 33411c87555..66a3bd6775b 100644 --- a/endpoints/openrtb2/video_auction_test.go +++ b/endpoints/openrtb2/video_auction_test.go @@ -1351,7 +1351,7 @@ func (m *mockExchangeVideo) HoldAuction(ctx context.Context, bidRequest *openrtb if debugLog != nil && debugLog.Enabled { m.cache.called = true } - ext := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"20.00","hb_pb_cat_dur_appnex":"20.00_395_30s","hb_size":"1x1", "hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"},"type":"video"},"bidder":{"appnexus":{"brand_id":1,"auction_id":7840037870526938650,"bidder_id":2,"bid_ad_type":1,"creative_info":{"video":{"duration":30,"mimes":["video\/mp4"]}}}}}`) + ext := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"20.00","hb_pb_cat_dur_appnex":"20.00_395_30s","hb_size":"1x1", "hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"},"type":"video","dealpriority":0,"dealtiersatisfied":false},"bidder":{"appnexus":{"brand_id":1,"auction_id":7840037870526938650,"bidder_id":2,"bid_ad_type":1,"creative_info":{"video":{"duration":30,"mimes":["video\/mp4"]}}}}}`) return &openrtb.BidResponse{ SeatBid: []openrtb.SeatBid{{ Seat: "appnexus", diff --git a/exchange/bidder.go b/exchange/bidder.go index 5924e39b031..a230041de87 100644 --- a/exchange/bidder.go +++ b/exchange/bidder.go @@ -58,12 +58,14 @@ type adaptedBidder interface { // 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 is optionally provided by adapters and used internally by the exchange to support deal targeted campaigns. +// pbsOrtbBid.dealTierSatisfied is set to true by exchange.updateHbPbCatDur if deal tier satisfied otherwise it will be set to false type pbsOrtbBid struct { - bid *openrtb.Bid - bidType openrtb_ext.BidType - bidTargets map[string]string - bidVideo *openrtb_ext.ExtBidPrebidVideo - dealPriority int + bid *openrtb.Bid + bidType openrtb_ext.BidType + bidTargets map[string]string + bidVideo *openrtb_ext.ExtBidPrebidVideo + dealPriority int + dealTierSatisfied bool } // pbsOrtbSeatBid is a SeatBid returned by an adaptedBidder. diff --git a/exchange/exchange.go b/exchange/exchange.go index c1acc0d5353..2e8fe76fcfa 100644 --- a/exchange/exchange.go +++ b/exchange/exchange.go @@ -281,6 +281,7 @@ func validateDealTier(dealTier openrtb_ext.DealTier) bool { func updateHbPbCatDur(bid *pbsOrtbBid, dealTier openrtb_ext.DealTier, bidCategory map[string]string) { if bid.dealPriority >= dealTier.MinDealTier { prefixTier := fmt.Sprintf("%s%d_", dealTier.Prefix, bid.dealPriority) + bid.dealTierSatisfied = true if oldCatDur, ok := bidCategory[bid.bid.ID]; ok { oldCatDurSplit := strings.SplitAfterN(oldCatDur, "_", 2) @@ -773,9 +774,11 @@ func (e *exchange) makeBid(Bids []*pbsOrtbBid, auc *auction, returnCreative bool bidExt := &openrtb_ext.ExtBid{ Bidder: thisBid.bid.Ext, Prebid: &openrtb_ext.ExtBidPrebid{ - Targeting: thisBid.bidTargets, - Type: thisBid.bidType, - Video: thisBid.bidVideo, + Targeting: thisBid.bidTargets, + Type: thisBid.bidType, + Video: thisBid.bidVideo, + DealPriority: thisBid.dealPriority, + DealTierSatisfied: thisBid.dealTierSatisfied, }, } if cacheInfo, found := e.getBidCacheInfo(thisBid, auc); found { diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index 09d1af912fd..ae8bc3c8c9d 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -695,6 +695,11 @@ func TestBidReturnsCreative(t *testing.T) { assert.Equal(t, 0, len(resultingErrs), "%s. Test should not return errors \n", test.description) assert.Equal(t, test.expectedCreativeMarkup, resultingBids[0].AdM, "%s. Ad markup string doesn't match expected \n", test.description) + + var bidExt openrtb_ext.ExtBid + json.Unmarshal(resultingBids[0].Ext, &bidExt) + assert.Equal(t, 0, bidExt.Prebid.DealPriority, "%s. Test should have DealPriority set to 0", test.description) + assert.Equal(t, false, bidExt.Prebid.DealTierSatisfied, "%s. Test should have DealTierSatisfied set to false", test.description) } } @@ -1514,10 +1519,10 @@ func TestCategoryMapping(t *testing.T) { bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, 0} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0, false} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, 0, false} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1569,10 +1574,10 @@ func TestCategoryMappingNoIncludeBrandCategory(t *testing.T) { bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, 0} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0, false} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, 0, false} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, 0, false} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1623,9 +1628,9 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) { bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0, false} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1705,9 +1710,9 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) { bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, 0, false} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1757,11 +1762,11 @@ func TestCategoryDedupe(t *testing.T) { bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 20.0000, Cat: cats4, W: 1, H: 1} bid5 := openrtb.Bid{ID: "bid_id5", ImpID: "imp_id5", Price: 20.0000, Cat: cats1, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, 0} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, 0, false} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} selectedBids := make(map[string]int) expectedCategories := map[string]string{ @@ -1836,11 +1841,11 @@ func TestNoCategoryDedupe(t *testing.T) { bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 20.0000, Cat: cats4, W: 1, H: 1} bid5 := openrtb.Bid{ID: "bid_id5", ImpID: "imp_id5", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} selectedBids := make(map[string]int) expectedCategories := map[string]string{ @@ -1916,8 +1921,8 @@ func TestCategoryMappingBidderName(t *testing.T) { bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 10.0000, Cat: cats2, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} innerBids1 := []*pbsOrtbBid{ &bid1_1, @@ -1970,8 +1975,8 @@ func TestCategoryMappingBidderNameNoCategories(t *testing.T) { bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 12.0000, Cat: cats2, W: 1, H: 1} - bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} innerBids1 := []*pbsOrtbBid{ &bid1_1, @@ -2082,7 +2087,7 @@ func TestBidRejectionErrors(t *testing.T) { innerBids := []*pbsOrtbBid{} for _, bid := range test.bids { currentBid := pbsOrtbBid{ - bid, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: test.duration}, 0, + bid, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: test.duration}, 0, false, } innerBids = append(innerBids, ¤tBid) } @@ -2131,8 +2136,8 @@ func TestCategoryMappingTwoBiddersOneBidEachNoCategorySamePrice(t *testing.T) { bidApn1 := openrtb.Bid{ID: "bid_idApn1", ImpID: "imp_idApn1", Price: 10.0000, Cat: cats1, W: 1, H: 1} bidApn2 := openrtb.Bid{ID: "bid_idApn2", ImpID: "imp_idApn2", Price: 10.0000, Cat: cats2, W: 1, H: 1} - bid1_Apn1 := pbsOrtbBid{&bidApn1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} - bid1_Apn2 := pbsOrtbBid{&bidApn2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0} + bid1_Apn1 := pbsOrtbBid{&bidApn1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} + bid1_Apn2 := pbsOrtbBid{&bidApn2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, 0, false} innerBidsApn1 := []*pbsOrtbBid{ &bid1_Apn1, @@ -2193,12 +2198,13 @@ func TestUpdateRejections(t *testing.T) { func TestApplyDealSupport(t *testing.T) { testCases := []struct { - description string - dealPriority int - impExt json.RawMessage - targ map[string]string - expectedHbPbCatDur string - expectedDealErr string + description string + dealPriority int + impExt json.RawMessage + targ map[string]string + expectedHbPbCatDur string + expectedDealErr string + expectedDealTierSatisfied bool }{ { description: "hb_pb_cat_dur should be modified", @@ -2207,8 +2213,9 @@ func TestApplyDealSupport(t *testing.T) { targ: map[string]string{ "hb_pb_cat_dur": "12.00_movies_30s", }, - expectedHbPbCatDur: "tier5_movies_30s", - expectedDealErr: "", + expectedHbPbCatDur: "tier5_movies_30s", + expectedDealErr: "", + expectedDealTierSatisfied: true, }, { description: "hb_pb_cat_dur should not be modified due to priority not exceeding min", @@ -2217,8 +2224,9 @@ func TestApplyDealSupport(t *testing.T) { targ: map[string]string{ "hb_pb_cat_dur": "12.00_medicine_30s", }, - expectedHbPbCatDur: "12.00_medicine_30s", - expectedDealErr: "", + expectedHbPbCatDur: "12.00_medicine_30s", + expectedDealErr: "", + expectedDealTierSatisfied: false, }, { description: "hb_pb_cat_dur should not be modified due to invalid config", @@ -2227,8 +2235,9 @@ func TestApplyDealSupport(t *testing.T) { targ: map[string]string{ "hb_pb_cat_dur": "12.00_games_30s", }, - expectedHbPbCatDur: "12.00_games_30s", - expectedDealErr: "dealTier configuration invalid for bidder 'appnexus', imp ID 'imp_id1'", + expectedHbPbCatDur: "12.00_games_30s", + expectedDealErr: "dealTier configuration invalid for bidder 'appnexus', imp ID 'imp_id1'", + expectedDealTierSatisfied: false, }, { description: "hb_pb_cat_dur should not be modified due to deal priority of 0", @@ -2237,8 +2246,9 @@ func TestApplyDealSupport(t *testing.T) { targ: map[string]string{ "hb_pb_cat_dur": "12.00_auto_30s", }, - expectedHbPbCatDur: "12.00_auto_30s", - expectedDealErr: "", + expectedHbPbCatDur: "12.00_auto_30s", + expectedDealErr: "", + expectedDealTierSatisfied: false, }, } @@ -2254,7 +2264,7 @@ func TestApplyDealSupport(t *testing.T) { }, } - bid := pbsOrtbBid{&openrtb.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, test.dealPriority} + bid := pbsOrtbBid{&openrtb.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, test.dealPriority, false} bidCategory := map[string]string{ bid.bid.ID: test.targ["hb_pb_cat_dur"], } @@ -2270,6 +2280,7 @@ func TestApplyDealSupport(t *testing.T) { dealErrs := applyDealSupport(bidRequest, auc, bidCategory) assert.Equal(t, test.expectedHbPbCatDur, bidCategory[auc.winningBidsByBidder["imp_id1"][bidderName].bid.ID], test.description) + assert.Equal(t, test.expectedDealTierSatisfied, auc.winningBidsByBidder["imp_id1"][bidderName].dealTierSatisfied, "expectedDealTierSatisfied=%v when %v", test.expectedDealTierSatisfied, test.description) if len(test.expectedDealErr) > 0 { assert.Containsf(t, dealErrs, errors.New(test.expectedDealErr), "Expected error message not found in deal errors") } @@ -2368,11 +2379,12 @@ func TestValidateDealTier(t *testing.T) { func TestUpdateHbPbCatDur(t *testing.T) { testCases := []struct { - description string - targ map[string]string - dealTier openrtb_ext.DealTier - dealPriority int - expectedHbPbCatDur string + description string + targ map[string]string + dealTier openrtb_ext.DealTier + dealPriority int + expectedHbPbCatDur string + expectedDealTierSatisfied bool }{ { description: "hb_pb_cat_dur should be updated with prefix and tier", @@ -2384,8 +2396,9 @@ func TestUpdateHbPbCatDur(t *testing.T) { Prefix: "tier", MinDealTier: 5, }, - dealPriority: 5, - expectedHbPbCatDur: "tier5_movies_30s", + dealPriority: 5, + expectedHbPbCatDur: "tier5_movies_30s", + expectedDealTierSatisfied: true, }, { description: "hb_pb_cat_dur should not be updated due to bid priority", @@ -2397,8 +2410,9 @@ func TestUpdateHbPbCatDur(t *testing.T) { Prefix: "tier", MinDealTier: 10, }, - dealPriority: 6, - expectedHbPbCatDur: "12.00_auto_30s", + dealPriority: 6, + expectedHbPbCatDur: "12.00_auto_30s", + expectedDealTierSatisfied: false, }, { description: "hb_pb_cat_dur should be updated with prefix and tier", @@ -2410,13 +2424,14 @@ func TestUpdateHbPbCatDur(t *testing.T) { Prefix: "tier", MinDealTier: 1, }, - dealPriority: 7, - expectedHbPbCatDur: "tier7_medicine_30s", + dealPriority: 7, + expectedHbPbCatDur: "tier7_medicine_30s", + expectedDealTierSatisfied: true, }, } for _, test := range testCases { - bid := pbsOrtbBid{&openrtb.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, test.dealPriority} + bid := pbsOrtbBid{&openrtb.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, test.dealPriority, false} bidCategory := map[string]string{ bid.bid.ID: test.targ["hb_pb_cat_dur"], } @@ -2424,6 +2439,7 @@ func TestUpdateHbPbCatDur(t *testing.T) { updateHbPbCatDur(&bid, test.dealTier, bidCategory) assert.Equal(t, test.expectedHbPbCatDur, bidCategory[bid.bid.ID], test.description) + assert.Equal(t, test.expectedDealTierSatisfied, bid.dealTierSatisfied, test.description) } } diff --git a/openrtb_ext/bid.go b/openrtb_ext/bid.go index 09ee375be82..75d83c9d7dd 100644 --- a/openrtb_ext/bid.go +++ b/openrtb_ext/bid.go @@ -12,11 +12,15 @@ type ExtBid struct { } // ExtBidPrebid defines the contract for bidresponse.seatbid.bid[i].ext.prebid +// DealPriority represents priority of deal bid. If its non deal bid then value will be 0 +// DealTierSatisfied true represents corresponding bid has satisfied the deal tier type ExtBidPrebid struct { - Cache *ExtBidPrebidCache `json:"cache,omitempty"` - Targeting map[string]string `json:"targeting,omitempty"` - Type BidType `json:"type"` - Video *ExtBidPrebidVideo `json:"video,omitempty"` + Cache *ExtBidPrebidCache `json:"cache,omitempty"` + Targeting map[string]string `json:"targeting,omitempty"` + Type BidType `json:"type"` + Video *ExtBidPrebidVideo `json:"video,omitempty"` + DealPriority int `json:"dealpriority,omitempty"` + DealTierSatisfied bool `json:"dealtiersatisfied,omitempty"` } // ExtBidPrebidCache defines the contract for bidresponse.seatbid.bid[i].ext.prebid.cache