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

GumGum: adds support for floor module #5532

Merged
merged 3 commits into from
Aug 4, 2020
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
35 changes: 33 additions & 2 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,34 @@ function _getVidParams (attributes) {
};
}

/**
* Gets bidfloor
* @param {Object} mediaTypes
* @param {Number} bidfloor
* @param {Object} bid
* @returns {Number} floor
*/
function _getFloor (mediaTypes, bidfloor, bid) {
const curMediaType = Object.keys(mediaTypes)[0] || 'banner';
let floor = bidfloor || 0;

if (typeof bid.getFloor === 'function') {
const floorInfo = bid.getFloor({
currency: 'USD',
mediaType: curMediaType,
size: '*'
});

if (typeof floorInfo === 'object' &&
floorInfo.currency === 'USD' &&
!isNaN(parseFloat(floorInfo.floor))) {
floor = Math.max(floor, parseFloat(floorInfo.floor));
}
}

return floor;
}

/**
* Make a server request from the list of BidRequests.
*
Expand All @@ -219,6 +247,7 @@ function buildRequests (validBidRequests, bidderRequest) {
transactionId,
userId = {}
} = bidRequest;
const bidFloor = _getFloor(mediaTypes, params.bidfloor, bidRequest);
let sizes = [1, 1];
let data = {};

Expand All @@ -231,9 +260,11 @@ function buildRequests (validBidRequests, bidderRequest) {
if (pageViewId) {
data.pv = pageViewId;
}
if (params.bidfloor) {
data.fp = params.bidfloor;

if (bidFloor) {
data.fp = bidFloor;
}

if (params.inScreenPubID) {
data.pubId = params.inScreenPubID;
data.pi = 2;
Expand Down
29 changes: 29 additions & 0 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,35 @@ describe('gumgumAdapter', function () {
expect(bidRequest.sizes).to.equal(vidMediaTypes.video.playerSize);
});

describe('floorModule', function () {
const floorTestData = {
'currency': 'USD',
'floor': 1.50
};
bidRequests[0].getFloor = _ => {
return floorTestData;
};
it('should return the value from getFloor if present', function () {
const request = { ...bidRequests[0] };
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.fp).to.equal(floorTestData.floor);
});
it('should return the getFloor.floor value if it is greater than bidfloor', function () {
const bidfloor = 0.80;
const request = { ...bidRequests[0] };
request.params.bidfloor = bidfloor;
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.fp).to.equal(floorTestData.floor);
});
it('should return the bidfloor value if it is greater than getFloor.floor', function () {
const bidfloor = 1.80;
const request = { ...bidRequests[0] };
request.params.bidfloor = bidfloor;
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.fp).to.equal(bidfloor);
});
});

it('sends bid request to ENDPOINT via GET', function () {
const request = spec.buildRequests(bidRequests)[0];
expect(request.url).to.equal(ENDPOINT);
Expand Down