Skip to content

Commit

Permalink
TTD BId Adapter: Support bidfloor bidding parameter (#9607)
Browse files Browse the repository at this point in the history
* rbc-OPATH-367: support bidfloor bidding parameter

* rbc-OPATH-367-added-tests

---------

Co-authored-by: robert.charlton <[email protected]>
Co-authored-by: robert-charlton-ttd <[email protected]>
  • Loading branch information
3 people authored Mar 2, 2023
1 parent 500b348 commit 99d2fb7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
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

0 comments on commit 99d2fb7

Please sign in to comment.