Skip to content

Commit

Permalink
Flipp: Use height value from server response (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
MishelleBit authored Dec 10, 2024
1 parent a9564da commit 183b1ec
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 34 deletions.
52 changes: 42 additions & 10 deletions adapters/flipp/flipp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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
}
Expand Down
16 changes: 7 additions & 9 deletions adapters/flipp/flipptest/exemplary/simple-banner-dtx.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"siteId": 1243066,
"zoneIds": [285431],
"options": {
"startCompact": true
"startCompact": true
}
}
}
Expand Down Expand Up @@ -70,7 +70,7 @@
285431
],
"options": {
"startCompact": true
"startCompact": true
}
}
],
Expand All @@ -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
},
Expand All @@ -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,
Expand Down Expand Up @@ -164,7 +161,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 600
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"siteId": 1243066,
"zoneIds": [285431],
"options": {
"startCompact": true
"startCompact": false
},
"userKey": "abc123"
}
Expand Down Expand Up @@ -78,7 +78,6 @@
285431
],
"options": {
"startCompact": true
}
}
],
Expand All @@ -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
Expand Down Expand Up @@ -172,7 +173,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 900
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"siteId": 1243066,
"zoneIds": [285431],
"options": {
"startCompact": true
"startCompact": false
},
"userKey": "abc123"
}
Expand Down Expand Up @@ -74,7 +74,7 @@
285431
],
"options": {
"startCompact": true

}
}
],
Expand Down Expand Up @@ -168,7 +168,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 2400
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"siteId": 1243066,
"zoneIds": [285431],
"options": {
"startCompact": true
"startCompact": false
},
"userKey": "abc123"
}
Expand Down Expand Up @@ -74,7 +74,6 @@
285431
],
"options": {
"startCompact": true
}
}
],
Expand Down Expand Up @@ -168,7 +167,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 2400
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 600
},
"type": "banner"
}
Expand Down
9 changes: 5 additions & 4 deletions adapters/flipp/flipptest/exemplary/simple-banner-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"siteId": 1243066,
"zoneIds": [285431],
"options": {
"startCompact": true,
"startCompact": false,
"contentCode": "publisher-test-2"
}
}
Expand Down Expand Up @@ -72,7 +72,6 @@
285431
],
"options": {
"startCompact": true,
"contentCode": "publisher-test-2"
}
}
Expand All @@ -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
Expand Down Expand Up @@ -167,7 +167,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 2400
},
"type": "banner"
}
Expand Down

0 comments on commit 183b1ec

Please sign in to comment.