Skip to content

Commit

Permalink
Update to PBS bid adapter for video bids, pass along w and h respecti…
Browse files Browse the repository at this point in the history
…vely and filter out contxt and playerSize params as PBS does not use them (prebid#6682)
  • Loading branch information
mmoschovas authored and stsepelin committed May 28, 2021
1 parent b1b22ae commit 3921bd3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,17 @@ const OPEN_RTB_PROTOCOL = {
if (videoParams.context === 'instream' && !videoParams.hasOwnProperty('placement')) {
videoParams.placement = 1;
}
mediaTypes['video'] = videoParams;

mediaTypes['video'] = Object.keys(videoParams).filter(param => param !== 'context')
.reduce((result, param) => {
if (param === 'playerSize') {
result.w = utils.deepAccess(videoParams, `${param}.0.0`);
result.h = utils.deepAccess(videoParams, `${param}.0.1`);
} else {
result[param] = videoParams[param];
}
return result;
}, {});
}
}

Expand Down
20 changes: 20 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,26 @@ describe('S2S Adapter', function () {
expect(requestBid.imp[0].video.placement).to.equal(1);
});

it('converts video mediaType properties into openRTB format', function () {
let ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';

config.setConfig({ s2sConfig: ortb2Config });

let videoBid = utils.deepClone(VIDEO_REQUEST);
videoBid.ad_units[0].mediaTypes.video.context = 'instream';
adapter.callBids(videoBid, BID_REQUESTS, addBidResponse, done, ajax);

const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.imp[0].banner).to.not.exist;
expect(requestBid.imp[0].video).to.exist;
expect(requestBid.imp[0].video.placement).to.equal(1);
expect(requestBid.imp[0].video.w).to.equal(640);
expect(requestBid.imp[0].video.h).to.equal(480);
expect(requestBid.imp[0].video.playerSize).to.be.undefined;
expect(requestBid.imp[0].video.context).to.be.undefined;
});

it('exists and is a function', function () {
expect(adapter.callBids).to.exist.and.to.be.a('function');
});
Expand Down

0 comments on commit 3921bd3

Please sign in to comment.