Skip to content

Commit

Permalink
Rubicon: hardcode EUR to USD for floors (prebid#1899)
Browse files Browse the repository at this point in the history
Co-authored-by: Serhii Nahornyi <snahornyi@rubiconproject.com>
  • Loading branch information
2 people authored and shunj-nb committed Nov 8, 2022
1 parent e77db21 commit be65b55
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
15 changes: 15 additions & 0 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
continue
}

resolvedBidFloor, resolvedBidFloorCur := resolveBidFloorAttributes(thisImp.BidFloor, thisImp.BidFloorCur)
thisImp.BidFloorCur = resolvedBidFloorCur
thisImp.BidFloor = resolvedBidFloor

if request.User != nil {
userCopy := *request.User
userExtRP := rubiconUserExt{RP: rubiconUserExtRP{Target: rubiconExt.Visitor}}
Expand Down Expand Up @@ -893,6 +897,17 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
return requestData, errs
}

// Will be replaced after https://github.com/prebid/prebid-server/issues/1482 resolution
func resolveBidFloorAttributes(bidFloor float64, bidFloorCur string) (float64, string) {
if bidFloor > 0 {
if strings.ToUpper(bidFloorCur) == "EUR" {
return bidFloor * 1.2, "USD"
}
}

return bidFloor, bidFloorCur
}

func updateUserExtWithIabAttribute(userExtRP *rubiconUserExt, data []openrtb2.Data) error {
var segmentIdsToCopy = make([]string, 0)

Expand Down
46 changes: 46 additions & 0 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,52 @@ func TestResolveVideoSizeId(t *testing.T) {
}
}

func TestResolveBidFloorAttributes(t *testing.T) {
testScenarios := []struct {
bidFloor float64
bidFloorCur string
expectedBidFloor float64
expectedBidFloorCur string
}{
{
bidFloor: 1,
bidFloorCur: "EUR",
expectedBidFloor: 1.2,
expectedBidFloorCur: "USD",
},
{
bidFloor: 1,
bidFloorCur: "Eur",
expectedBidFloor: 1.2,
expectedBidFloorCur: "USD",
},
{
bidFloor: 0,
bidFloorCur: "EUR",
expectedBidFloor: 0,
expectedBidFloorCur: "EUR",
},
{
bidFloor: -1,
bidFloorCur: "EUR",
expectedBidFloor: -1,
expectedBidFloorCur: "EUR",
},
{
bidFloor: 1,
bidFloorCur: "USD",
expectedBidFloor: 1,
expectedBidFloorCur: "USD",
},
}

for _, scenario := range testScenarios {
bidFloor, bidFloorCur := resolveBidFloorAttributes(scenario.bidFloor, scenario.bidFloorCur)
assert.Equal(t, scenario.expectedBidFloor, bidFloor)
assert.Equal(t, scenario.expectedBidFloorCur, bidFloorCur)
}
}

func TestNoContentResponse(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)
Expand Down
4 changes: 4 additions & 0 deletions adapters/rubicon/rubicontest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"w": 1024,
"h": 576
},
"bidfloor": 1,
"bidfloorcur": "EuR",
"ext": {
"bidder": {
"video": {
Expand Down Expand Up @@ -192,6 +194,8 @@
"w": 1024,
"h": 576
},
"bidfloor": 1.2,
"bidfloorcur": "USD",
"ext": {
"rp": {
"track": {
Expand Down

0 comments on commit be65b55

Please sign in to comment.