Skip to content

Commit

Permalink
OTT-1687: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishshinde-pubm committed Mar 28, 2024
1 parent 1c28d86 commit e08c86f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 76 deletions.
20 changes: 8 additions & 12 deletions adapters/ortbbidder/ortbbidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (o *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
if request == nil || requestInfo == nil {
return nil, []error{fmt.Errorf("Found either nil request or nil requestInfo")}
}
var errs []error
adapterInfo := o.adapterInfo
// bidder request supports single impression in single HTTP call.
if adapterInfo.requestMode == RequestModeSingle {
Expand All @@ -73,11 +74,12 @@ func (o *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
requestCopy.Imp = []openrtb2.Imp{imp} // requestCopy contains single impression
reqData, err := adapterInfo.prepareRequestData(&requestCopy)
if err != nil {
return nil, []error{err}
errs = append(errs, err)
continue
}
requestData = append(requestData, reqData)
}
return requestData, nil
return requestData, errs
}
// bidder request supports multi impressions in single HTTP call.
requestData, err := adapterInfo.prepareRequestData(request)
Expand Down Expand Up @@ -108,14 +110,9 @@ func (o *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
var errs []error
for _, seatBid := range response.SeatBid {
for bidInd, bid := range seatBid.Bid {
bidType, err := getMediaTypeForBid(bid)
if err != nil {
errs = append(errs, err)
continue
}
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &seatBid.Bid[bidInd],
BidType: bidType,
BidType: getMediaTypeForBid(bid),
})
}
}
Expand All @@ -124,7 +121,7 @@ func (o *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R

// getMediaTypeForBid returns the BidType as per the bid.MType field
// bid.MType has high priority over bidExt.Prebid.Type
func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) {
func getMediaTypeForBid(bid openrtb2.Bid) openrtb_ext.BidType {
var bidType openrtb_ext.BidType
if bid.MType > 0 {
bidType = getMediaTypeForBidFromMType(bid.MType)
Expand All @@ -137,11 +134,10 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) {
}
}
}
// TODO : detect mediatype from bid.AdM and request.imp parameter
if bidType == "" {
return bidType, fmt.Errorf("Failed to parse bid mType for bidID \"%s\"", bid.ID)
// TODO : detect mediatype from bid.AdM and request.imp parameter
}
return bidType, nil
return bidType
}

// getMediaTypeForBidFromMType returns the bidType from the MarkupType field
Expand Down
36 changes: 1 addition & 35 deletions adapters/ortbbidder/ortbbidder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,6 @@ func TestMakeBids(t *testing.T) {
}},
},
},
{
name: "getMediaTypeForBid_returns_error",
args: args{
responseData: &adapters.ResponseData{
StatusCode: http.StatusOK,
Body: []byte(`{"id":"bid-resp-id","seatbid":[{"seat":"test_bidder","bid":[{"id":"bid-1","mtype":2},{"id":"bid-2","mtype":5}]}]}`),
},
},
want: want{
response: &adapters.BidderResponse{
Bids: []*adapters.TypedBid{
{
Bid: &openrtb2.Bid{
ID: "bid-1",
MType: 2,
},
BidType: "video",
},
},
},
errors: []error{fmt.Errorf("Failed to parse bid mType for bidID \"bid-2\"")},
},
},
{
name: "valid_response",
args: args{
Expand Down Expand Up @@ -219,7 +196,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
}
type want struct {
bidType openrtb_ext.BidType
err error
}
tests := []struct {
name string
Expand All @@ -233,7 +209,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: openrtb_ext.BidTypeBanner,
err: nil,
},
},
{
Expand All @@ -243,7 +218,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: openrtb_ext.BidTypeVideo,
err: nil,
},
},
{
Expand All @@ -253,7 +227,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: openrtb_ext.BidTypeAudio,
err: nil,
},
},
{
Expand All @@ -263,7 +236,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: openrtb_ext.BidTypeNative,
err: nil,
},
},
{
Expand All @@ -273,7 +245,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: "",
err: fmt.Errorf("Failed to parse bid mType for bidID \"5\""),
},
},
{
Expand All @@ -283,7 +254,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: "video",
err: nil,
},
},
{
Expand All @@ -293,7 +263,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: "",
err: fmt.Errorf("Failed to parse bid mType for bidID \"5\""),
},
},
{
Expand All @@ -303,7 +272,6 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: "",
err: fmt.Errorf("Failed to parse bid mType for bidID \"5\""),
},
},
{
Expand All @@ -313,15 +281,13 @@ func TestGetMediaTypeForBid(t *testing.T) {
},
want: want{
bidType: "banner",
err: nil,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
bidType, err := getMediaTypeForBid(tt.args.bid)
bidType := getMediaTypeForBid(tt.args.bid)
assert.Equal(t, tt.want.bidType, bidType, "mismatched bidType")
assert.Equal(t, tt.want.err, err, "mismatched error")
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions openrtb_ext/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ var coreBidderNames []BidderName = []BidderName{
BidderOpenx,
BidderOperaads,
BidderOrbidder,
BidderORTBMagnite,
BidderOutbrain,
BidderOwnAdx,
BidderPangle,
Expand Down Expand Up @@ -229,6 +228,7 @@ var coreBidderNames []BidderName = []BidderName{
BidderYieldone,
BidderZeroClickFraud,
BidderZetaGlobalSsp,
BidderORTBMagnite, // maintained by OW
}

func GetAliasBidderToParent() map[BidderName]BidderName {
Expand Down Expand Up @@ -457,7 +457,6 @@ const (
BidderOpenx BidderName = "openx"
BidderOperaads BidderName = "operaads"
BidderOrbidder BidderName = "orbidder"
BidderORTBMagnite BidderName = "ortb_magnite" // OW specific: oRTB bidder for magnite
BidderOutbrain BidderName = "outbrain"
BidderOwnAdx BidderName = "ownadx"
BidderPangle BidderName = "pangle"
Expand Down Expand Up @@ -527,6 +526,7 @@ const (
BidderYieldone BidderName = "yieldone"
BidderZeroClickFraud BidderName = "zeroclickfraud"
BidderZetaGlobalSsp BidderName = "zeta_global_ssp"
BidderORTBMagnite BidderName = "owortb_magnite" // OW specific: oRTB bidder for magnite
)

// CoreBidderNames returns a slice of all core bidders.
Expand Down
27 changes: 0 additions & 27 deletions static/bidder-info/ortb_magnite.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions static/bidder-info/owortb_magnite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# sample bidder-info yaml for testing purpose
#endpoint: "https://hbopenbid.pubmatic.com/translator?source=prebid-server"
maintainer:
email: "[email protected]"
File renamed without changes.

0 comments on commit e08c86f

Please sign in to comment.