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

OpenX: Determine bid type from bid.mtype #4241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading