Skip to content

Commit

Permalink
IX Bid Adapter: send bid floor per size in format ext (prebid#9084)
Browse files Browse the repository at this point in the history
* feat: send bid floor per size in format ext [PB-1311]

* fix: remove typo [PB-1311]

Co-authored-by: shahin.rahbariasl <shahin.rahbariasl@indexexchange.com>
  • Loading branch information
2 people authored and jorgeluisrocha committed May 18, 2023
1 parent 552f091 commit a61da7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,15 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
},
};

// We add sid in imp.ext.sid therefore, remove from banner.format[].ext
for (let bannerFormat of _bannerImpression.banner.format) {
if (bannerFormat.ext != null && bannerFormat.ext.sid != null) {
delete bannerFormat.ext.sid;
for (let i = 0; i < _bannerImpression.banner.format.length; i++) {
// We add sid in imp.ext.sid therefore, remove from banner.format[].ext
if (_bannerImpression.banner.format[i].ext != null && _bannerImpression.banner.format[i].ext.sid != null) {
delete _bannerImpression.banner.format[i].ext.sid;
}

// add floor per size
if ('bidfloor' in impressionObjects[i]) {
_bannerImpression.banner.format[i].ext.bidfloor = impressionObjects[i].bidfloor
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,18 @@ describe('IndexexchangeAdapter', function () {
expect(impression.banner.format[0].ext.fl).to.equal('x');
});

it('banner multi size impression should have bidFloor both in imp and format ext obejcts', function () {
const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]);
bid.params.bidFloor = 50;
bid.params.bidFloorCur = 'USD';
const requestBidFloor = spec.buildRequests([bid], {})[0];
const impression = JSON.parse(requestBidFloor.data.r).imp[0];

expect(impression.bidfloor).to.equal(bid.params.bidFloor);
expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur);
expect(impression.banner.format[0].ext.bidfloor).to.equal(50);
});

it('missing sizes impressions should contain floors from priceFloors module ', function () {
const bid = utils.deepClone(ONE_BANNER[0]);
bid.mediaTypes.banner.sizes.push([500, 400])
Expand Down

0 comments on commit a61da7d

Please sign in to comment.