Skip to content

Commit

Permalink
EXCH-11681 Determine bid type based on bid.mtype
Browse files Browse the repository at this point in the history
  • Loading branch information
gmiedlar-ox committed Feb 27, 2025
1 parent 17f40d1 commit 8b7c575
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 31 deletions.
15 changes: 14 additions & 1 deletion adapters/openx/openx.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe
for i := range sb.Bid {
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &sb.Bid[i],
BidType: getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp),
BidType: getBidType(sb.Bid[i].MType, sb.Bid[i].ImpID, internalRequest.Imp),
BidVideo: getBidVideo(&sb.Bid[i]),
})
}
Expand All @@ -255,6 +255,19 @@ func getBidVideo(bid *openrtb2.Bid) *openrtb_ext.ExtBidPrebidVideo {
}
}

func getBidType(mtype openrtb2.MarkupType, impId string, imps []openrtb2.Imp) openrtb_ext.BidType {
switch mtype {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative
default:
return getMediaTypeForImp(impId, imps)
}
}

// getMediaTypeForImp figures out which media type this bid is for.
//
// OpenX doesn't support multi-type impressions.
Expand Down
6 changes: 4 additions & 2 deletions adapters/openx/openxtest/exemplary/fledge.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"adm": "some-test-ad",
"crid": "crid_10",
"h": 90,
"w": 728
"w": 728,
"mtype": 1
}]
}
],
Expand Down Expand Up @@ -91,7 +92,8 @@
"adm": "some-test-ad",
"crid": "crid_10",
"w": 728,
"h": 90
"h": 90,
"mtype": 1
},
"type": "banner"
}
Expand Down
6 changes: 4 additions & 2 deletions adapters/openx/openxtest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}",
"crid": "crid_10",
"h": 90,
"w": 728
"w": 728,
"mtype": 1
}]
}
],
Expand All @@ -75,7 +76,8 @@
"adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}",
"crid": "crid_10",
"w": 728,
"h": 90
"h": 90,
"mtype": 1
},
"type": "banner"
}
Expand Down
8 changes: 5 additions & 3 deletions adapters/openx/openxtest/exemplary/simple-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}",
"crid": "crid_10",
"w": 300,
"h": 200
"h": 200,
"mtype": 4
}]
}
]
Expand All @@ -77,11 +78,12 @@
"adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}",
"crid": "crid_10",
"w": 300,
"h": 200
"h": 200,
"mtype": 4
},
"type": "native"
}
]
}
]
}
}
6 changes: 4 additions & 2 deletions adapters/openx/openxtest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"h": 576,
"cattax": 1,
"cat": ["IAB20"],
"dur": 30
"dur": 30,
"mtype": 2
}]
}
]
Expand All @@ -88,7 +89,8 @@
"h": 576,
"cattax": 1,
"cat": ["IAB20"],
"dur": 30
"dur": 30,
"mtype": 2
},
"video": {
"duration": 30,
Expand Down
6 changes: 4 additions & 2 deletions adapters/openx/openxtest/exemplary/video-rewarded.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"adm": "some-test-ad",
"crid": "crid_10",
"w": 1024,
"h": 576
"h": 576,
"mtype": 2
}]
}
]
Expand All @@ -92,7 +93,8 @@
"adm": "some-test-ad",
"crid": "crid_10",
"w": 1024,
"h": 576
"h": 576,
"mtype": 2
},
"type": "video"
}
Expand Down
Loading

0 comments on commit 8b7c575

Please sign in to comment.