Skip to content

Commit

Permalink
Merge remote-tracking branch 'prebid/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanivplaydigo committed Apr 25, 2024
2 parents 93b554f + 5e7c824 commit 36dae66
Show file tree
Hide file tree
Showing 41 changed files with 2,966 additions and 42 deletions.
52 changes: 21 additions & 31 deletions adapters/adkernel/adkernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,48 +260,38 @@ func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb2.BidRequest, e
bidResponse.Currency = bidResp.Cur
for i := 0; i < len(seatBid.Bid); i++ {
bid := seatBid.Bid[i]
origImpId := bid.ImpID
typeSuffix := ""
if strings.HasSuffix(origImpId, mf_suffix) {
sfxStart := len(origImpId) - len(mf_suffix) - 1
typeSuffix = origImpId[sfxStart:]
bid.ImpID = origImpId[:sfxStart]
if strings.HasSuffix(bid.ImpID, mf_suffix) {
sfxStart := len(bid.ImpID) - len(mf_suffix) - 1
bid.ImpID = bid.ImpID[:sfxStart]
}
bidType, err := getMediaTypeForBid(&bid)
if err != nil {
return nil, []error{err}
}
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: getMediaTypeForImpID(bid.ImpID, typeSuffix, internalRequest.Imp),
BidType: bidType,
})
}
return bidResponse, nil
}

// getMediaTypeForImp figures out which media type this bid is for
func getMediaTypeForImpID(impID string, typeSuffix string, imps []openrtb2.Imp) openrtb_ext.BidType {
if len(typeSuffix) > 0 {
if typeSuffix == mf_suffix_banner {
return openrtb_ext.BidTypeBanner
} else if typeSuffix == mf_suffix_video {
return openrtb_ext.BidTypeVideo
} else if typeSuffix == mf_suffix_audio {
return openrtb_ext.BidTypeAudio
} else if typeSuffix == mf_suffix_native {
return openrtb_ext.BidTypeNative
}
}
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner != nil {
return openrtb_ext.BidTypeBanner
} else if imp.Video != nil {
return openrtb_ext.BidTypeVideo
} else if imp.Audio != nil {
return openrtb_ext.BidTypeAudio
} else if imp.Native != nil {
return openrtb_ext.BidTypeNative
}
func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupAudio:
return openrtb_ext.BidTypeAudio, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
default:
return "", &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unsupported MType %d", bid.MType),
}
}
return openrtb_ext.BidTypeVideo
}

func newBadInputError(message string) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"crid": "2002",
"adid": "2002",
"adm": "<!-- admarkup -->",
"mtype": 1,
"adomain": [
"tag-example.com"
]
Expand All @@ -103,6 +104,7 @@
"crid": "702",
"adid": "702",
"adm": "<!-- native response -->",
"mtype": 4,
"adomain": [
"tag-example.com"
]
Expand All @@ -115,6 +117,7 @@
"crid": "172",
"adid": "172",
"nurl": "http://adkernel.com/win?f=nurl",
"mtype": 3,
"adomain": [
"tag-example.com"
]
Expand Down Expand Up @@ -142,7 +145,8 @@
],
"cid": "1001",
"adid": "2002",
"crid": "2002"
"crid": "2002",
"mtype": 1
},
"type": "banner"
},
Expand All @@ -157,7 +161,8 @@
],
"cid": "601",
"crid": "702",
"adid": "702"
"adid": "702",
"mtype": 4
},
"type": "native"
},
Expand All @@ -172,7 +177,8 @@
],
"cid": "161",
"crid": "172",
"adid": "172"
"adid": "172",
"mtype": 3
},
"type": "audio"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"adid": "19005",
"adm": "<!-- admarkup -->",
"cat": ["IAB2"],
"mtype": 1,
"adomain": ["test.com"],
"h": 250,
"w": 300
Expand Down Expand Up @@ -93,7 +94,8 @@
"crid": "19005",
"w": 300,
"h": 250,
"cat": ["IAB2"]
"cat": ["IAB2"],
"mtype": 1
},
"type": "banner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"cat": [
"IAB2"
],
"mtype": 2,
"adomain": [
"video-example.com"
]
Expand Down Expand Up @@ -106,7 +107,8 @@
"crid": "2002",
"cat": [
"IAB2"
]
],
"mtype": 2
},
"type": "video"
}
Expand Down
23 changes: 21 additions & 2 deletions adapters/conversant/conversant.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"

