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

Sovrn: Add Support for Floor Module #6155

Merged
merged 14 commits into from
Jan 14, 2021
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
17 changes: 12 additions & 5 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const spec = {
* @return boolean for whether or not a bid is valid
*/
isBidRequestValid: function(bid) {
return !!(bid.params.tagid && !isNaN(parseFloat(bid.params.tagid)) && isFinite(bid.params.tagid));
return !!(bid.params.tagid && !isNaN(parseFloat(bid.params.tagid)) && isFinite(bid.params.tagid))
},

/**
Expand Down Expand Up @@ -45,14 +45,21 @@ export const spec = {
}

if (bid.schain) {
schain = schain || bid.schain;
schain = schain || bid.schain
}
iv = iv || utils.getBidIdParameter('iv', bid.params);
iv = iv || utils.getBidIdParameter('iv', bid.params)

let bidSizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes;
let bidSizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes
bidSizes = ((utils.isArray(bidSizes) && utils.isArray(bidSizes[0])) ? bidSizes : [bidSizes])
bidSizes = bidSizes.filter(size => utils.isArray(size))
const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)}))
const floorInfo = (bid.getFloor && typeof bid.getFloor === 'function') ? bid.getFloor({
currency: 'USD',
mediaType: 'banner',
size: '*'
}) : {}
floorInfo.floor = floorInfo.floor || utils.getBidIdParameter('bidfloor', bid.params)

const imp = {
adunitcode: bid.adUnitCode,
id: bid.bidId,
Expand All @@ -62,7 +69,7 @@ export const spec = {
h: 1,
},
tagid: String(utils.getBidIdParameter('tagid', bid.params)),
bidfloor: utils.getBidIdParameter('bidfloor', bid.params)
bidfloor: floorInfo.floor
}

const segmentsString = utils.getBidIdParameter('segments', bid.params)
Expand Down
39 changes: 37 additions & 2 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ import {newBidder} from 'src/adapters/bidderFactory.js';

const ENDPOINT = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$`;

const adUnitBidRequest = {
'bidder': 'sovrn',
'params': {
'tagid': '403370'
},
'adUnitCode': 'adunit-code',
'sizes': [
[300, 250],
[300, 600]
],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
}

describe('sovrnBidAdapter', function() {
const adapter = newBidder(spec);

describe('isBidRequestValid', function () {
let bid = {
const bid = {
'bidder': 'sovrn',
'params': {
'tagid': '403370'
Expand Down Expand Up @@ -296,12 +311,32 @@ describe('sovrnBidAdapter', function() {
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475'
}];
}]
const request = spec.buildRequests(segmentsRequests, bidderRequest)
const payload = JSON.parse(request.data)
expect(payload.imp[0].ext.deals[0]).to.equal('test1')
expect(payload.imp[0].ext.deals[1]).to.equal('test2')
})
it('should use the floor provided from the floor module if present', function() {
const floorBid = {...adUnitBidRequest, getFloor: () => ({currency: 'USD', floor: 1.10})}
floorBid.params = {
tagid: 1234,
bidfloor: 2.00
}
const request = spec.buildRequests([floorBid], bidderRequest)
const payload = JSON.parse(request.data)
expect(payload.imp[0].bidfloor).to.equal(1.10)
})
it('should use the floor from the param if there is no floor from the floor module', function() {
const floorBid = {...adUnitBidRequest, getFloor: () => ({})}
floorBid.params = {
tagid: 1234,
bidfloor: 2.00
}
const request = spec.buildRequests([floorBid], bidderRequest)
const payload = JSON.parse(request.data)
expect(payload.imp[0].bidfloor).to.equal(2.00)
})
});

describe('interpretResponse', function () {
Expand Down