From 879542018de3e3e650a53ce1a4d6e8c4d9fce2e8 Mon Sep 17 00:00:00 2001 From: colbertk Date: Tue, 2 Jun 2020 16:48:14 -0400 Subject: [PATCH 1/3] access floor from floors module --- modules/tripleliftBidAdapter.js | 18 +++++++++++++++++- test/spec/modules/tripleliftBidAdapter_spec.js | 9 +++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 8b21f334233..77f472d254f 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -111,7 +111,7 @@ function _buildPostBody(bidRequests) { return { id: index, tagid: bid.params.inventoryCode, - floor: bid.params.floor, + floor: _getFloor(bid), banner: { format: _sizes(bid.sizes) } @@ -138,6 +138,22 @@ function _buildPostBody(bidRequests) { return data; } +function _getFloor (bid) { + let floor = null; + if (typeof bid.getFloor === 'function') { + let floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: 'banner', + size: _sizes(bid.sizes) + }); + if (typeof floorInfo === 'object' && + floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor))) { + floor = parseFloat(floorInfo.floor); + } + } + return floor || bid.params.floor; +} + function getUnifiedIdEids(bidRequests) { return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID'); } diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 675b8b6c532..73373293114 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -299,6 +299,15 @@ describe('triplelift adapter', function () { const { data: payload } = request; expect(payload.ext).to.deep.equal(undefined); }); + it('should get floor from floors module if available', function() { + const floorInfo = { + currency: 'USD', + floor: 1.99 + }; + bidRequests[0].getFloor = () => floorInfo; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].floor).to.equal(1.99); + }); }); describe('interpretResponse', function () { From 4f106581002f55f2dba8f3f8d41b5b6acdf77cc3 Mon Sep 17 00:00:00 2001 From: colbertk Date: Tue, 2 Jun 2020 17:43:40 -0400 Subject: [PATCH 2/3] int -> float and null check --- modules/tripleliftBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index 77f472d254f..e0523d92ca6 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -147,11 +147,11 @@ function _getFloor (bid) { size: _sizes(bid.sizes) }); if (typeof floorInfo === 'object' && - floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor))) { + floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { floor = parseFloat(floorInfo.floor); } } - return floor || bid.params.floor; + return floor !== null ? floor : bid.params.floor; } function getUnifiedIdEids(bidRequests) { From a0d4f7e97c3a83148a804eb845b4415d7a23c77e Mon Sep 17 00:00:00 2001 From: colbertk Date: Wed, 3 Jun 2020 10:29:28 -0400 Subject: [PATCH 3/3] let -> const --- modules/tripleliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tripleliftBidAdapter.js b/modules/tripleliftBidAdapter.js index e0523d92ca6..af904aedc11 100644 --- a/modules/tripleliftBidAdapter.js +++ b/modules/tripleliftBidAdapter.js @@ -141,7 +141,7 @@ function _buildPostBody(bidRequests) { function _getFloor (bid) { let floor = null; if (typeof bid.getFloor === 'function') { - let floorInfo = bid.getFloor({ + const floorInfo = bid.getFloor({ currency: 'USD', mediaType: 'banner', size: _sizes(bid.sizes)