Skip to content

Commit

Permalink
Banner impression update to look for only top one (#587)
Browse files Browse the repository at this point in the history
*  Banner impression update to look for only top one

* making a copy of bid request to work on

*  Copying banner object to update

*  Fixing issue with impression copy

*  Updating error statement
  • Loading branch information
smithaammassamveettil authored and hhhjort committed Jul 20, 2018
1 parent 9bf9058 commit 8c3ee50
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 74 deletions.
19 changes: 14 additions & 5 deletions adapters/brightroll/brightroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,26 @@ func (a *BrightrollAdapter) MakeRequests(request *openrtb.BidRequest) ([]*adapte
}

validImpExists := false

for _, imp := range request.Imp {
for i := 0; i < len(request.Imp); i++ {
//Brightroll supports only banner and video impressions as of now
if imp.Banner != nil {
if request.Imp[i].Banner != nil {
bannerCopy := *request.Imp[i].Banner
if bannerCopy.W == nil && bannerCopy.H == nil && len(bannerCopy.Format) > 0 {
firstFormat := bannerCopy.Format[0]
bannerCopy.W = &(firstFormat.W)
bannerCopy.H = &(firstFormat.H)
}
request.Imp[i].Banner = &bannerCopy
validImpExists = true
} else if imp.Video != nil {
} else if request.Imp[i].Video != nil {
validImpExists = true
} else {
err := &errortypes.BadInput{
Message: fmt.Sprintf("Brightroll only supports banner and video imps. Ignoring imp id=%s", imp.ID),
Message: fmt.Sprintf("Brightroll only supports banner and video imps. Ignoring imp id=%s", request.Imp[i].ID),
}
errs = append(errs, err)
request.Imp = append(request.Imp[:i], request.Imp[i+1:]...)
i--
}
}

Expand Down Expand Up @@ -98,6 +106,7 @@ func (a *BrightrollAdapter) MakeRequests(request *openrtb.BidRequest) ([]*adapte
addHeaderIfNonEmpty(headers, "Accept-Language", request.Device.Language)
addHeaderIfNonEmpty(headers, "DNT", strconv.Itoa(int(request.Device.DNT)))
}

return []*adapters.RequestData{{
Method: "POST",
Uri: thisURI,
Expand Down
19 changes: 4 additions & 15 deletions adapters/brightroll/brightrolltest/exemplary/banner-and-audio.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,10 @@
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"publisher": "cafemom"
}
}
},
{
"id": "unsupported-audio-imp",
"audio": {
"mimes": [
"video/mp4"
]
},
],
"w": 300,
"h": 250
},
"ext": {
"bidder": {
"publisher": "cafemom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"w": 300,
"h": 600
}
]
],
"w": 300,
"h": 250
},
"ext": {
"bidder": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,9 @@
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"publisher": "cafemom"
}
}
},
{
"id": "unsupported-native-imp",
"native": {
"ver": "1.1",
"request": "{\"ver\":\"1.1\",\"context\":1,\"contextsubtype\":11,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":500}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1,\"hmin\":1}},{\"id\":3,\"required\":0,\"data\":{\"type\":1,\"len\":200}},{\"id\":4,\"required\":0,\"data\":{\"type\":2,\"len\":15000}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"len\":40}},{\"id\":6,\"required\":0,\"data\":{\"type\":500}}]}"
},
"ext": {
"bidder": {
"publisher": "cafemom"
}
}
},
{
"id": "unsupported-audio-imp",
"audio": {
"mimes": [
"video/mp4"
]
],
"w": 300,
"h": 250
},
"ext": {
"bidder": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,9 @@
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"publisher": "cafemom"
}
}
},
{
"id": "unsupported-native-imp",
"native": {
"ver": "1.1",
"request": "{\"ver\":\"1.1\",\"context\":1,\"contextsubtype\":11,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":500}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1,\"hmin\":1}},{\"id\":3,\"required\":0,\"data\":{\"type\":1,\"len\":200}},{\"id\":4,\"required\":0,\"data\":{\"type\":2,\"len\":15000}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"len\":40}},{\"id\":6,\"required\":0,\"data\":{\"type\":500}}]}"
],
"w": 300,
"h": 250
},
"ext": {
"bidder": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"w": 300,
"h": 600
}
]
],
"w": 300,
"h": 250
},
"ext": {
"bidder": {
Expand Down
13 changes: 0 additions & 13 deletions adapters/brightroll/brightrolltest/exemplary/video-and-audio.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@
"publisher": "cafemom"
}
}
},
{
"id": "unsupported-audio-imp",
"audio": {
"mimes": [
"video/mp4"
]
},
"ext": {
"bidder": {
"publisher": "cafemom"
}
}
}
]
}
Expand Down

0 comments on commit 8c3ee50

Please sign in to comment.