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

Adkernel: bid.mtype support #3631

Merged
merged 3 commits into from
Apr 25, 2024
Merged
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
52 changes: 21 additions & 31 deletions adapters/adkernel/adkernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,48 +259,38 @@ func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb2.BidRequest, e
bidResponse.Currency = bidResp.Cur
for i := 0; i < len(seatBid.Bid); i++ {
bid := seatBid.Bid[i]
origImpId := bid.ImpID
typeSuffix := ""
if strings.HasSuffix(origImpId, mf_suffix) {
sfxStart := len(origImpId) - len(mf_suffix) - 1
typeSuffix = origImpId[sfxStart:]
bid.ImpID = origImpId[:sfxStart]
if strings.HasSuffix(bid.ImpID, mf_suffix) {
sfxStart := len(bid.ImpID) - len(mf_suffix) - 1
bid.ImpID = bid.ImpID[:sfxStart]
}
bidType, err := getMediaTypeForBid(&bid)
if err != nil {
return nil, []error{err}
}
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: getMediaTypeForImpID(bid.ImpID, typeSuffix, internalRequest.Imp),
BidType: bidType,
})
}
return bidResponse, nil
}

// getMediaTypeForImp figures out which media type this bid is for
func getMediaTypeForImpID(impID string, typeSuffix string, imps []openrtb2.Imp) openrtb_ext.BidType {
if len(typeSuffix) > 0 {
if typeSuffix == mf_suffix_banner {
return openrtb_ext.BidTypeBanner
} else if typeSuffix == mf_suffix_video {
return openrtb_ext.BidTypeVideo
} else if typeSuffix == mf_suffix_audio {
return openrtb_ext.BidTypeAudio
} else if typeSuffix == mf_suffix_native {
return openrtb_ext.BidTypeNative
}
}
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner != nil {
return openrtb_ext.BidTypeBanner
} else if imp.Video != nil {
return openrtb_ext.BidTypeVideo
} else if imp.Audio != nil {
return openrtb_ext.BidTypeAudio
} else if imp.Native != nil {
return openrtb_ext.BidTypeNative
}
func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupAudio:
return openrtb_ext.BidTypeAudio, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
default:
return "", &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unsupported MType %d", bid.MType),
}
}
return openrtb_ext.BidTypeVideo
}

func newBadInputError(message string) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"crid": "2002",
"adid": "2002",
"adm": "<!-- admarkup -->",
"mtype": 1,
"adomain": [
"tag-example.com"
]
Expand All @@ -102,6 +103,7 @@
"crid": "702",
"adid": "702",
"adm": "<!-- native response -->",
"mtype": 4,
"adomain": [
"tag-example.com"
]
Expand All @@ -114,6 +116,7 @@
"crid": "172",
"adid": "172",
"nurl": "http://adkernel.com/win?f=nurl",
"mtype": 3,
"adomain": [
"tag-example.com"
]
Expand Down Expand Up @@ -141,7 +144,8 @@
],
"cid": "1001",
"adid": "2002",
"crid": "2002"
"crid": "2002",
"mtype": 1
},
"type": "banner"
},
Expand All @@ -156,7 +160,8 @@
],
"cid": "601",
"crid": "702",
"adid": "702"
"adid": "702",
"mtype": 4
},
"type": "native"
},
Expand All @@ -171,7 +176,8 @@
],
"cid": "161",
"crid": "172",
"adid": "172"
"adid": "172",
"mtype": 3
},
"type": "audio"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"adid": "19005",
"adm": "<!-- admarkup -->",
"cat": ["IAB2"],
"mtype": 1,
"adomain": ["test.com"],
"h": 250,
"w": 300
Expand Down Expand Up @@ -92,7 +93,8 @@
"crid": "19005",
"w": 300,
"h": 250,
"cat": ["IAB2"]
"cat": ["IAB2"],
"mtype": 1
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"cat": [
"IAB2"
],
"mtype": 2,
"adomain": [
"video-example.com"
]
Expand Down Expand Up @@ -105,7 +106,8 @@
"crid": "2002",
"cat": [
"IAB2"
]
],
"mtype": 2
},
"type": "video"
}
Expand Down
Loading