Skip to content

Commit

Permalink
oneVideo Bid Adapter: adomain & mediaTypes.video Support (SAPR-16874) (
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-browning authored Jun 3, 2021
1 parent 65975d3 commit 25a495c
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 119 deletions.
113 changes: 78 additions & 35 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.1.0',
VERSION: '3.1.1',
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 All @@ -17,26 +17,52 @@ export const spec = {
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function(bid) {
// Bidder code validation
if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') {
return false;
}

// Video validations
if (typeof bid.params.video === 'undefined' || typeof bid.params.video.playerWidth === 'undefined' || typeof bid.params.video.playerHeight == 'undefined' || typeof bid.params.video.mimes == 'undefined') {
return false;
// E2E test skip validations
if (bid.params && bid.params.video && bid.params.video.e2etest) {
return true;
}
// MediaTypes Video / Banner validation
if (typeof bid.mediaTypes.video === 'undefined' && typeof bid.mediaTypes.banner === 'undefined') {
utils.logError('Failed validation: adUnit mediaTypes.video OR mediaTypes.banner not declared');
return false;
};

// Prevend DAP Outstream validation, Banner DAP validation & Multi-Format adUnit support
if (bid.mediaTypes.video) {
if (bid.mediaTypes.video.context === 'outstream' && bid.params.video.display === 1) {
// Player size validation
if (typeof bid.mediaTypes.video.playerSize === 'undefined') {
if (bid.params.video && (typeof bid.params.video.playerWidth === 'undefined' || typeof bid.params.video.playerHeight === 'undefined')) {
utils.logError('Failed validation: Player size not declared in either mediaTypes.playerSize OR bid.params.video.plauerWidth & bid.params.video.playerHeight.');
return false;
};
};
// Mimes validation
if (typeof bid.mediaTypes.video.mimes === 'undefined') {
if (!bid.params.video || typeof bid.params.video.mimes === 'undefined') {
utils.logError('Failed validation: adUnit mediaTypes.mimes OR params.video.mimes not declared');
return false;
};
};
// Prevend DAP Outstream validation, Banner DAP validation & Multi-Format adUnit support
if (bid.mediaTypes.video.context === 'outstream' && bid.params.video && bid.params.video.display === 1) {
utils.logError('Failed validation: Dynamic Ad Placement cannot be used with context Outstream (params.video.display=1)');
return false;
}
} else if (bid.mediaTypes.banner && !bid.params.video.display) {
};
};

// DAP Validation
if (bid.mediaTypes.banner && bid.params.video && !bid.params.video.display) {
utils.logError('Failed validation: If you are trying to use Dynamic Ad Placement you must pass params.video.display=1');
return false;
}
};

// Pub Id validation
// Publisher Id (Exchange) validation
if (typeof bid.params.pubId === 'undefined') {
utils.logError('Failed validation: Adapter cannot send requests without bid.params.pubId');
return false;
}

Expand All @@ -49,7 +75,7 @@ export const spec = {
* @param bidderRequest
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function(bids, bidRequest) {
buildRequests: function (bids, bidRequest) {
let consentData = bidRequest ? bidRequest.gdprConsent : null;

return bids.map(bid => {
Expand Down Expand Up @@ -100,7 +126,10 @@ export const spec = {
currency: response.cur,
ttl: (bidRequest.params.video.ttl > 0 && bidRequest.params.video.ttl <= 3600) ? bidRequest.params.video.ttl : 300,
netRevenue: true,
adUnitCode: bidRequest.adUnitCode
adUnitCode: bidRequest.adUnitCode,
meta: {
advertiserDomains: bid.adomain
}
};

bidResponse.mediaType = (bidRequest.mediaTypes.banner) ? 'banner' : 'video'
Expand Down Expand Up @@ -194,40 +223,54 @@ function getRequestData(bid, consentData, bidRequest) {

if (bid.params.video.display == undefined || bid.params.video.display != 1) {
bidData.imp[0].video = {
mimes: bid.params.video.mimes,
w: bid.params.video.playerWidth,
h: bid.params.video.playerHeight,
pos: bid.params.video.position,
linearity: 1
};
if (bid.params.video.playerWidth && bid.params.video.playerHeight) {
bidData.imp[0].video.w = bid.params.video.playerWidth;
bidData.imp[0].video.h = bid.params.video.playerHeight;
} else {
const playerSize = getSize(bid.mediaTypes.video.playerSize);
bidData.imp[0].video.w = playerSize.width;
bidData.imp[0].video.h = playerSize.height;
};
if (bid.params.video.mimes) {
bidData.imp[0].video.mimes = bid.params.video.mimes;
} else {
bidData.imp[0].video.mimes = bid.mediaTypes.video.mimes;
};
if (bid.params.video.maxbitrate) {
bidData.imp[0].video.maxbitrate = bid.params.video.maxbitrate
if (bid.mediaTypes.video.maxbitrate || bid.params.video.maxbitrate) {
bidData.imp[0].video.maxbitrate = bid.params.video.maxbitrate || bid.mediaTypes.video.maxbitrate;
}
if (bid.params.video.maxduration) {
bidData.imp[0].video.maxduration = bid.params.video.maxduration
if (bid.mediaTypes.video.maxduration || bid.params.video.maxduration) {
bidData.imp[0].video.maxduration = bid.params.video.maxduration || bid.mediaTypes.video.maxduration;
}
if (bid.params.video.minduration) {
bidData.imp[0].video.minduration = bid.params.video.minduration
if (bid.mediaTypes.video.minduration || bid.params.video.minduration) {
bidData.imp[0].video.minduration = bid.params.video.minduration || bid.mediaTypes.video.minduration;
}
if (bid.params.video.api) {
bidData.imp[0].video.api = bid.params.video.api
if (bid.mediaTypes.video.api || bid.params.video.api) {
bidData.imp[0].video.api = bid.params.video.api || bid.mediaTypes.video.api;
}
if (bid.params.video.delivery) {
bidData.imp[0].video.delivery = bid.params.video.delivery
if (bid.mediaTypes.video.delivery || bid.params.video.delivery) {
bidData.imp[0].video.delivery = bid.params.video.delivery || bid.mediaTypes.video.delivery;
}
if (bid.params.video.position) {
bidData.imp[0].video.pos = bid.params.video.position
if (bid.mediaTypes.video.position || bid.params.video.position) {
bidData.imp[0].video.pos = bid.params.video.position || bid.mediaTypes.video.position;
}
if (bid.params.video.playbackmethod) {
bidData.imp[0].video.playbackmethod = bid.params.video.playbackmethod
if (bid.mediaTypes.video.playbackmethod || bid.params.video.playbackmethod) {
bidData.imp[0].video.playbackmethod = bid.params.video.playbackmethod || bid.mediaTypes.video.playbackmethod;
}
if (bid.params.video.placement) {
bidData.imp[0].video.placement = bid.params.video.placement
if (bid.mediaTypes.video.placement || bid.params.video.placement) {
bidData.imp[0].video.placement = bid.params.video.placement || bid.mediaTypes.video.placement;
}
if (bid.params.video.rewarded) {
bidData.imp[0].ext.rewarded = bid.params.video.rewarded
}
bidData.imp[0].video.linearity = 1;
bidData.imp[0].video.protocols = bid.params.video.protocols || [2, 5];
if (bid.mediaTypes.video.linearity || bid.params.video.linearity) {
bidData.imp[0].video.linearity = bid.params.video.linearity || bid.mediaTypes.video.linearity || 1;
}
if (bid.mediaTypes.video.protocols || bid.params.video.protocols) {
bidData.imp[0].video.protocols = bid.params.video.protocols || bid.mediaTypes.video.protocols || [2, 5];
}
} else if (bid.params.video.display == 1) {
getFloorRequestObject.mediaType = 'banner';
bidData.imp[0].banner = {
Expand Down Expand Up @@ -307,7 +350,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');
utils.logMessage('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');
bidData.imp[0].bidfloor = null;
bidData.imp[0].video.w = 300;
bidData.imp[0].video.h = 250;
Expand Down
Loading

0 comments on commit 25a495c

Please sign in to comment.