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

TTD BId Adapter: Support bidfloor bidding parameter #9607

Merged
merged 5 commits into from
Mar 2, 2023
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
10 changes: 10 additions & 0 deletions modules/ttdBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ function getRegs(bidderRequest) {
}

function getBidFloor(bid) {
// value from params takes precedance over value set by Floor Module
if (bid.params.bidfloor) {
return bid.params.bidfloor;
}

if (!utils.isFn(bid.getFloor)) {
return null;
}
Expand Down Expand Up @@ -349,6 +354,11 @@ export const spec = {
return false;
}

// optional parameters
if (bid.params.bidfloor && isNaN(parseFloat(bid.params.bidfloor))) {
return false;
}

const gpid = utils.deepAccess(bid, 'ortb2Imp.ext.gpid');
if (!bid.params.placementId && !gpid) {
utils.logWarn(BIDDER_CODE + ': one of params.placementId or gpid (via the GPT module https://docs.prebid.org/dev-docs/modules/gpt-pre-auction.html) must be passed');
Expand Down
4 changes: 3 additions & 1 deletion modules/ttdBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The Trade Desk bid adapter supports Banner and Video.
supplySourceId: 'supplier',
publisherId: '1427ab10f2e448057ed3b422',
placementId: '/1111/home#header',
bidfloor: 0.45,
banner: {
expdir: [1, 3]
},
Expand Down Expand Up @@ -107,7 +108,8 @@ The Trade Desk bid adapter supports Banner and Video.
params: {
supplySourceId: 'supplier',
publisherId: '1427ab10f2e448057ed3b422',
placementId: '/1111/home#header'
placementId: '/1111/home#header',
bidfloor: 0.45
}
}
]
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/ttdBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ describe('ttdBidAdapter', function () {
delete bid.mediaTypes
expect(spec.isBidRequestValid(bid)).to.equal(false);
});

it('should return false if bidfloor is passed incorrectly', function () {
let bid = makeBid();
bid.params.bidfloor = 'invalid bidfloor';
expect(spec.isBidRequestValid(bid)).to.equal(false);
});

it('should return true if bidfloor is passed correctly as a float', function () {
let bid = makeBid();
bid.params.bidfloor = 3.01;
expect(spec.isBidRequestValid(bid)).to.equal(true);
});
});

describe('banner', function () {
Expand Down Expand Up @@ -535,6 +547,17 @@ describe('ttdBidAdapter', function () {
expect(requestBody.site.ref).to.equal('https://ref.example.com');
expect(requestBody.site.keywords).to.equal('power tools, drills');
});

it('should fallback to floor module if no bidfloor is sent ', function () {
let clonedBannerRequests = deepClone(baseBannerBidRequests);
const bidfloor = 5.00;
clonedBannerRequests[0].getFloor = () => {
return { currency: 'USD', floor: bidfloor };
};
const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data;
config.resetConfig();
expect(requestBody.imp[0].bidfloor).to.equal(bidfloor);
});
});

describe('buildRequests-banner-multiple', function () {
Expand Down