Skip to content

Commit

Permalink
add support for setting seat (bidderCode) override + demand source in…
Browse files Browse the repository at this point in the history
… bid meta (#3733)

authored by @nickjacob
  • Loading branch information
nickjacob committed Jun 25, 2024
1 parent fe55575 commit 9f2caf9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
21 changes: 18 additions & 3 deletions adapters/amx/amx.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ func (adapter *AMXAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapt
}

type amxBidExt struct {
StartDelay *int `json:"startdelay,omitempty"`
CreativeType *int `json:"ct,omitempty"`
StartDelay *int `json:"startdelay,omitempty"`
CreativeType *int `json:"ct,omitempty"`
DemandSource *string `json:"ds,omitempty"`
BidderCode *string `json:"bc,omitempty"`
}

// MakeBids will parse the bids from the AMX server
Expand Down Expand Up @@ -154,12 +156,25 @@ func (adapter *AMXAdapter) MakeBids(request *openrtb2.BidRequest, externalReques
continue
}

demandSource := ""
if bidExt.DemandSource != nil {
demandSource = *bidExt.DemandSource
}

bidType := getMediaTypeForBid(bidExt)
b := &adapters.TypedBid{
Bid: &bid,
Bid: &bid,
BidMeta: &openrtb_ext.ExtBidPrebidMeta{
AdvertiserDomains: bid.ADomain,
DemandSource: demandSource,
},
BidType: bidType,
}

if bidExt.BidderCode != nil {
b.Seat = openrtb_ext.BidderName(*bidExt.BidderCode)
}

bidResponse.Bids = append(bidResponse.Bids, b)
}
}
Expand Down
29 changes: 19 additions & 10 deletions adapters/amx/amx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,24 @@ func TestMakeBids(t *testing.T) {
}

type testCase struct {
bidType openrtb_ext.BidType
adm string
extRaw string
valid bool
bidType openrtb_ext.BidType
adm string
extRaw string
seatName string
demandSource string
valid bool
}

tests := []testCase{
{openrtb_ext.BidTypeNative, `{"assets":[]}`, `{"ct":10}`, true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"ct": 1}`, true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"ct": "invalid"}`, false},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{}`, true},
{openrtb_ext.BidTypeVideo, sampleVastADM, `{"startdelay": 1}`, true},
{openrtb_ext.BidTypeBanner, sampleVastADM, `{"ct": 1}`, true}, // the server shouldn't do this
{openrtb_ext.BidTypeNative, `{"assets":[]}`, `{"ct":10}`, "", "", true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"ct": 1}`, "", "", true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"ct": "invalid"}`, "", "", false},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{}`, "", "", true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"bc": "amx-pmp"}`, "amx-pmp", "", true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"ds": "pmp-1"}`, "", "pmp-1", true},
{openrtb_ext.BidTypeBanner, sampleDisplayADM, `{"bc": "amx-pmp", "ds": "pmp-1"}`, "amx-pmp", "pmp-1", true},
{openrtb_ext.BidTypeVideo, sampleVastADM, `{"startdelay": 1}`, "", "", true},
{openrtb_ext.BidTypeBanner, sampleVastADM, `{"ct": 1}`, "", "", true}, // the server shouldn't do this
}

for _, test := range tests {
Expand Down Expand Up @@ -233,6 +238,10 @@ func TestMakeBids(t *testing.T) {

assert.Len(t, bids.Bids, 1)
assert.Equal(t, test.bidType, bids.Bids[0].BidType)

br := bids.Bids[0]
assert.Equal(t, openrtb_ext.BidderName(test.seatName), br.Seat)
assert.Equal(t, test.demandSource, br.BidMeta.DemandSource)
}

}
6 changes: 5 additions & 1 deletion adapters/amx/amxtest/exemplary/display-multiple.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
"cid": "668",
"crid": "253510977",
"ext": {
"bc": "amx-pmp"
},
"h": 250,
"id": "8911104898220857797",
Expand Down Expand Up @@ -258,14 +259,17 @@
],
"cid": "668",
"crid": "253510977",
"ext": {},
"ext": {
"bc": "amx-pmp"
},
"h": 250,
"id": "8911104898220857797",
"impid": "6a362d3a9db4eba300x250",
"nurl": "https://1x1.a-mo.net/hbx/bwin",
"price": 0.50,
"w": 300
},
"seat": "amx-pmp",
"type": "banner"
},
{
Expand Down

0 comments on commit 9f2caf9

Please sign in to comment.