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

No default zero bidfloor #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 10 additions & 9 deletions modules/kubientBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,23 @@ export const spec = {
return;
}
return validBidRequests.map(function (bid) {
let floor = 0.0;
let adSlot = {
bidId: bid.bidId,
zoneId: bid.params.zoneid || ''
};

if (typeof bid.getFloor === 'function') {
const mediaType = (Object.keys(bid.mediaTypes).length == 1) ? Object.keys(bid.mediaTypes)[0] : '*';
const sizes = bid.sizes || '*';
const floorInfo = bid.getFloor({currency: 'USD', mediaType: mediaType, size: sizes});
if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) {
floor = parseFloat(floorInfo.floor);
if (typeof floorInfo === 'object' && floorInfo.currency === 'USD') {
let floor = parseFloat(floorInfo.floor)
if (!isNaN(floor) && floor > 0) {
adSlot.floor = parseFloat(floorInfo.floor);
}
}
}

let adSlot = {
bidId: bid.bidId,
zoneId: bid.params.zoneid || '',
floor: floor || 0.0
};

if (bid.mediaTypes.banner) {
adSlot.banner = bid.mediaTypes.banner;
}
Expand Down
8 changes: 3 additions & 5 deletions test/spec/modules/kubientBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('KubientAdapter', function () {
},
getFloor: function(params) {
return {
floor: 0.05,
floor: 0,
currency: 'USD'
};
},
Expand Down Expand Up @@ -127,10 +127,9 @@ describe('KubientAdapter', function () {
expect(data.uspConsent).to.exist.and.to.equal(uspConsentData);
for (let j = 0; j < data['adSlots'].length; j++) {
let adSlot = data['adSlots'][i];
expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain');
expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'banner', 'schain');
expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId);
expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid);
expect(adSlot.floor).to.be.a('number');
expect(adSlot.schain).to.be.an('object');
expect(adSlot.banner).to.be.an('object');
}
Expand Down Expand Up @@ -202,10 +201,9 @@ describe('KubientAdapter', function () {
expect(data.uspConsent).to.exist.and.to.equal(uspConsentData);
for (let j = 0; j < data['adSlots'].length; j++) {
let adSlot = data['adSlots'][i];
expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'floor', 'banner', 'schain');
expect(adSlot).to.have.all.keys('bidId', 'zoneId', 'banner', 'schain');
expect(adSlot.bidId).to.be.a('string').and.to.equal(bidBanner.bidId);
expect(adSlot.zoneId).to.be.a('string').and.to.equal(bidBanner.params.zoneid);
expect(adSlot.floor).to.be.a('number');
expect(adSlot.schain).to.be.an('object');
expect(adSlot.banner).to.be.an('object');
}
Expand Down