From c0c741925f5e9ba8be4b4795d3c1f491f1a585f3 Mon Sep 17 00:00:00 2001 From: jddeleon Date: Tue, 29 Jan 2019 13:02:40 -0800 Subject: [PATCH] Add bidfloor param to allow dynamic bid floor CPM (#3431) * Add bidfloor to params to allow dynamic bid floor CPM * polyfill Number.isFinite for IE11/Safari 8 * ADSS-538 Revert changes to package-lock.json --- integrationExamples/gpt/pbjs_example_gpt.html | 3 ++- modules/gumgumBidAdapter.js | 9 +++++++++ modules/gumgumBidAdapter.md | 6 ++++-- test/spec/modules/gumgumBidAdapter_spec.js | 15 +++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/integrationExamples/gpt/pbjs_example_gpt.html b/integrationExamples/gpt/pbjs_example_gpt.html index 6852b9f680a..dcc67ae0f74 100644 --- a/integrationExamples/gpt/pbjs_example_gpt.html +++ b/integrationExamples/gpt/pbjs_example_gpt.html @@ -418,7 +418,8 @@ { bidder: 'gumgum', params: { - inScreen: 'ggumtest' // REQUIRED str Tracking Id + inScreen: 'ggumtest', // REQUIRED str Tracking Id + bidfloor: 0.01 // OPTIONAL number CPM bid } }, { diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index 51068d7edb9..846beae2694 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -103,6 +103,12 @@ function isBidRequestValid (bid) { utils.logWarn(`[GumGum] No product selected for the placement ${adUnitCode}, please check your implementation.`); return false; } + + if (params.bidfloor && !(typeof params.bidfloor === 'number' && isFinite(params.bidfloor))) { + utils.logWarn('[GumGum] bidfloor must be a Number'); + return false; + } + return true; } @@ -126,6 +132,9 @@ function buildRequests (validBidRequests, bidderRequest) { if (pageViewId) { data.pv = pageViewId } + if (params.bidfloor) { + data.fp = params.bidfloor; + } if (params.inScreen) { data.t = params.inScreen; data.pi = 2; diff --git a/modules/gumgumBidAdapter.md b/modules/gumgumBidAdapter.md index 14f2fe40abb..57616a90ac2 100644 --- a/modules/gumgumBidAdapter.md +++ b/modules/gumgumBidAdapter.md @@ -20,7 +20,8 @@ var adUnits = [ { bidder: 'gumgum', params: { - inSlot: '15901' // GumGum Slot ID given to the client + inSlot: '15901', // GumGum Slot ID given to the client, + bidFloor: 0.03 // CPM bid floor } } ] @@ -31,7 +32,8 @@ var adUnits = [ { bidder: 'gumgum', params: { - inScreen: 'dc9d6be1' // GumGum Zone ID given to the client + inScreen: 'dc9d6be1', // GumGum Zone ID given to the client + bidFloor: 0.03 // CPM bid floor } } ] diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index 0c1431b71a5..c067f50fa56 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -17,7 +17,8 @@ describe('gumgumAdapter', function () { let bid = { 'bidder': 'gumgum', 'params': { - 'inScreen': '10433394' + 'inScreen': '10433394', + 'bidfloor': 0.05 }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [300, 600], [1, 1]], @@ -40,7 +41,7 @@ describe('gumgumAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should return false when required params are not passed', function () { + it('should return false when no unit type is specified', function () { let bid = Object.assign({}, bid); delete bid.params; bid.params = { @@ -48,6 +49,16 @@ describe('gumgumAdapter', function () { }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); + + it('should return false when bidfloor is not a number', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'inSlot': '789', + 'bidfloor': '0.50' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); }); describe('buildRequests', function () {