Skip to content

Commit ff8b87f

Browse files
Vungle Correct Media Type (#116)
1 parent 821374a commit ff8b87f

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

adapters/vungle/vungle.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,15 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
152152
for i := range seatBid.Bid {
153153
// NewsBreak Custom SDK Logic Begins
154154
seatBid.Bid[i].Ext = extBytes
155+
mediaType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp)
156+
if err != nil {
157+
return nil, []error{err}
158+
}
155159
// NewsBreak Custom SDK Logic Ends
156160

157161
b := &adapters.TypedBid{
158162
Bid: &seatBid.Bid[i],
159-
BidType: openrtb_ext.BidTypeVideo,
163+
BidType: mediaType,
160164
Seat: openrtb_ext.BidderName(seatBid.Seat),
161165
}
162166

@@ -180,3 +184,28 @@ func getAdUnitIdForImp(imps []openrtb2.Imp) string {
180184
}
181185
return adUnitId
182186
}
187+
188+
func getMediaTypeForImp(impId string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
189+
var mediaType openrtb_ext.BidType
190+
var typeCnt = 0
191+
for _, imp := range imps {
192+
if imp.ID == impId {
193+
if imp.Banner != nil {
194+
typeCnt += 1
195+
mediaType = openrtb_ext.BidTypeBanner
196+
}
197+
if imp.Native != nil {
198+
typeCnt += 1
199+
mediaType = openrtb_ext.BidTypeNative
200+
}
201+
if imp.Video != nil {
202+
typeCnt += 1
203+
mediaType = openrtb_ext.BidTypeVideo
204+
}
205+
}
206+
}
207+
if typeCnt == 1 {
208+
return mediaType, nil
209+
}
210+
return mediaType, fmt.Errorf("Vungle unable to fetch mediaType in multi-format: %s", impId)
211+
}

0 commit comments

Comments
 (0)