Skip to content

Commit

Permalink
move dfp_ad_unit_code to imp.ext (prebid#7637)
Browse files Browse the repository at this point in the history
  • Loading branch information
umakajan authored and Chris Pabst committed Jan 10, 2022
1 parent 3a1ad21 commit d23c0c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
}

if (impressionObjects.length && BANNER in impressionObjects[0]) {
const { id, banner: { topframe } } = impressionObjects[0];
const { id, banner: { topframe }, ext } = impressionObjects[0];
const _bannerImpression = {
id,
banner: {
Expand All @@ -655,6 +655,12 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
},
}

if (ext.dfp_ad_unit_code) {
_bannerImpression.ext = {
dfp_ad_unit_code: ext.dfp_ad_unit_code
}
}

if ('bidfloor' in impressionObjects[0]) {
_bannerImpression.bidfloor = impressionObjects[0].bidfloor;
}
Expand Down
6 changes: 3 additions & 3 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1405,16 +1405,16 @@ describe('IndexexchangeAdapter', function () {
}
};
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].banner.format[0].ext;
const { ext: { dfp_ad_unit_code } } = JSON.parse(requests[0].data.r).imp[0];
expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE);
});

it('should not send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot does not exists', function () {
const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].banner.format[0].ext;
const { ext } = JSON.parse(requests[0].data.r).imp[0];

expect(dfp_ad_unit_code).to.not.exist;
expect(ext).to.not.exist;
});

it('payload should have correct format and value', function () {
Expand Down

0 comments on commit d23c0c6

Please sign in to comment.