Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OFF-1457: height should use the compactHeight and standardHeight fields in decisions response #8

Merged
merged 10 commits into from
Sep 25, 2024
Merged
46 changes: 36 additions & 10 deletions adapters/flipp/flipp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
key string
Copy link

@hasan-kanjee hasan-kanjee Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just initialize the key here to be standardHeight. Also maybe we can make it a bit more descriptive like customDataKey

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initializing the key there to be standardHeight causes some errors. I think it's because the key will never be modified again in buildBid to standardHeight from compactHeight if it's needed @hasan-kanjee

)

type adapter struct {
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -230,7 +242,21 @@ 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{})

if flippExtParams.Options.StartCompact {
bid.H = defaultCompactHeight
key = "compactHeight"
} else {
bid.H = defaultStandardHeight
key = "standardHeight"
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then here you can do something like

bid.H = defaultStandardHeight
if flippExtParams.Options.StartCompact {
	bid.H = defaultCompactHeight
	key = "compactHeight"
} 

if value, exists := customDataMap[key]; exists {
if floatVal, ok := value.(float64); ok {
bid.H = int64(floatVal)
}
}
}
return bid
}
Expand Down
9 changes: 6 additions & 3 deletions adapters/flipp/flipptest/exemplary/simple-banner-dtx.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -106,7 +108,7 @@
],
"creativeId": 81325690,
"flightId": 175421795,
"height": 1800,
"height": 700,
MishelleBit marked this conversation as resolved.
Show resolved Hide resolved
"impressionUrl": "https://e-11090.adzerk.net/i.gif?e=eyJ2IjoiMS4xMSIsImF2IjoxOTg4MDI3LCJhdCI6NDMwOSwiYnQiOjAsImNtIjo2MzI4NTM5MiwiY2giOjU4MDgxLCJjayI6e30sImNyIjo4MTMyNTY5MCwiZGkiOiJiOTg3MGNkYTA5MTU0NDlmOTkwZGNkZTNmNjYyNGNhMyIsImRqIjowLCJpaSI6IjJmNjYwMjMyODBmYjQ4NTRiYTY0YzFlYzA1ZDU5MTNiIiwiZG0iOjMsImZjIjoxODM1OTkxMTUsImZsIjoxNzU0MjE3OTUsImlwIjoiMTQyLjE4MS41OC41MiIsIm53IjoxMDkyMiwicGMiOjAsIm9wIjowLCJlYyI6MCwiZ20iOjAsImVwIjpudWxsLCJwciI6MjMyNjk5LCJydCI6MywicnMiOjUwMCwic2EiOiIzNCIsInNiIjoiaS0wNDZjMWNlNWRjYmExMTVjNSIsInNwIjozNzIzMDU1LCJzdCI6MTI0MzA2NiwidWsiOiJkOTU1N2Q2NS1kNWI5LTQyOTItYjg2My0xNGEyOTcyNTk3ZjQiLCJ6biI6Mjg1NDMxLCJ0cyI6MTY4MDU1NTc4MzkyMywicG4iOiJpbmxpbmUiLCJnYyI6dHJ1ZSwiZ0MiOnRydWUsImdzIjoibm9uZSIsInR6IjoiQW1lcmljYS9OZXdfWW9yayIsImJhIjoxLCJmcSI6MH0&s=Qce4_IohtESeNA_sB71Qjb4TouY",
"prebid": {
"cpm": 12.34,
Expand Down Expand Up @@ -164,7 +166,8 @@
"price": 12.34,
"adm": "creativeContent",
"crid": "81325690",
"w": 300
"w": 300,
"h": 700
},
"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
Loading