From 70dec6e009082770859fc57098a6bf3b93fd7495 Mon Sep 17 00:00:00 2001 From: Mishelle Bitman Date: Wed, 25 Sep 2024 13:06:08 -0400 Subject: [PATCH] OFF-1457: height should use the compactHeight and standardHeight fields in decisions response (#8) * add compactHeight and standardHeight fields in decision response * modify tests * modify tests * modify tests * modify tests * adding height to expectedBidResponses * final testing * final changes * final changes * final changes --- adapters/flipp/flipp.go | 45 ++++++++++++++----- .../exemplary/simple-banner-dtx.json | 9 ++-- ...ple-banner-native-param-transmit-eids.json | 10 +++-- ...simple-banner-native-param-user-coppa.json | 7 +-- .../simple-banner-native-param-user-gdpr.json | 6 +-- .../simple-banner-native-param-user.json | 3 +- .../exemplary/simple-banner-native.json | 9 ++-- 7 files changed, 61 insertions(+), 28 deletions(-) diff --git a/adapters/flipp/flipp.go b/adapters/flipp/flipp.go index 55a3ce7b3e1..bb23ea5a6b9 100644 --- a/adapters/flipp/flipp.go +++ b/adapters/flipp/flipp.go @@ -20,16 +20,20 @@ import ( ) const ( - bannerType = "banner" - inlineDivName = "inline" - flippBidder = "flipp" - defaultCurrency = "USD" + bannerType = "banner" + inlineDivName = "inline" + flippBidder = "flipp" + defaultCurrency = "USD" + defaultStandardHeight int64 = 2400 + defaultCompactHeight int64 = 600 ) var ( - count int64 = 1 - adTypes = []int64{4309, 641} - dtxTypes = []int64{5061} + count int64 = 1 + adTypes = []int64{4309, 641} + dtxTypes = []int64{5061} + flippExtParams openrtb_ext.ImpExtFlipp + customDataKey string ) type adapter struct { @@ -198,10 +202,18 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) bidResponse.Currency = defaultCurrency for _, imp := range request.Imp { + params, _, _, err := jsonparser.Get(imp.Ext, "bidder") + if err != nil { + return nil, []error{fmt.Errorf("flipp params not found. %v", err)} + } + err = json.Unmarshal(params, &flippExtParams) + if err != nil { + return nil, []error{fmt.Errorf("unable to extract flipp params. %v", err)} + } for _, decision := range campaignResponseBody.Decisions.Inline { if *decision.Prebid.RequestID == imp.ID { b := &adapters.TypedBid{ - Bid: buildBid(decision, imp.ID), + Bid: buildBid(decision, imp.ID, flippExtParams), BidType: openrtb_ext.BidType(bannerType), } bidResponse.Bids = append(bidResponse.Bids, b) @@ -218,7 +230,7 @@ func getAdTypes(creativeType string) []int64 { return adTypes } -func buildBid(decision *InlineModel, impId string) *openrtb2.Bid { +func buildBid(decision *InlineModel, impId string, flippExtParams openrtb_ext.ImpExtFlipp) *openrtb2.Bid { bid := &openrtb2.Bid{ CrID: fmt.Sprint(decision.CreativeID), Price: *decision.Prebid.Cpm, @@ -230,7 +242,20 @@ func buildBid(decision *InlineModel, impId string) *openrtb2.Bid { if decision.Contents[0].Data.Width != 0 { bid.W = decision.Contents[0].Data.Width } - bid.H = 0 + customDataInterface := decision.Contents[0].Data.CustomData + customDataMap := customDataInterface.(map[string]interface{}) + + bid.H = defaultStandardHeight + customDataKey = "standardHeight" + if flippExtParams.Options.StartCompact { + bid.H = defaultCompactHeight + customDataKey = "compactHeight" + } + if value, exists := customDataMap[customDataKey]; exists { + if floatVal, ok := value.(float64); ok { + bid.H = int64(floatVal) + } + } } return bid } diff --git a/adapters/flipp/flipptest/exemplary/simple-banner-dtx.json b/adapters/flipp/flipptest/exemplary/simple-banner-dtx.json index 379f881ed85..3f3aba2881f 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-dtx.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-dtx.json @@ -96,7 +96,9 @@ "data": { "customData": { "campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215", - "campaignNameIdentifier": "US Grocery Demo (Kroger)" + "campaignNameIdentifier": "US Grocery Demo (Kroger)", + "standardHeight": 900, + "compactHeight": 700 }, "height": 1800, "width": 300 @@ -106,7 +108,7 @@ ], "creativeId": 81325690, "flightId": 175421795, - "height": 1800, + "height": 700, "impressionUrl": "https://e-11090.adzerk.net/i.gif?e=eyJ2IjoiMS4xMSIsImF2IjoxOTg4MDI3LCJhdCI6NDMwOSwiYnQiOjAsImNtIjo2MzI4NTM5MiwiY2giOjU4MDgxLCJjayI6e30sImNyIjo4MTMyNTY5MCwiZGkiOiJiOTg3MGNkYTA5MTU0NDlmOTkwZGNkZTNmNjYyNGNhMyIsImRqIjowLCJpaSI6IjJmNjYwMjMyODBmYjQ4NTRiYTY0YzFlYzA1ZDU5MTNiIiwiZG0iOjMsImZjIjoxODM1OTkxMTUsImZsIjoxNzU0MjE3OTUsImlwIjoiMTQyLjE4MS41OC41MiIsIm53IjoxMDkyMiwicGMiOjAsIm9wIjowLCJlYyI6MCwiZ20iOjAsImVwIjpudWxsLCJwciI6MjMyNjk5LCJydCI6MywicnMiOjUwMCwic2EiOiIzNCIsInNiIjoiaS0wNDZjMWNlNWRjYmExMTVjNSIsInNwIjozNzIzMDU1LCJzdCI6MTI0MzA2NiwidWsiOiJkOTU1N2Q2NS1kNWI5LTQyOTItYjg2My0xNGEyOTcyNTk3ZjQiLCJ6biI6Mjg1NDMxLCJ0cyI6MTY4MDU1NTc4MzkyMywicG4iOiJpbmxpbmUiLCJnYyI6dHJ1ZSwiZ0MiOnRydWUsImdzIjoibm9uZSIsInR6IjoiQW1lcmljYS9OZXdfWW9yayIsImJhIjoxLCJmcSI6MH0&s=Qce4_IohtESeNA_sB71Qjb4TouY", "prebid": { "cpm": 12.34, @@ -164,7 +166,8 @@ "price": 12.34, "adm": "creativeContent", "crid": "81325690", - "w": 300 + "w": 300, + "h": 700 }, "type": "banner" } diff --git a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-transmit-eids.json b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-transmit-eids.json index 19748d47fba..beb101ea108 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-transmit-eids.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-transmit-eids.json @@ -37,7 +37,7 @@ "siteId": 1243066, "zoneIds": [285431], "options": { - "startCompact": true + "startCompact": false }, "userKey": "abc123" } @@ -78,7 +78,6 @@ 285431 ], "options": { - "startCompact": true } } ], @@ -104,7 +103,9 @@ "data": { "customData": { "campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215", - "campaignNameIdentifier": "US Grocery Demo (Kroger)" + "campaignNameIdentifier": "US Grocery Demo (Kroger)", + "standardHeight": 900, + "compactHeight": 700 }, "height": 1800, "width": 300 @@ -172,7 +173,8 @@ "price": 12.34, "adm": "creativeContent", "crid": "81325690", - "w": 300 + "w": 300, + "h": 900 }, "type": "banner" } diff --git a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-coppa.json b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-coppa.json index eb81940da63..c9c283ec48a 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-coppa.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-coppa.json @@ -33,7 +33,7 @@ "siteId": 1243066, "zoneIds": [285431], "options": { - "startCompact": true + "startCompact": false }, "userKey": "abc123" } @@ -74,7 +74,7 @@ 285431 ], "options": { - "startCompact": true + } } ], @@ -168,7 +168,8 @@ "price": 12.34, "adm": "creativeContent", "crid": "81325690", - "w": 300 + "w": 300, + "h": 2400 }, "type": "banner" } diff --git a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-gdpr.json b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-gdpr.json index 2a9c276696c..1b464670c43 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-gdpr.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-gdpr.json @@ -33,7 +33,7 @@ "siteId": 1243066, "zoneIds": [285431], "options": { - "startCompact": true + "startCompact": false }, "userKey": "abc123" } @@ -74,7 +74,6 @@ 285431 ], "options": { - "startCompact": true } } ], @@ -168,7 +167,8 @@ "price": 12.34, "adm": "creativeContent", "crid": "81325690", - "w": 300 + "w": 300, + "h": 2400 }, "type": "banner" } diff --git a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user.json b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user.json index f9f9537a86c..7f4635171e4 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-native-param-user.json @@ -170,7 +170,8 @@ "price": 12.34, "adm": "creativeContent", "crid": "81325690", - "w": 300 + "w": 300, + "h": 600 }, "type": "banner" } diff --git a/adapters/flipp/flipptest/exemplary/simple-banner-native.json b/adapters/flipp/flipptest/exemplary/simple-banner-native.json index d1d6188f0b8..c3e5e52c1f8 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-native.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-native.json @@ -31,7 +31,7 @@ "siteId": 1243066, "zoneIds": [285431], "options": { - "startCompact": true, + "startCompact": false, "contentCode": "publisher-test-2" } } @@ -72,7 +72,6 @@ 285431 ], "options": { - "startCompact": true, "contentCode": "publisher-test-2" } } @@ -99,7 +98,8 @@ "data": { "customData": { "campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215", - "campaignNameIdentifier": "US Grocery Demo (Kroger)" + "campaignNameIdentifier": "US Grocery Demo (Kroger)", + "compactHeight": 700 }, "height": 1800, "width": 300 @@ -167,7 +167,8 @@ "price": 12.34, "adm": "creativeContent", "crid": "81325690", - "w": 300 + "w": 300, + "h": 2400 }, "type": "banner" }