Skip to content

Commit

Permalink
Remove imp.ext.context references.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddubyk committed Sep 13, 2024
1 parent ffdd75f commit 0b4e673
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 57 deletions.
34 changes: 9 additions & 25 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ type RubiconAdapter struct {
XAPIPassword string
}

type rubiconContext struct {
Data json.RawMessage `json:"data"`
}

type rubiconData struct {
AdServer rubiconAdServer `json:"adserver"`
PbAdSlot string `json:"pbadslot"`
Expand All @@ -44,12 +40,11 @@ type rubiconAdServer struct {
}

type rubiconExtImpBidder struct {
Prebid *openrtb_ext.ExtImpPrebid `json:"prebid"`
Bidder openrtb_ext.ExtImpRubicon `json:"bidder"`
Gpid string `json:"gpid"`
Skadn json.RawMessage `json:"skadn,omitempty"`
Data json.RawMessage `json:"data"`
Context rubiconContext `json:"context"`
Prebid *openrtb_ext.ExtImpPrebid `json:"prebid"`
Bidder openrtb_ext.ExtImpRubicon `json:"bidder"`
Gpid string `json:"gpid"`
Skadn json.RawMessage `json:"skadn,omitempty"`
Data json.RawMessage `json:"data"`
}

type bidRequestExt struct {
Expand Down Expand Up @@ -707,9 +702,7 @@ func updateImpRpTargetWithFpdAttributes(extImp rubiconExtImpBidder, extImpRubico
}
}

if len(extImp.Context.Data) > 0 {
err = populateFirstPartyDataAttributes(extImp.Context.Data, target)
} else if len(extImp.Data) > 0 {
if len(extImp.Data) > 0 {
err = populateFirstPartyDataAttributes(extImp.Data, target)
}
if isNotKeyPathError(err) {
Expand All @@ -723,18 +716,11 @@ func updateImpRpTargetWithFpdAttributes(extImp rubiconExtImpBidder, extImpRubico
return nil, err
}
}
var contextData rubiconData
if len(extImp.Context.Data) > 0 {
err := json.Unmarshal(extImp.Context.Data, &contextData)
if err != nil {
return nil, err
}
}

if data.PbAdSlot != "" {
target["pbadslot"] = data.PbAdSlot
} else {
dfpAdUnitCode := extractDfpAdUnitCode(data, contextData)
dfpAdUnitCode := extractDfpAdUnitCode(data)
if dfpAdUnitCode != "" {
target["dfp_ad_unit_code"] = dfpAdUnitCode
}
Expand All @@ -750,10 +736,8 @@ func updateImpRpTargetWithFpdAttributes(extImp rubiconExtImpBidder, extImpRubico
return updatedTarget, nil
}

func extractDfpAdUnitCode(data rubiconData, contextData rubiconData) string {
if contextData.AdServer.Name == "gam" && contextData.AdServer.AdSlot != "" {
return contextData.AdServer.AdSlot
} else if data.AdServer.Name == "gam" && data.AdServer.AdSlot != "" {
func extractDfpAdUnitCode(data rubiconData) string {
if data.AdServer.Name == "gam" && data.AdServer.AdSlot != "" {
return data.AdServer.AdSlot
}

Expand Down
10 changes: 4 additions & 6 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,10 @@ func TestOpenRTBRequestWithImpAndAdSlotIncluded(t *testing.T) {
"inventory": {"key1" : "val1"},
"visitor": {"key2" : "val2"}
},
"context": {
"data": {
"adserver": {
"adslot": "/test-adslot",
"name": "gam"
}
"data": {
"adserver": {
"adslot": "/test-adslot",
"name": "gam"
}
}
}`),
Expand Down
20 changes: 7 additions & 13 deletions adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,13 @@
"h": 576
},
"ext": {
"context": {
"data": {
"adserver": {
"name": "gam",
"adslot": "adSlotFromContextData"
},
"dataAttr1": "dataVal1",
"dataAttr2": "dataVal2"
}
},
"data": {
"adserver": {
"name": "gam",
"adslot": "adSlotFromData"
}
"adslot": "adSlotFromContextData"
},
"dataAttr1": "dataVal1",
"dataAttr2": "dataVal2"
},
"bidder": {
"video": {
Expand Down Expand Up @@ -362,7 +354,9 @@
}
]
},
"impIDs":["test-imp-id"]
"impIDs": [
"test-imp-id"
]
},
"mockResponse": {
"status": 200,
Expand Down
20 changes: 7 additions & 13 deletions adapters/rubicon/rubicontest/exemplary/flexible-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,13 @@
"h": 576
},
"ext": {
"context": {
"data": {
"adserver": {
"name": "gam",
"adslot": "adSlotFromContextData"
},
"dataAttr1": "dataVal1",
"dataAttr2": "dataVal2"
}
},
"data": {
"adserver": {
"name": "gam",
"adslot": "adSlotFromData"
}
"adslot": "adSlotFromContextData"
},
"dataAttr1": "dataVal1",
"dataAttr2": "dataVal2"
},
"bidder": {
"video": {
Expand Down Expand Up @@ -362,7 +354,9 @@
}
]
},
"impIDs":["test-imp-id"]
"impIDs": [
"test-imp-id"
]
},
"mockResponse": {
"status": 200,
Expand Down

0 comments on commit 0b4e673

Please sign in to comment.