Skip to content

Commit

Permalink
Add bidfloor param to allow dynamic bid floor CPM (prebid#3431)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jddeleon authored and Pedro López Jiménez committed Mar 18, 2019
1 parent fb211ac commit c0c7419
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
{
Expand Down
9 changes: 9 additions & 0 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions modules/gumgumBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
]
Expand All @@ -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
}
}
]
Expand Down
15 changes: 13 additions & 2 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand All @@ -40,14 +41,24 @@ 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 = {
'placementId': 0
};
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 () {
Expand Down

0 comments on commit c0c7419

Please sign in to comment.