Skip to content

Commit 183b1ec

Browse files
authored
Flipp: Use height value from server response (#3940)
1 parent a9564da commit 183b1ec

7 files changed

+69
-34
lines changed

adapters/flipp/flipp.go

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ import (
2121
)
2222

2323
const (
24-
bannerType = "banner"
25-
inlineDivName = "inline"
26-
flippBidder = "flipp"
27-
defaultCurrency = "USD"
24+
bannerType = "banner"
25+
inlineDivName = "inline"
26+
flippBidder = "flipp"
27+
defaultCurrency = "USD"
28+
defaultStandardHeight int64 = 2400
29+
defaultCompactHeight int64 = 600
2830
)
2931

3032
var (
31-
count int64 = 1
32-
adTypes = []int64{4309, 641}
33-
dtxTypes = []int64{5061}
33+
count int64 = 1
34+
adTypes = []int64{4309, 641}
35+
dtxTypes = []int64{5061}
36+
flippExtParams openrtb_ext.ImpExtFlipp
37+
customDataKey string
3438
)
3539

3640
type adapter struct {
@@ -199,10 +203,18 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
199203
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
200204
bidResponse.Currency = defaultCurrency
201205
for _, imp := range request.Imp {
206+
params, _, _, err := jsonparser.Get(imp.Ext, "bidder")
207+
if err != nil {
208+
return nil, []error{fmt.Errorf("flipp params not found. %v", err)}
209+
}
210+
err = jsonutil.Unmarshal(params, &flippExtParams)
211+
if err != nil {
212+
return nil, []error{fmt.Errorf("unable to extract flipp params. %v", err)}
213+
}
202214
for _, decision := range campaignResponseBody.Decisions.Inline {
203215
if *decision.Prebid.RequestID == imp.ID {
204216
b := &adapters.TypedBid{
205-
Bid: buildBid(decision, imp.ID),
217+
Bid: buildBid(decision, imp.ID, flippExtParams),
206218
BidType: openrtb_ext.BidType(bannerType),
207219
}
208220
bidResponse.Bids = append(bidResponse.Bids, b)
@@ -219,7 +231,7 @@ func getAdTypes(creativeType string) []int64 {
219231
return adTypes
220232
}
221233

222-
func buildBid(decision *InlineModel, impId string) *openrtb2.Bid {
234+
func buildBid(decision *InlineModel, impId string, flippExtParams openrtb_ext.ImpExtFlipp) *openrtb2.Bid {
223235
bid := &openrtb2.Bid{
224236
CrID: fmt.Sprint(decision.CreativeID),
225237
Price: *decision.Prebid.Cpm,
@@ -231,7 +243,27 @@ func buildBid(decision *InlineModel, impId string) *openrtb2.Bid {
231243
if decision.Contents[0].Data.Width != 0 {
232244
bid.W = decision.Contents[0].Data.Width
233245
}
234-
bid.H = 0
246+
247+
if flippExtParams.Options.StartCompact {
248+
bid.H = defaultCompactHeight
249+
} else {
250+
bid.H = defaultStandardHeight
251+
}
252+
253+
if customDataInterface := decision.Contents[0].Data.CustomData; customDataInterface != nil {
254+
if customDataMap, ok := customDataInterface.(map[string]interface{}); ok {
255+
customDataKey := "standardHeight"
256+
if flippExtParams.Options.StartCompact {
257+
customDataKey = "compactHeight"
258+
}
259+
260+
if value, exists := customDataMap[customDataKey]; exists {
261+
if floatVal, ok := value.(float64); ok {
262+
bid.H = int64(floatVal)
263+
}
264+
}
265+
}
266+
}
235267
}
236268
return bid
237269
}

adapters/flipp/flipptest/exemplary/simple-banner-dtx.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"siteId": 1243066,
3232
"zoneIds": [285431],
3333
"options": {
34-
"startCompact": true
34+
"startCompact": true
3535
}
3636
}
3737
}
@@ -70,7 +70,7 @@
7070
285431
7171
],
7272
"options": {
73-
"startCompact": true
73+
"startCompact": true
7474
}
7575
}
7676
],
@@ -93,11 +93,8 @@
9393
"clickUrl": "https://e-11090.adzerk.net/r?e=eyJ2IjoiMS4xMSIsImF2IjoxOTg4MDI3LCJhdCI6NDMwOSwiYnQiOjAsImNtIjo2MzI4NTM5MiwiY2giOjU4MDgxLCJjayI6e30sImNyIjo4MTMyNTY5MCwiZGkiOiJiOTg3MGNkYTA5MTU0NDlmOTkwZGNkZTNmNjYyNGNhMyIsImRqIjowLCJpaSI6IjJmNjYwMjMyODBmYjQ4NTRiYTY0YzFlYzA1ZDU5MTNiIiwiZG0iOjMsImZjIjoxODM1OTkxMTUsImZsIjoxNzU0MjE3OTUsImlwIjoiMTQyLjE4MS41OC41MiIsIm53IjoxMDkyMiwicGMiOjAsIm9wIjowLCJlYyI6MCwiZ20iOjAsImVwIjpudWxsLCJwciI6MjMyNjk5LCJydCI6MywicnMiOjUwMCwic2EiOiIzNCIsInNiIjoiaS0wNDZjMWNlNWRjYmExMTVjNSIsInNwIjozNzIzMDU1LCJzdCI6MTI0MzA2NiwidWsiOiJkOTU1N2Q2NS1kNWI5LTQyOTItYjg2My0xNGEyOTcyNTk3ZjQiLCJ6biI6Mjg1NDMxLCJ0cyI6MTY4MDU1NTc4MzkyMiwicG4iOiJpbmxpbmUiLCJnYyI6dHJ1ZSwiZ0MiOnRydWUsImdzIjoibm9uZSIsInR6IjoiQW1lcmljYS9OZXdfWW9yayIsInVyIjoiaHR0cDovL3d3dy5mbGlwcC5jb20ifQ&s=Mnss8P1kc37Eftik5RJvLJb4S9Y",
9494
"contents": [
9595
{
96-
"data": {
97-
"customData": {
98-
"campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215",
99-
"campaignNameIdentifier": "US Grocery Demo (Kroger)"
100-
},
96+
"data": {
97+
"customData": null,
10198
"height": 1800,
10299
"width": 300
103100
},
@@ -106,7 +103,7 @@
106103
],
107104
"creativeId": 81325690,
108105
"flightId": 175421795,
109-
"height": 1800,
106+
"height": 700,
110107
"impressionUrl": "https://e-11090.adzerk.net/i.gif?e=eyJ2IjoiMS4xMSIsImF2IjoxOTg4MDI3LCJhdCI6NDMwOSwiYnQiOjAsImNtIjo2MzI4NTM5MiwiY2giOjU4MDgxLCJjayI6e30sImNyIjo4MTMyNTY5MCwiZGkiOiJiOTg3MGNkYTA5MTU0NDlmOTkwZGNkZTNmNjYyNGNhMyIsImRqIjowLCJpaSI6IjJmNjYwMjMyODBmYjQ4NTRiYTY0YzFlYzA1ZDU5MTNiIiwiZG0iOjMsImZjIjoxODM1OTkxMTUsImZsIjoxNzU0MjE3OTUsImlwIjoiMTQyLjE4MS41OC41MiIsIm53IjoxMDkyMiwicGMiOjAsIm9wIjowLCJlYyI6MCwiZ20iOjAsImVwIjpudWxsLCJwciI6MjMyNjk5LCJydCI6MywicnMiOjUwMCwic2EiOiIzNCIsInNiIjoiaS0wNDZjMWNlNWRjYmExMTVjNSIsInNwIjozNzIzMDU1LCJzdCI6MTI0MzA2NiwidWsiOiJkOTU1N2Q2NS1kNWI5LTQyOTItYjg2My0xNGEyOTcyNTk3ZjQiLCJ6biI6Mjg1NDMxLCJ0cyI6MTY4MDU1NTc4MzkyMywicG4iOiJpbmxpbmUiLCJnYyI6dHJ1ZSwiZ0MiOnRydWUsImdzIjoibm9uZSIsInR6IjoiQW1lcmljYS9OZXdfWW9yayIsImJhIjoxLCJmcSI6MH0&s=Qce4_IohtESeNA_sB71Qjb4TouY",
111108
"prebid": {
112109
"cpm": 12.34,
@@ -164,7 +161,8 @@
164161
"price": 12.34,
165162
"adm": "creativeContent",
166163
"crid": "81325690",
167-
"w": 300
164+
"w": 300,
165+
"h": 600
168166
},
169167
"type": "banner"
170168
}

adapters/flipp/flipptest/exemplary/simple-banner-native-param-transmit-eids.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"siteId": 1243066,
3838
"zoneIds": [285431],
3939
"options": {
40-
"startCompact": true
40+
"startCompact": false
4141
},
4242
"userKey": "abc123"
4343
}
@@ -78,7 +78,6 @@
7878
285431
7979
],
8080
"options": {
81-
"startCompact": true
8281
}
8382
}
8483
],
@@ -104,7 +103,9 @@
104103
"data": {
105104
"customData": {
106105
"campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215",
107-
"campaignNameIdentifier": "US Grocery Demo (Kroger)"
106+
"campaignNameIdentifier": "US Grocery Demo (Kroger)",
107+
"standardHeight": 900,
108+
"compactHeight": 700
108109
},
109110
"height": 1800,
110111
"width": 300
@@ -172,7 +173,8 @@
172173
"price": 12.34,
173174
"adm": "creativeContent",
174175
"crid": "81325690",
175-
"w": 300
176+
"w": 300,
177+
"h": 900
176178
},
177179
"type": "banner"
178180
}

adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-coppa.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"siteId": 1243066,
3434
"zoneIds": [285431],
3535
"options": {
36-
"startCompact": true
36+
"startCompact": false
3737
},
3838
"userKey": "abc123"
3939
}
@@ -74,7 +74,7 @@
7474
285431
7575
],
7676
"options": {
77-
"startCompact": true
77+
7878
}
7979
}
8080
],
@@ -168,7 +168,8 @@
168168
"price": 12.34,
169169
"adm": "creativeContent",
170170
"crid": "81325690",
171-
"w": 300
171+
"w": 300,
172+
"h": 2400
172173
},
173174
"type": "banner"
174175
}

adapters/flipp/flipptest/exemplary/simple-banner-native-param-user-gdpr.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"siteId": 1243066,
3434
"zoneIds": [285431],
3535
"options": {
36-
"startCompact": true
36+
"startCompact": false
3737
},
3838
"userKey": "abc123"
3939
}
@@ -74,7 +74,6 @@
7474
285431
7575
],
7676
"options": {
77-
"startCompact": true
7877
}
7978
}
8079
],
@@ -168,7 +167,8 @@
168167
"price": 12.34,
169168
"adm": "creativeContent",
170169
"crid": "81325690",
171-
"w": 300
170+
"w": 300,
171+
"h": 2400
172172
},
173173
"type": "banner"
174174
}