"github.com/prebid/openrtb/v20/adcom1"
"github.com/prebid/openrtb/v20/openrtb2"
Expand All @@ -18,6 +19,10 @@ type ConversantAdapter struct {
}

func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
//Backend needs USD or it will reject the request
if len(request.Cur) > 0 && request.Cur[0] != "USD" {
request.Cur = []string{"USD"}
}
for i := 0; i < len(request.Imp); i++ {
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(request.Imp[i].Ext, &bidderExt); err != nil {
Expand Down Expand Up @@ -50,7 +55,10 @@ func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *
request.App.ID = cnvrExt.SiteID
}
}
parseCnvrParams(&request.Imp[i], cnvrExt)
err := parseCnvrParams(&request.Imp[i], cnvrExt, reqInfo)
if err != nil {
return nil, err
}
}

//create the request body
Expand All @@ -73,7 +81,7 @@ func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *
}}, nil
}

func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant) {
func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant, reqInfo *adapters.ExtraRequestInfo) []error {
imp.DisplayManager = "prebid-s2s"
imp.DisplayManagerVer = "2.0.0"

Expand Down Expand Up @@ -131,6 +139,17 @@ func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant) {
imp.Video.MaxDuration = *cnvrExt.MaxDuration
}
}
if imp.BidFloor > 0 && imp.BidFloorCur != "" && strings.ToUpper(imp.BidFloorCur) != "USD" {
floor, err := reqInfo.ConvertCurrency(imp.BidFloor, imp.BidFloorCur, "USD")
if err != nil {
return []error{&errortypes.BadInput{
Message: fmt.Sprintf("Unable to convert provided bid floor currency from %s to USD", imp.BidFloorCur),
}}
}
imp.BidFloorCur = "USD"
imp.BidFloor = floor
}
return nil
}

func (c *ConversantAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
Expand Down
27 changes: 24 additions & 3 deletions adapters/conversant/conversanttest/exemplary/video.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"mockBidRequest": {
"id": "testauction",
"cur": ["EUR"],
"imp": [
{
"id": "1",
"video": {
"w": 300,
"h": 250
},
"bidfloor": 2.00,
"bidfloorcur": "EUR",
"ext": {
"bidder": {
"site_id": "108060",
"bidfloor": 0.01,
"tag_id": "mytag",
"secure": 1,
"mimes": ["video/mp4", "video/x-flv"],
Expand All @@ -31,6 +33,15 @@
},
"site": {
"domain": "www.mypage.com"
},
"ext": {
"prebid": {
"currency": {
"rates": {
"USD": {"EUR": 0.08}
}
}
}
}
},
"httpCalls": [
Expand All @@ -39,6 +50,7 @@
"uri": "",
"body": {
"id": "testauction",
"cur": ["USD"],
"site": {
"id": "108060",
"domain": "www.mypage.com"
Expand All @@ -48,7 +60,8 @@
"id": "1",
"tagid": "mytag",
"secure": 1,
"bidfloor": 0.01,
"bidfloor": 25.0,
"bidfloorcur": "USD",
"displaymanager": "prebid-s2s",
"displaymanagerver": "2.0.0",
"video": {
Expand All @@ -66,7 +79,6 @@
"ext": {
"bidder": {
"site_id": "108060",
"bidfloor": 0.01,
"tag_id": "mytag",
"secure": 1,
"mimes": [
Expand All @@ -86,6 +98,15 @@
"ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36",
"ip": "192.168.1.1",
"dnt": 1
},
"ext": {
"prebid": {
"currency": {
"rates": {
"USD": {"EUR": 0.08}
}
}
}
}
},
"impIDs":["1"]
Expand Down
Loading

0 comments on commit 36dae66

Please sign in to comment.