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

TheMediaGrid: make gridNMBidAdater as alias for gridBidAdapter #9832

Merged
merged 2 commits into from
Apr 19, 2023
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
61 changes: 42 additions & 19 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
generateUUID,
mergeDeep,
logWarn,
parseUrl, isArray, isNumber
parseUrl,
isArray,
isNumber,
isStr
} from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { Renderer } from '../src/Renderer.js';
Expand Down Expand Up @@ -52,15 +55,20 @@ const ALIAS_CONFIG = {
bidResponseExternal: {
netRevenue: false
}
}
},
'gridNM': {
defaultParams: {
multiRequest: true
}
},
};

let hasSynced = false;

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
aliases: ['playwire', 'adlivetech', { code: 'trustx', skipPbsAliasing: true }],
aliases: ['playwire', 'adlivetech', 'gridNM', { code: 'trustx', skipPbsAliasing: true }],
supportedMediaTypes: [ BANNER, VIDEO ],
/**
* Determines whether or not the given bid request is valid.
Expand Down Expand Up @@ -126,8 +134,9 @@ export const spec = {
if (!endpoint) {
endpoint = ALIAS_CONFIG[bid.bidder] && ALIAS_CONFIG[bid.bidder].endpoint;
}
const { params: { uid, keywords, forceBidder, multiRequest }, mediaTypes, bidId, adUnitCode, rtd, ortb2Imp } = bid;
const { secid, pubid, source, content: bidParamsContent } = bid.params;
const { params, mediaTypes, bidId, adUnitCode, rtd, ortb2Imp } = bid;
const { defaultParams } = ALIAS_CONFIG[bid.bidder] || {};
const { secid, pubid, source, uid, keywords, forceBidder, multiRequest, content: bidParamsContent, video: videoParams } = { ...defaultParams, ...params };
const bidFloor = _getFloor(mediaTypes || {}, bid);
const jwTargeting = rtd && rtd.jwplayer && rtd.jwplayer.targeting;
if (jwTargeting && !content && jwTargeting.content) {
Expand Down Expand Up @@ -178,7 +187,7 @@ export const spec = {
}
}
if (mediaTypes && mediaTypes[VIDEO]) {
const video = createVideoRequest(bid, mediaTypes[VIDEO]);
const video = createVideoRequest(videoParams, mediaTypes[VIDEO], bid.sizes);
if (video) {
impObj.video = video;
}
Expand Down Expand Up @@ -588,27 +597,41 @@ function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst, bid
}
}

function createVideoRequest(bid, mediaType) {
const { playerSize, mimes, durationRangeSec, protocols } = mediaType;
const size = (playerSize || bid.sizes || [])[0];
if (!size) return;
function createVideoRequest(videoParams, mediaType, bidSizes) {
const { mind, maxd, size, playerSize, protocols, durationRangeSec = [], ...videoData } = { ...mediaType, ...videoParams };
if (size && isStr(size)) {
const sizeArray = size.split('x');
if (sizeArray.length === 2 && parseInt(sizeArray[0]) && parseInt(sizeArray[1])) {
videoData.w = parseInt(sizeArray[0]);
videoData.h = parseInt(sizeArray[1]);
}
}
if (!videoData.w || !videoData.h) {
const pSizesString = (playerSize || bidSizes || []).toString();
const pSizeString = (pSizesString.match(/^\d+,\d+/) || [])[0];
const pSize = pSizeString && pSizeString.split(',').map((d) => parseInt(d));
if (pSize && pSize.length === 2) {
Object.assign(videoData, parseGPTSingleSizeArrayToRtbSize(pSize));
}
}

let result = parseGPTSingleSizeArrayToRtbSize(size);
if (!videoData.w || !videoData.h) return;

if (mimes) {
result.mimes = mimes;
}
const minDur = mind || durationRangeSec[0] || videoData.minduration;
const maxDur = maxd || durationRangeSec[1] || videoData.maxduration;

if (durationRangeSec && durationRangeSec.length === 2) {
result.minduration = durationRangeSec[0];
result.maxduration = durationRangeSec[1];
if (minDur) {
videoData.minduration = minDur;
}
if (maxDur) {
videoData.maxduration = maxDur;
}

if (protocols && protocols.length) {
result.protocols = protocols;
videoData.protocols = protocols;
}

return result;
return videoData;
}

function createBannerRequest(bid, mediaType) {
Expand Down
Loading