Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SylviaF authored May 28, 2024
2 parents 409161e + 9133d2c commit 3a8f603
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
25 changes: 11 additions & 14 deletions adapters/medianet/medianet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest

for _, sb := range bidResp.SeatBid {
for i := range sb.Bid {
bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp)
bidType, err := getBidMediaTypeFromMtype(&sb.Bid[i])
if err != nil {
errs = append(errs, err)
} else {
Expand All @@ -90,19 +90,16 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co
}, nil
}

func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner == nil && imp.Video != nil {
mediaType = openrtb_ext.BidTypeVideo
}
return mediaType, nil
}
}

return "", &errortypes.BadInput{
Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID),
func getBidMediaTypeFromMtype(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("Unable to fetch mediaType for imp: %s", bid.ImpID)
}
}

Expand Down
6 changes: 4 additions & 2 deletions adapters/medianet/medianettest/exemplary/multi-imps.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"h": 50,
"w": 320
"w": 320,
"mtype": 1
}
]
}
Expand All @@ -123,7 +124,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
},
"type": "banner"
}
Expand Down
6 changes: 4 additions & 2 deletions adapters/medianet/medianettest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"h": 50,
"w": 320
"w": 320,
"mtype": 1
}
]
}
Expand All @@ -89,7 +90,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
},
"type": "banner"
}
Expand Down
6 changes: 4 additions & 2 deletions adapters/medianet/medianettest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 480
"h": 480,
"mtype": 2
}
]
}
Expand All @@ -92,7 +93,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 480
"h": 480,
"mtype": 2
},
"type": "video"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
"cid": "987",
"crid": "12345678",
"h": 250,
"w": 300
"w": 300,
"mtype": 1
}
]
}
Expand All @@ -123,7 +124,8 @@
"cid": "987",
"crid": "12345678",
"h": 250,
"w": 300
"w": 300,
"mtype": 1
},
"type": "banner"
}]
Expand Down

0 comments on commit 3a8f603

Please sign in to comment.