Skip to content

Commit

Permalink
Vrtcal Bid Adapter: added Non-Static Bid Floor Support (#7324)
Browse files Browse the repository at this point in the history
* Added Non-Static Bid Floor Support

* Added floors module test cases and removed unsupported bid.params.bidFloor coding

Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
vrtcal-dev and Ubuntu authored Aug 20, 2021
1 parent 3f56bad commit a1c8a1e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
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

0 comments on commit a1c8a1e

Please sign in to comment.