Skip to content

Commit

Permalink
Rubicon adapter: accept accountId, siteId, zoneId as strings (#2110)
Browse files Browse the repository at this point in the history
  • Loading branch information
And1sS authored Jan 10, 2022
1 parent 7e2af0c commit 6677af1
Show file tree
Hide file tree
Showing 5 changed files with 482 additions and 22 deletions.
26 changes: 22 additions & 4 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,21 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
continue
}

siteId, err := rubiconExt.SiteId.Int64()
if err != nil {
errs = append(errs, err)
continue
}

zoneId, err := rubiconExt.ZoneId.Int64()
if err != nil {
errs = append(errs, err)
continue
}

impExt := rubiconImpExt{
RP: rubiconImpExtRP{
ZoneID: rubiconExt.ZoneId,
ZoneID: int(zoneId),
Target: target,
Track: rubiconImpExtRPTrack{Mint: "", MintVersion: ""},
},
Expand Down Expand Up @@ -534,11 +546,17 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
imp.Video = nil
}

pubExt := rubiconPubExt{RP: rubiconPubExtRP{AccountID: rubiconExt.AccountId}}
accountId, err := rubiconExt.AccountId.Int64()
if err != nil {
errs = append(errs, err)
continue
}

pubExt := rubiconPubExt{RP: rubiconPubExtRP{AccountID: int(accountId)}}

if request.Site != nil {
siteCopy := *request.Site
siteExtRP := rubiconSiteExt{RP: rubiconSiteExtRP{SiteID: rubiconExt.SiteId}}
siteExtRP := rubiconSiteExt{RP: rubiconSiteExtRP{SiteID: int(siteId)}}
if siteCopy.Content != nil {
siteTarget := make(map[string]interface{})
updateExtWithIabAttribute(siteTarget, siteCopy.Content.Data, []int{1, 2, 5, 6})
Expand All @@ -563,7 +581,7 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
rubiconRequest.Site = &siteCopy
} else {
appCopy := *request.App
appCopy.Ext, err = json.Marshal(rubiconSiteExt{RP: rubiconSiteExtRP{SiteID: rubiconExt.SiteId}})
appCopy.Ext, err = json.Marshal(rubiconSiteExt{RP: rubiconSiteExtRP{SiteID: int(siteId)}})
appCopy.Publisher = &openrtb2.Publisher{}
appCopy.Publisher.Ext, err = json.Marshal(&pubExt)
rubiconRequest.App = &appCopy
Expand Down
5 changes: 4 additions & 1 deletion adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,10 @@ func TestOpenRTBRequestWithVideoImpAndEnabledRewardedInventoryFlag(t *testing.T)
"is_rewarded_inventory": 1
},
"bidder": {
"video": {"size_id": 1}
"video": {"size_id": 1},
"zoneId": "123",
"siteId": 1234,
"accountId": "444"
}}`),
}},
App: &openrtb2.App{
Expand Down
Loading

0 comments on commit 6677af1

Please sign in to comment.