Skip to content

Commit

Permalink
update bigoad adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhucheng committed May 30, 2024
1 parent a40121d commit 74967e9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
30 changes: 13 additions & 17 deletions adapters/bigoad/bigoad.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,11 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData

bidResponseWithCapacity := adapters.NewBidderResponseWithBidsCapacity(len(bidResponse.SeatBid[0].Bid))

// impMap := map[string]*openrtb2.Imp{}
// for i := range request.Imp {
// imp := request.Imp[i]
// impMap[imp.ID] = &imp
// }

var errors []error
seatBid := bidResponse.SeatBid[0]
for _, bid := range seatBid.Bid {
// imp, exists := impMap[bid.ImpID]
// if !exists {
// errors = append(errors, &errortypes.BadInput{
// Message: fmt.Sprintf("Invalid bid imp ID #%s does not match any imp IDs from the original bid request", bid.ImpID),
// })
// continue
// }
bidType, err := getBidType(request.Imp[0])
for i := range seatBid.Bid {
bid := seatBid.Bid[i]
bidType, err := getBidType(request.Imp[0], bid)
if err != nil {
errors = append(errors, err)
continue
Expand All @@ -152,7 +140,15 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData
return bidResponseWithCapacity, errors
}

func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) {
func getBidType(imp openrtb2.Imp, bid openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
}
if imp.Native != nil {
return openrtb_ext.BidTypeNative, nil
} else if imp.Banner != nil {
Expand All @@ -162,6 +158,6 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) {
}

return "", &errortypes.BadInput{
Message: fmt.Sprintf("Processing an invalid impression; cannot resolve impression type for imp #%s", imp.ID),
Message: fmt.Sprintf("unrecognized bid type in response from bigoad %s", imp.ID),
}
}
2 changes: 2 additions & 0 deletions adapters/bigoad/bigoadtest/exemplary/banner_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"id": "test-imp-id",
"impid": "test-imp-id",
"adid": "11110126",
"mtype": 1,
"price": 0.42632559,
"adm": "some-test-ad",
"adomain": [
Expand Down Expand Up @@ -161,6 +162,7 @@
"adid": "11110126",
"price": 0.42632559,
"adm": "some-test-ad",
"mtype": 1,
"adomain": [
"www.lazada.com"
],
Expand Down
4 changes: 3 additions & 1 deletion adapters/bigoad/bigoadtest/exemplary/native_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"adomain": [
"awesome.com"
],
"crid": "20"
"crid": "20",
"mtype": 4
}
],
"type": "native",
Expand All @@ -135,6 +136,7 @@
"price": 3.5,
"adm": "awesome-markup",
"crid": "20",
"mtype": 4,
"adomain": [
"awesome.com"
]
Expand Down
6 changes: 4 additions & 2 deletions adapters/bigoad/bigoadtest/exemplary/video_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
],
"crid": "20",
"w": 1280,
"h": 720
"h": 720,
"mtype": 2
}
],
"seat": "bigoad"
Expand All @@ -150,7 +151,8 @@
"awesome.com"
],
"w": 1280,
"h": 720
"h": 720,
"mtype": 2
},
"type": "video"
}
Expand Down
2 changes: 1 addition & 1 deletion openrtb_ext/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ const (
BidderBidmyadz BidderName = "bidmyadz"
BidderBidsCube BidderName = "bidscube"
BidderBidstack BidderName = "bidstack"
BidderBigoAd BidderName = "bigoad"
BidderBizzclick BidderName = "bizzclick"
BidderBliink BidderName = "bliink"
BidderBlue BidderName = "blue"
Expand Down Expand Up @@ -511,7 +512,6 @@ const (
BidderZeroClickFraud BidderName = "zeroclickfraud"
BidderZetaGlobalSsp BidderName = "zeta_global_ssp"
BidderZmaticoo BidderName = "zmaticoo"
BidderBigoAd BidderName = "bigoad"
)

// CoreBidderNames returns a slice of all core bidders.
Expand Down

0 comments on commit 74967e9

Please sign in to comment.