Skip to content

Commit

Permalink
change getMediaTypeForBid(), use mtype to get bid type in response.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilder0601 committed Jan 25, 2024
1 parent 188fcfc commit ed5fec3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
30 changes: 13 additions & 17 deletions adapters/adview/adview.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
var errors []error
for _, seatBid := range response.SeatBid {
for i, bid := range seatBid.Bid {
bidType, err := getMediaTypeForBid(bid, request.Imp)
bidType, err := getMediaTypeForBid(bid)
if err != nil {
errors = append(errors, err)
continue
Expand Down Expand Up @@ -178,23 +178,19 @@ func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType,
return mediaType, nil
}

func getMediaTypeForBid(bid openrtb2.Bid, reqImps []openrtb2.Imp) (openrtb_ext.BidType, error) {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range reqImps {
if bid.ImpID == imp.ID {
if bid.Ext != nil {
var bidExt *adviewBidExt
err := json.Unmarshal(bid.Ext, &bidExt)
if err == nil {
return getBidType(bidExt)
} else {
return mediaType, err
}
}
return mediaType, nil
}
func getMediaTypeForBid(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.MarkupAudio:
return openrtb_ext.BidTypeAudio, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("Unable to fetch mediaType in multi-format: %s", bid.ImpID)
}
return mediaType, nil
}

// getBidType returns the bid type specified in the response bid.ext
Expand Down
2 changes: 2 additions & 0 deletions adapters/adview/adviewtest/exemplary/banner-app-format.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"crid": "20",
"w": 320,
"h": 50,
"mtype": 1,
"ext": {
"formattype": 0
}
Expand Down Expand Up @@ -152,6 +153,7 @@
"crid": "20",
"w": 320,
"h": 50,
"mtype": 1,
"ext": {
"formattype": 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
],
"crid": "20",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
}
],
"type": "banner",
Expand Down Expand Up @@ -138,7 +139,8 @@
],
"crid": "20",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
},
"type": "banner"
}
Expand Down
2 changes: 2 additions & 0 deletions adapters/adview/adviewtest/exemplary/banner-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"crid": "20",
"w": 320,
"h": 50,
"mtype": 1,
"ext": {
"formattype": 0
}
Expand Down Expand Up @@ -142,6 +143,7 @@
"crid": "20",
"w": 320,
"h": 50,
"mtype": 1,
"ext": {
"formattype": 0
}
Expand Down
2 changes: 2 additions & 0 deletions adapters/adview/adviewtest/exemplary/native-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"awesome.com"
],
"crid": "20",
"mtype": 4,
"ext": {
"formattype": 2
}
Expand Down Expand Up @@ -135,6 +136,7 @@
"price": 3.5,
"adm": "awesome-markup",
"crid": "20",
"mtype": 4,
"adomain": [
"awesome.com"
],
Expand Down
2 changes: 2 additions & 0 deletions adapters/adview/adviewtest/exemplary/video-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"crid": "20",
"w": 1280,
"h": 720,
"mtype": 2,
"ext": {
"formattype": 1
}
Expand Down Expand Up @@ -151,6 +152,7 @@
],
"w": 1280,
"h": 720,
"mtype": 2,
"ext": {
"formattype": 1
}
Expand Down

0 comments on commit ed5fec3

Please sign in to comment.