Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vrtcal Bid Adapter: added Non-Static Bid Floor Support #7324

Merged
merged 2 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions modules/vrtcalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@ export const spec = {
},
buildRequests: function (bidRequests) {
const requests = bidRequests.map(function (bid) {
const params = {
let floor = 0;

if (typeof bid.getFloor === 'function') {
const floorInfo = bid.getFloor({ currency: 'USD', mediaType: 'banner', size: bid.sizes.map(([w, h]) => ({w, h})) });

if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) {
floor = Math.max(floor, parseFloat(floorInfo.floor));
}
}

const params = {
prebidJS: 1,
prebidAdUnitCode: bid.adUnitCode,
id: bid.bidId,
imp: [{
id: '1',
banner: {
},
bidfloor: 0.75
bidfloor: floor
}],
site: {
id: 'VRTCAL_FILLED',
Expand Down
14 changes: 13 additions & 1 deletion test/spec/modules/vrtcalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('vrtcalBidAdapter', function () {
}
];

const request = spec.buildRequests(bidRequests);
let request = spec.buildRequests(bidRequests);

it('sends bid request to our endpoint via POST', function () {
expect(request[0].method).to.equal('POST');
Expand All @@ -38,6 +38,18 @@ describe('vrtcalBidAdapter', function () {
it('adUnitCode should be sent as prebidAdUnitCode parameters on any requests', function () {
expect(request[0].data).to.match(/"prebidAdUnitCode":"adunit0001"/);
});

it('if the publisher has NOT set a floor via the floors module, zero should be sent as bidfloor parameter on any requests', function () {
expect(request[0].data).to.match(/"bidfloor":0/);
});

it('if the publisher has set a floor via the floors module, it should be sent as bidfloor parameter on any requests', function () {
let floorInfo;
bidRequests[0].getFloor = () => floorInfo;
floorInfo = {currency: 'USD', floor: 0.55};
request = spec.buildRequests(bidRequests);
expect(request[0].data).to.match(/"bidfloor":0.55/);
});
});

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