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

oneVideo Bid Adapter: Price Floors Module Support (SAPR-16735) #6672

Merged
merged 11 commits into from
Apr 28, 2021
20 changes: 17 additions & 3 deletions modules/oneVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'oneVideo';
export const spec = {
code: 'oneVideo',
VERSION: '3.0.7',
VERSION: '3.1.0',
ENDPOINT: 'https://ads.adaptv.advertising.com/rtb/openrtb?ext_id=',
E2ETESTENDPOINT: 'https://ads-wc.v.ssp.yahoo.com/rtb/openrtb?ext_id=',
SYNC_ENDPOINT1: 'https://pixel.advertising.com/ups/57304/sync?gdpr=&gdpr_consent=&_origin=0&redir=true',
Expand Down Expand Up @@ -165,14 +165,17 @@ function getRequestData(bid, consentData, bidRequest) {
let loc = bidRequest.refererInfo.referer;
let page = (bid.params.site && bid.params.site.page) ? (bid.params.site.page) : (loc.href);
let ref = (bid.params.site && bid.params.site.referrer) ? bid.params.site.referrer : bidRequest.refererInfo.referer;
let getFloorRequestObject = {
currency: bid.params.cur || 'USD',
mediaType: 'video',
size: '\*'
adam-browning marked this conversation as resolved.
Show resolved Hide resolved
adam-browning marked this conversation as resolved.
Show resolved Hide resolved
};
let bidData = {
id: utils.generateUUID(),
at: 2,
cur: bid.cur || 'USD',
imp: [{
id: '1',
secure: isSecure(),
bidfloor: bid.params.bidfloor,
ext: {
hb: 1,
prebidver: '$prebid.version$',
Expand Down Expand Up @@ -226,6 +229,7 @@ function getRequestData(bid, consentData, bidRequest) {
bidData.imp[0].video.linearity = 1;
bidData.imp[0].video.protocols = bid.params.video.protocols || [2, 5];
} else if (bid.params.video.display == 1) {
getFloorRequestObject.mediaType = 'banner';
bidData.imp[0].banner = {
mimes: bid.params.video.mimes,
w: bid.params.video.playerWidth,
Expand All @@ -244,6 +248,15 @@ function getRequestData(bid, consentData, bidRequest) {
bidData.imp[0].banner.ext.minduration = bid.params.video.minduration
}
}

if (utils.isFn(bid.getFloor)) {
let floorData = bid.getFloor(getFloorRequestObject);
bidData.imp[0].bidfloor = floorData.floor;
bidData.cur = floorData.currency;
} else {
bidData.imp[0].bidfloor = bid.params.bidfloor;
};

if (bid.params.video.inventoryid) {
bidData.imp[0].ext.inventoryid = bid.params.video.inventoryid
}
Expand Down Expand Up @@ -294,6 +307,7 @@ function getRequestData(bid, consentData, bidRequest) {
}
}
if (bid.params.video.e2etest) {
utils.logMessage('+++ oneVideoBidAdapter: E2E test mode enabled. \n The following parameters are being overridden by e2etest mode:\n* bidfloor:null\n* width:300\n* height:250\n* mimes: video/mp4, application/javascript\n* api:2\n* site.page/ref: verizonmedia.com\n* tmax:1000');
adam-browning marked this conversation as resolved.
Show resolved Hide resolved
bidData.imp[0].bidfloor = null;
bidData.imp[0].video.w = 300;
bidData.imp[0].video.h = 250;
Expand Down
103 changes: 95 additions & 8 deletions test/spec/modules/oneVideoBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
expect
} from 'chai';
import {
spec
} from 'modules/oneVideoBidAdapter.js';
import * as utils from 'src/utils.js';
import { expect } from 'chai';
import { spec } from 'modules/oneVideoBidAdapter.js';

describe('OneVideoBidAdapter', function () {
let bidRequest;
Expand Down Expand Up @@ -221,7 +216,7 @@ describe('OneVideoBidAdapter', function () {
const placement = bidRequest.params.video.placement;
const rewarded = bidRequest.params.video.rewarded;
const inventoryid = bidRequest.params.video.inventoryid;
const VERSION = '3.0.7';
const VERSION = '3.1.0';
expect(data.imp[0].video.w).to.equal(width);
expect(data.imp[0].video.h).to.equal(height);
expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor);
Expand Down Expand Up @@ -503,6 +498,98 @@ describe('OneVideoBidAdapter', function () {
});
});

describe('price floor module validations', function () {
beforeEach(function () {
bidRequest.getFloor = (floorObj) => {
return {
floor: bidRequest.floors.values[floorObj.mediaType + '|640x480'],
currency: floorObj.currency,
mediaType: floorObj.mediaType
}
}
});

it('should get bidfloor from getFloor method', function () {
bidRequest.params.cur = 'EUR';
bidRequest.floors = {
currency: 'EUR',
values: {
'video|640x480': 5.55
}
};
const requests = spec.buildRequests([bidRequest], bidderRequest);
const data = requests[0].data;
expect(data.cur).is.a('string');
expect(data.cur).to.equal('EUR');
expect(data.imp[0].bidfloor).is.a('number');
expect(data.imp[0].bidfloor).to.equal(5.55);
});

it('should use adUnit/module currency & floor instead of bid.params.bidfloor', function () {
bidRequest.params.cur = 'EUR';
bidRequest.params.bidfloor = 3.33;
bidRequest.floors = {
currency: 'EUR',
values: {
'video|640x480': 5.55
}
};
const requests = spec.buildRequests([bidRequest], bidderRequest);
const data = requests[0].data;
expect(data.cur).is.a('string');
expect(data.cur).to.equal('EUR');
expect(data.imp[0].bidfloor).is.a('number');
expect(data.imp[0].bidfloor).to.equal(5.55);
});

it('should load banner instead of video floor when DAP is active bid.params.video.display = 1', function () {
bidRequest.params.video.display = 1;
bidRequest.params.cur = 'EUR';
bidRequest.mediaTypes = {
banner: {
sizes: [
[640, 480]
]
}
};
bidRequest.floors = {
currency: 'EUR',
values: {
'banner|640x480': 2.22,
'video|640x480': 9.99
}
};
const requests = spec.buildRequests([bidRequest], bidderRequest);
const data = requests[0].data;
expect(data.cur).is.a('string');
expect(data.cur).to.equal('EUR');
expect(data.imp[0].bidfloor).is.a('number');
expect(data.imp[0].bidfloor).to.equal(2.22);
})

it('should load video floor when multi-format adUnit is present', function () {
bidRequest.params.cur = 'EUR';
bidRequest.mediaTypes.banner = {
sizes: [
[640, 480]
]
};
bidRequest.floors = {
currency: 'EUR',
values: {
'banner|640x480': 2.22,
'video|640x480': 9.99
}
};
const requests = spec.buildRequests([bidRequest], bidderRequest);
const data = requests[0].data;
expect(data.cur).is.a('string');
expect(data.cur).to.equal('EUR');
expect(data.imp[0].bidfloor).is.a('number');
expect(data.imp[0].bidfloor).to.equal(9.99);
})
})

describe('spec.interpretResponse', function () {
it('should return no bids if the response is not valid', function () {
const bidResponse = spec.interpretResponse({
Expand Down