Skip to content

Commit

Permalink
Adding creative type check in pubmatic adapter (prebid#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
PubMatic-OpenWrap authored and dbemiller committed Jul 9, 2018
1 parent 949d490 commit 0fd8dd2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions adapters/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/golang/glog"
"github.com/mxmCherry/openrtb"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/prebid/prebid-server/pbs"
"golang.org/x/net/context/ctxhttp"
)
Expand Down Expand Up @@ -227,6 +228,9 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder
DealId: bid.DealID,
}

mediaType := getMediaTypeForImp(bid.ImpID, pbReq.Imp)
pbid.CreativeMediaType = string(mediaType)

bids = append(bids, &pbid)
logf("[PUBMATIC] Returned Bid for PubID [%s] AdUnit [%s] BidID [%s] Size [%dx%d] Price [%f] \n",
pubId, pbid.AdUnitCode, pbid.BidID, pbid.Width, pbid.Height, pbid.Price)
Expand All @@ -236,6 +240,24 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder
return bids, nil
}

// getMediaTypeForImp figures out which media type this bid is for.
func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impId {
if imp.Video != nil {
mediaType = openrtb_ext.BidTypeVideo
} else if imp.Audio != nil {
mediaType = openrtb_ext.BidTypeAudio
} else if imp.Native != nil {
mediaType = openrtb_ext.BidTypeNative
}
return mediaType
}
}
return mediaType
}

func logf(msg string, args ...interface{}) {
if glog.V(2) {
glog.Infof(msg, args)
Expand Down

0 comments on commit 0fd8dd2

Please sign in to comment.