Skip to content

Commit

Permalink
The adapter is modified to return schain in case it has more than 2 n…
Browse files Browse the repository at this point in the history
…odes.
  • Loading branch information
maximilianozurita committed Jan 16, 2025
1 parent 4e95b38 commit 1ee929f
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 12 deletions.
14 changes: 3 additions & 11 deletions adapters/eplanning/eplanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,9 @@ func (adapter *EPlanningAdapter) MakeRequests(request *openrtb2.BidRequest, reqI
query.Set("vv", vastVersionDefault)
}
if request.Source != nil && request.Source.Ext != nil {
var randNum int
if adapter.testing {
randNum = 1
} else {
randNum = rand.Intn(1000)
}
if randNum == 1 {
if openRtbSchain := unmarshalSupplyChain(request); openRtbSchain != nil {
if schainValue := makeSupplyChain(*openRtbSchain); schainValue != "" {
query.Set("sch", schainValue)
}
if openRtbSchain := unmarshalSupplyChain(request); openRtbSchain != nil && len(openRtbSchain.Nodes) > 2 {
if schainValue := makeSupplyChain(*openRtbSchain); schainValue != "" {
query.Set("sch", schainValue)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"mockBidRequest": {
"id": "test-request-id",
"source": {
"ext": {
"schain": {
"ver": "1.0",
"complete": 1,
"nodes": [
{
"asi": "exchange1.com",
"sid": "1234",
"hp": 1,
"ext": "text"
},
{
"asi": "exchange2.com",
"sid": "abcd",
"hp": 1,
"ext": 1
}
]
}
}
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"ci": "12345"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://rtb.e-planning.net/pbs/1/12345/1/FILE/ROS?e=300x250%3A300x250&ncb=1&ur=FILE",
"body": {},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"sI": { "k": "12345" },
"sec": "ROS",
"sp": [
{
"k": "300x250",
"a": [{
"i": "123456789abcdef",
"pr": "0.5",
"adm": "<div>test</div>",
"crid": "abcdef123456789",
"id": "adid12345",
"w": 300,
"h": 250
}]
}
]
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "123456789abcdef",
"impid": "test-imp-id",
"price": 0.5,
"adm": "<div>test</div>",
"adid": "adid12345",
"crid": "abcdef123456789",
"w": 300,
"h": 250
},
"type": "banner"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"sid": "abcd",
"hp": 1,
"ext": 1
},
{
"asi": "exchange3.com",
"sid": "abcdf",
"hp": 1,
"ext": 1
}
]
}
Expand Down Expand Up @@ -49,7 +55,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://rtb.e-planning.net/pbs/1/12345/1/FILE/ROS?e=300x250%3A300x250&ncb=1&sch=1.0%2C1%21exchange1.com%2C1234%2C1%2C%2C%2C%2C%2522text%2522%21exchange2.com%2Cabcd%2C1%2C%2C%2C%2C1&ur=FILE",
"uri": "http://rtb.e-planning.net/pbs/1/12345/1/FILE/ROS?e=300x250%3A300x250&ncb=1&sch=1.0%2C1%21exchange1.com%2C1234%2C1%2C%2C%2C%2C%2522text%2522%21exchange2.com%2Cabcd%2C1%2C%2C%2C%2C1%21exchange3.com%2Cabcdf%2C1%2C%2C%2C%2C1&ur=FILE",
"body": {},
"impIDs":["test-imp-id"]
},
Expand Down

0 comments on commit 1ee929f

Please sign in to comment.