adapters/flipp/flipptest/exemplary/simple-banner-native-param-user.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@
170170
"price": 12.34,
171171
"adm": "creativeContent",
172172
"crid": "81325690",
173-
"w": 300
173+
"w": 300,
174+
"h": 600
174175
},
175176
"type": "banner"
176177
}

adapters/flipp/flipptest/exemplary/simple-banner-native.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"siteId": 1243066,
3232
"zoneIds": [285431],
3333
"options": {
34-
"startCompact": true,
34+
"startCompact": false,
3535
"contentCode": "publisher-test-2"
3636
}
3737
}
@@ -72,7 +72,6 @@
7272
285431
7373
],
7474
"options": {
75-
"startCompact": true,
7675
"contentCode": "publisher-test-2"
7776
}
7877
}
@@ -99,7 +98,8 @@
9998
"data": {
10099
"customData": {
101100
"campaignConfigUrl": "https://campaign-config.flipp.com/dist-campaign-admin/215",
102-
"campaignNameIdentifier": "US Grocery Demo (Kroger)"
101+
"campaignNameIdentifier": "US Grocery Demo (Kroger)",
102+
"compactHeight": 700
103103
},
104104
"height": 1800,
105105
"width": 300
@@ -167,7 +167,8 @@
167167
"price": 12.34,
168168
"adm": "creativeContent",
169169
"crid": "81325690",
170-
"w": 300
170+
"w": 300,
171+
"h": 2400
171172
},
172173
"type": "banner"
173174
}

0 commit comments

Comments
 (0)