Skip to content

Commit

Permalink
Adkernel: bid.mtype support (prebid#3631)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckbo3hrk authored Apr 25, 2024
1 parent e8ff959 commit 78dd64d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
52 changes: 21 additions & 31 deletions adapters/adkernel/adkernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,48 +260,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 @@ -91,6 +91,7 @@
"crid": "2002",
"adid": "2002",
"adm": "<!-- admarkup -->",
"mtype": 1,
"adomain": [
"tag-example.com"
]
Expand All @@ -103,6 +104,7 @@
"crid": "702",
"adid": "702",
"adm": "<!-- native response -->",
"mtype": 4,
"adomain": [
"tag-example.com"
]
Expand All @@ -115,6 +117,7 @@
"crid": "172",
"adid": "172",
"nurl": "http://adkernel.com/win?f=nurl",
"mtype": 3,
"adomain": [
"tag-example.com"
]
Expand Down Expand Up @@ -142,7 +145,8 @@
],
"cid": "1001",
"adid": "2002",
"crid": "2002"
"crid": "2002",
"mtype": 1
},
"type": "banner"
},
Expand All @@ -157,7 +161,8 @@
],
"cid": "601",
"crid": "702",
"adid": "702"
"adid": "702",
"mtype": 4
},
"type": "native"
},
Expand All @@ -172,7 +177,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 @@ -65,6 +65,7 @@
"adid": "19005",
"adm": "<!-- admarkup -->",
"cat": ["IAB2"],
"mtype": 1,
"adomain": ["test.com"],
"h": 250,
"w": 300
Expand Down Expand Up @@ -93,7 +94,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 @@ -76,6 +76,7 @@
"cat": [
"IAB2"
],
"mtype": 2,
"adomain": [
"video-example.com"
]
Expand Down Expand Up @@ -106,7 +107,8 @@
"crid": "2002",
"cat": [
"IAB2"
]
],
"mtype": 2
},
"type": "video"
}
Expand Down

0 comments on commit 78dd64d

Please sign in to comment.