Skip to content

Commit

Permalink
Prebid Server Bid Adapter: add support for all imp parameters (#8159)
Browse files Browse the repository at this point in the history
* pass imp and fix test

* fix lint

* fix to mergeDeep

* add instl test

* remove overlapping testing
  • Loading branch information
ChrisHuie authored Mar 9, 2022
1 parent 631c2f4 commit ca333b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ Object.assign(ORTB2.prototype, {
return acc;
}, {...deepAccess(adUnit, 'ortb2Imp.ext')});

const imp = { id: impressionId, ext, secure: s2sConfig.secure };
const imp = { ...adUnit.ortb2Imp, id: impressionId, ext, secure: s2sConfig.secure };

const ortb2 = {...deepAccess(adUnit, 'ortb2Imp.ext.data')};
Object.keys(ortb2).forEach(prop => {
Expand Down Expand Up @@ -745,7 +745,7 @@ Object.assign(ORTB2.prototype, {
}
});

Object.assign(imp, mediaTypes);
mergeDeep(imp, mediaTypes);

// if storedAuctionResponse has been set, pass SRID
const storedAuctionResponseBid = find(firstBidRequest.bids, bid => (bid.adUnitCode === adUnit.code && bid.storedAuctionResponse));
Expand Down
18 changes: 18 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2910,6 +2910,24 @@ describe('S2S Adapter', function () {
expect(requestBid.coopSync).to.be.undefined;
});

it('should set imp banner if ortb2Imp.banner is present', function() {
const consentConfig = { s2sConfig: CONFIG };
config.setConfig(consentConfig);
const bidRequest = utils.deepClone(REQUEST);
bidRequest.ad_units[0].ortb2Imp = {
banner: {
api: 7
},
instl: 1
};

adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);

expect(parsedRequestBody.imp[0].banner.api).to.equal(7);
expect(parsedRequestBody.imp[0].instl).to.equal(1);
});

it('adds debug flag', function () {
config.setConfig({debug: true});

Expand Down

0 comments on commit ca333b5

Please sign in to comment.