Skip to content

Commit

Permalink
SpotX: add support for price floors module (#7481)
Browse files Browse the repository at this point in the history
  • Loading branch information
agdillon authored Oct 4, 2021
1 parent c6e74d2 commit f62ad03
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modules/spotxBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logError, deepAccess, isArray, getBidIdParameter, getDNT, deepSetValue, isEmpty, _each, logMessage, logWarn, isBoolean, isNumber, isPlainObject } from '../src/utils.js';
import { logError, deepAccess, isArray, getBidIdParameter, getDNT, deepSetValue, isEmpty, _each, logMessage, logWarn, isBoolean, isNumber, isPlainObject, isFn } from '../src/utils.js';
import { config } from '../src/config.js';
import { Renderer } from '../src/Renderer.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
Expand Down Expand Up @@ -163,6 +163,20 @@ export const spec = {
}
};

if (isFn(bid.getFloor)) {
let floorInfo = bid.getFloor({
currency: 'USD',
mediaType: 'video',
size: '*'
});

if (floorInfo.currency === 'USD') {
spotxReq.bidfloor = floorInfo.floor;
}
} else if (getBidIdParameter('price_floor', bid.params) != '') {
spotxReq.bidfloor = getBidIdParameter('price_floor', bid.params);
}

if (getBidIdParameter('start_delay', bid.params) != '') {
spotxReq.video.startdelay = 0 + Boolean(getBidIdParameter('start_delay', bid.params));
}
Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/spotxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,42 @@ describe('the spotx adapter', function () {
expect(request.data.ext.wrap_response).to.equal(0);
config.getConfig.restore();
});

it('should pass price floor in USD from the floors module if available', function () {
var request;

bid.getFloor = function () {
return { currency: 'USD', floor: 3 };
}

bid.params.price_floor = 2;

request = spec.buildRequests([bid], bidRequestObj)[0];

expect(request.data.imp.bidfloor).to.equal(3);
});

it('should not pass price floor if price floors module gives a non-USD currency', function () {
var request;

bid.getFloor = function () {
return { currency: 'EUR', floor: 3 };
}

request = spec.buildRequests([bid], bidRequestObj)[0];

expect(request.data.imp.bidfloor).to.be.undefined;
});

it('if floors module is not available, should pass price floor from price_floor param if available', function () {
var request;

bid.params.price_floor = 2;

request = spec.buildRequests([bid], bidRequestObj)[0];

expect(request.data.imp.bidfloor).to.equal(2);
});
});

describe('interpretResponse', function() {
Expand Down

0 comments on commit f62ad03

Please sign in to comment.