Skip to content

Commit

Permalink
Rubicon: Update video size-id logic (#3917)
Browse files Browse the repository at this point in the history
Co-authored-by: ddubyk <[email protected]>
  • Loading branch information
CTMBNara and ddubyk authored Dec 13, 2024
1 parent 78d07be commit b2023fd
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 126 deletions.
46 changes: 6 additions & 40 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prebid/prebid-server/v3/util/maputil"

"github.com/buger/jsonparser"
"github.com/prebid/openrtb/v20/adcom1"
"github.com/prebid/openrtb/v20/openrtb2"
)

Expand Down Expand Up @@ -174,34 +173,6 @@ type extPrebid struct {
Bidder json.RawMessage `json:"bidder,omitempty"`
}

// defines the contract for bidrequest.user.ext.eids[i].ext
type rubiconUserExtEidExt struct {
Segments []string `json:"segments,omitempty"`
}

type mappedRubiconUidsParam struct {
segments []string
liverampIdl string
}

func resolveVideoSizeId(placement adcom1.VideoPlacementSubtype, instl int8, impId string) (sizeID int, err error) {
if placement != 0 {
if placement == 1 {
return 201, nil
}
if placement == 3 {
return 203, nil
}
}

if instl == 1 {
return 202, nil
}
return 0, &errortypes.BadInput{
Message: fmt.Sprintf("video.size_id can not be resolved in impression with id : %s", impId),
}
}

func appendTrackerToUrl(uri string, tracker string) (res string) {
// Append integration method. Adapter init happens once
urlObject, err := url.Parse(uri)
Expand Down Expand Up @@ -374,23 +345,18 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
if isVideo {
videoCopy := *imp.Video

videoSizeId := rubiconExt.Video.VideoSizeID
if videoSizeId == 0 {
resolvedSizeId, err := resolveVideoSizeId(imp.Video.Placement, imp.Instl, imp.ID)
if err != nil {
errs = append(errs, err)
continue
}
videoSizeId = resolvedSizeId
}

// if imp.rwdd = 1, set imp.video.ext.videotype = "rewarded"
var videoType = ""
if imp.Rwdd == 1 {
videoType = "rewarded"
imp.Rwdd = 0
}
videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, VideoType: videoType, RP: rubiconVideoExtRP{SizeID: videoSizeId}}
videoExt := rubiconVideoExt{
Skip: rubiconExt.Video.Skip,
SkipDelay: rubiconExt.Video.SkipDelay,
VideoType: videoType,
RP: rubiconVideoExtRP{SizeID: rubiconExt.Video.VideoSizeID},
}
videoCopy.Ext, err = json.Marshal(&videoExt)
imp.Video = &videoCopy
imp.Banner = nil
Expand Down
46 changes: 0 additions & 46 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,52 +143,6 @@ func TestResolveNativeObject(t *testing.T) {
}
}

func TestResolveVideoSizeId(t *testing.T) {
testScenarios := []struct {
placement adcom1.VideoPlacementSubtype
instl int8
impId string
expected int
expectedErr error
}{
{
placement: 1,
instl: 1,
impId: "impId",
expected: 201,
expectedErr: nil,
},
{
placement: 3,
instl: 1,
impId: "impId",
expected: 203,
expectedErr: nil,
},
{
placement: 4,
instl: 1,
impId: "impId",
expected: 202,
expectedErr: nil,
},
{
placement: 4,
instl: 3,
impId: "impId",
expectedErr: &errortypes.BadInput{
Message: "video.size_id can not be resolved in impression with id : impId",
},
},
}

for _, scenario := range testScenarios {
res, err := resolveVideoSizeId(scenario.placement, scenario.instl, scenario.impId)
assert.Equal(t, scenario.expected, res)
assert.Equal(t, scenario.expectedErr, err)
}
}

func TestOpenRTBRequestWithDifferentBidFloorAttributes(t *testing.T) {
testScenarios := []struct {
bidFloor float64
Expand Down
1 change: 0 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
3 changes: 2 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
},
"bidder": {
"video": {
"size_id": 10
},
"accountId": 1001,
"siteId": 113932,
Expand Down Expand Up @@ -302,7 +303,7 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
"size_id": 10
}
},
"mimes": [
Expand Down
1 change: 0 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
1 change: 0 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/user-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down

This file was deleted.

0 comments on commit b2023fd

Please sign in to comment.