diff --git a/adapters/flipp/flipp.go b/adapters/flipp/flipp.go index 54bf2775354..4ac5c31c763 100644 --- a/adapters/flipp/flipp.go +++ b/adapters/flipp/flipp.go @@ -21,16 +21,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 { @@ -199,10 +203,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 = jsonutil.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) @@ -219,7 +231,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, @@ -231,7 +243,27 @@ 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 + + if flippExtParams.Options.StartCompact { + bid.H = defaultCompactHeight + } else { + bid.H = defaultStandardHeight + } + + if customDataInterface := decision.Contents[0].Data.CustomData; customDataInterface != nil { + if customDataMap, ok := customDataInterface.(map[string]interface{}); ok { + customDataKey := "standardHeight" + if flippExtParams.Options.StartCompact { + 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..dc68c5eebf2 100644 --- a/adapters/flipp/flipptest/exemplary/simple-banner-dtx.json +++ b/adapters/flipp/flipptest/exemplary/simple-banner-dtx.json @@ -31,7 +31,7 @@ "siteId": 1243066, "zoneIds": [285431], "options": { - "startCompact": true + "startCompact": true } } } @@ -70,7 +70,7 @@ 285431 ], "options": { - "startCompact": true + "startCompact": true } } ], @@ -93,11 +93,8 @@ "clickUrl": "https://e-11090.adzerk.net/r?e=eyJ2IjoiMS4xMSIsImF2IjoxOTg4MDI3LCJhdCI6NDMwOSwiYnQiOjAsImNtIjo2MzI4NTM5MiwiY2giOjU4MDgxLCJjayI6e30sImNyIjo4MTMyNTY5MCwiZGkiOiJiOTg3MGNkYTA5MTU0NDlmOTkwZGNkZTNmNjYyNGNhMyIsImRqIjowLCJpaSI6IjJmNjYwMjMyODBmYjQ4NTRiYTY0YzFlYzA1ZDU5MTNiIiwiZG0iOjMsImZjIjoxODM1OTkxMTUsImZsIjoxNzU0MjE3OTUsImlwIjoiMTQyLjE4MS41OC41MiIsIm53IjoxMDkyMiwicGMiOjAsIm9wIjowLCJlYyI6MCwiZ20iOjAsImVwIjpudWxsLCJwciI6MjMyNjk5LCJydCI6MywicnMiOjUwMCwic2EiOiIzNCIsInNiIjoiaS0wNDZjMWNlNWRjYmExMTVjNSIsInNwIjozNzIzMDU1LCJzdCI6MTI0MzA2NiwidWsiOiJkOTU1N2Q2NS1kNWI5LTQyOTItYjg2My0xNGEyOTcyNTk3ZjQiLCJ6biI6Mjg1NDMxLCJ0cyI6MTY4MDU1NTc4MzkyMiwicG4iOiJpbmxpbmUiLCJnYyI6dHJ1ZSwiZ0MiOnRydWUsImdzIjoibm9uZSIsInR6IjoiQW1lcmljYS9OZXdfWW9yayIsInVyIjoiaHR0cDovL3d3dy5mbGlwcC5jb20ifQ&s=Mnss8P1kc37Eftik5RJvLJb4S9Y", "contents": [ { - "data": { - "customData": { - "campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215", - "campaignNameIdentifier": "US Grocery Demo (Kroger)" - }, + "data": { + "customData": null, "height": 1800, "width": 300 }, @@ -106,7 +103,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 +161,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-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" }