Skip to content

Commit

Permalink
GumGum Bid Adapter: pass bidfloor currency in bidrequest (prebid#6391)
Browse files Browse the repository at this point in the history
* adds support for zone and pubId params

* adds support for iriscat field

* sets mediatype depending on product id

* Update doc for mediaType needed for video products

* makes slot and invideo products avail for pubId

* updates gumgum doc

* lint

* adds missing comma in gumgum doc

* adds currency in ad request, adds unit test

* readd the previous irisid changes

* remove the only in testing
  • Loading branch information
susyt authored and seergiioo6 committed Mar 23, 2021
1 parent 7eddc4b commit a8f8b89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 12 additions & 12 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,24 @@ function _getVidParams (attributes) {
* @param {Object} bid
* @returns {Number} floor
*/
function _getFloor (mediaTypes, bidfloor, bid) {
function _getFloor (mediaTypes, staticBidfloor, bid) {
const curMediaType = Object.keys(mediaTypes)[0] || 'banner';
let floor = bidfloor || 0;
const bidFloor = { floor: 0, currency: 'USD' };

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

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

return floor;
return bidFloor;
}

/**
Expand All @@ -250,7 +249,7 @@ function buildRequests (validBidRequests, bidderRequest) {
transactionId,
userId = {}
} = bidRequest;
const bidFloor = _getFloor(mediaTypes, params.bidfloor, bidRequest);
const { currency, floor } = _getFloor(mediaTypes, params.bidfloor, bidRequest);
let sizes = [1, 1];
let data = {};

Expand All @@ -265,8 +264,9 @@ function buildRequests (validBidRequests, bidderRequest) {
data.pv = pageViewId;
}

if (bidFloor) {
data.fp = bidFloor;
if (floor) {
data.fp = floor;
data.fpc = currency;
}

if (params.iriscat && typeof params.iriscat === 'string') {
Expand Down
4 changes: 4 additions & 0 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ describe('gumgumAdapter', function () {
const bidRequest = spec.buildRequests([request])[0];
expect(bidRequest.data.fp).to.equal(bidfloor);
});
it('should return a floor currency', function () {
const request = spec.buildRequests(bidRequests)[0];
expect(request.data.fpc).to.equal(floorTestData.currency);
})
});

it('sends bid request to ENDPOINT via GET', function () {
Expand Down

0 comments on commit a8f8b89

Please sign in to comment.