From 8c3ee50439a420e4ce358861204a34684800809b Mon Sep 17 00:00:00 2001 From: smithaammassamveettil <39389834+smithaammassamveettil@users.noreply.github.com> Date: Fri, 20 Jul 2018 09:39:13 -0700 Subject: [PATCH] Banner impression update to look for only top one (#587) * 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 --- adapters/brightroll/brightroll.go | 19 ++++++++---- .../exemplary/banner-and-audio.json | 19 +++--------- .../exemplary/banner-and-video.json | 4 ++- .../exemplary/banner-native-audio.json | 29 ++----------------- .../exemplary/banner-video-native.json | 16 ++-------- .../exemplary/simple-banner.json | 4 ++- .../exemplary/video-and-audio.json | 13 --------- 7 files changed, 30 insertions(+), 74 deletions(-) diff --git a/adapters/brightroll/brightroll.go b/adapters/brightroll/brightroll.go index 90d529f6731..57377ab880d 100644 --- a/adapters/brightroll/brightroll.go +++ b/adapters/brightroll/brightroll.go @@ -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-- } } @@ -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, diff --git a/adapters/brightroll/brightrolltest/exemplary/banner-and-audio.json b/adapters/brightroll/brightrolltest/exemplary/banner-and-audio.json index 66a2d1bd115..aa37c404b4d 100644 --- a/adapters/brightroll/brightrolltest/exemplary/banner-and-audio.json +++ b/adapters/brightroll/brightrolltest/exemplary/banner-and-audio.json @@ -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" diff --git a/adapters/brightroll/brightrolltest/exemplary/banner-and-video.json b/adapters/brightroll/brightrolltest/exemplary/banner-and-video.json index fc5f37f7c1d..9e13663a57e 100644 --- a/adapters/brightroll/brightrolltest/exemplary/banner-and-video.json +++ b/adapters/brightroll/brightrolltest/exemplary/banner-and-video.json @@ -57,7 +57,9 @@ "w": 300, "h": 600 } - ] + ], + "w": 300, + "h": 250 }, "ext": { "bidder": { diff --git a/adapters/brightroll/brightrolltest/exemplary/banner-native-audio.json b/adapters/brightroll/brightrolltest/exemplary/banner-native-audio.json index 37d60694444..4ad05787984 100644 --- a/adapters/brightroll/brightrolltest/exemplary/banner-native-audio.json +++ b/adapters/brightroll/brightrolltest/exemplary/banner-native-audio.json @@ -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": { diff --git a/adapters/brightroll/brightrolltest/exemplary/banner-video-native.json b/adapters/brightroll/brightrolltest/exemplary/banner-video-native.json index ee83b4417f0..760acf9172b 100644 --- a/adapters/brightroll/brightrolltest/exemplary/banner-video-native.json +++ b/adapters/brightroll/brightrolltest/exemplary/banner-video-native.json @@ -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": { diff --git a/adapters/brightroll/brightrolltest/exemplary/simple-banner.json b/adapters/brightroll/brightrolltest/exemplary/simple-banner.json index 1b8ad746c4a..1156739b055 100644 --- a/adapters/brightroll/brightrolltest/exemplary/simple-banner.json +++ b/adapters/brightroll/brightrolltest/exemplary/simple-banner.json @@ -44,7 +44,9 @@ "w": 300, "h": 600 } - ] + ], + "w": 300, + "h": 250 }, "ext": { "bidder": { diff --git a/adapters/brightroll/brightrolltest/exemplary/video-and-audio.json b/adapters/brightroll/brightrolltest/exemplary/video-and-audio.json index d53e07cce32..0c0e937cfb2 100644 --- a/adapters/brightroll/brightrolltest/exemplary/video-and-audio.json +++ b/adapters/brightroll/brightrolltest/exemplary/video-and-audio.json @@ -51,19 +51,6 @@ "publisher": "cafemom" } } - }, - { - "id": "unsupported-audio-imp", - "audio": { - "mimes": [ - "video/mp4" - ] - }, - "ext": { - "bidder": { - "publisher": "cafemom" - } - } } ] }