Skip to content

Commit

Permalink
Added pass through of BCat and BAdv from Video req to openRTB request (
Browse files Browse the repository at this point in the history
  • Loading branch information
VeronikaSolovei9 authored and guscarreon committed Jul 18, 2019
1 parent 92d91ae commit 6b20110
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
8 changes: 8 additions & 0 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ func mergeData(videoRequest *openrtb_ext.BidRequestVideo, bidRequest *openrtb.Bi
}
}

if len(videoRequest.BCat) != 0 {
bidRequest.BCat = videoRequest.BCat
}

if len(videoRequest.BAdv) != 0 {
bidRequest.BAdv = videoRequest.BAdv
}

bidExt, err := createBidExtension(videoRequest)
if err != nil {
return err
Expand Down
37 changes: 37 additions & 0 deletions endpoints/openrtb2/video_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,43 @@ func TestVideoBuildVideoResponseNoBids(t *testing.T) {
assert.Len(t, bidRespVideo.AdPods, 0, "AdPods length should be 0")
}

func TestMergeOpenRTBToVideoRequest(t *testing.T) {
var bidReq = &openrtb.BidRequest{}
var videoReq = &openrtb_ext.BidRequestVideo{}

videoReq.App = openrtb.App{
Domain: "test.com",
Bundle: "test.bundle",
}

videoReq.Site = openrtb.Site{
Page: "site.com/index",
}

var dnt int8 = 4
var lmt int8 = 5
videoReq.Device = openrtb.Device{
DNT: &dnt,
Lmt: &lmt,
}

videoReq.BCat = []string{"test1", "test2"}
videoReq.BAdv = []string{"test3", "test4"}

mergeData(videoReq, bidReq)

assert.Equal(t, videoReq.BCat, bidReq.BCat, "BCat is incorrect")
assert.Equal(t, videoReq.BAdv, bidReq.BAdv, "BAdv is incorrect")

assert.Equal(t, videoReq.App.Domain, bidReq.App.Domain, "App.Domain is incorrect")
assert.Equal(t, videoReq.App.Bundle, bidReq.App.Bundle, "App.Bundle is incorrect")

assert.Equal(t, videoReq.Device.Lmt, bidReq.Device.Lmt, "Device.Lmt is incorrect")
assert.Equal(t, videoReq.Device.DNT, bidReq.Device.DNT, "Device.DNT is incorrect")

assert.Equal(t, videoReq.Site.Page, bidReq.Site.Page, "Device.Site.Page is incorrect")
}

func mockDeps(t *testing.T, ex *mockExchangeVideo) *endpointDeps {
theMetrics := pbsmetrics.NewMetrics(metrics.NewRegistry(), openrtb_ext.BidderList())
edep := &endpointDeps{
Expand Down
17 changes: 17 additions & 0 deletions openrtb_ext/bid_request_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ type BidRequestVideo struct {
// be received including Internet latency to avoid timeout. This
// value supersedes any a priori guidance from the exchange.
TMax int64 `json:"tmax,omitempty"`

// Attribute:
// bcat
// Type:
// string array
// Description:
// Blocked advertiser categories using the IAB content
// categories. Refer to List 5.1.
BCat []string `json:"bcat,omitempty"`

// Attribute:
// badv
// Type:
// string array
// Description:
// Block list of advertisers by their domains (e.g., “ford.com”).
BAdv []string `json:"badv,omitempty"`
}

type PodConfig struct {
Expand Down

0 comments on commit 6b20110

Please sign in to comment.