From 15f4b9c7f1903704dfafbb87da3bdce7365fce68 Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Tue, 7 May 2019 10:37:59 -0400 Subject: [PATCH 1/8] change userid to pubcid --- modules/yieldmoBidAdapter.js | 30 +- modules/yieldmoBidAdapter.md | 3 +- modules/yieldmoBidAdapter.txt | 328 ++++++++++++++++++++ test/spec/modules/yieldmoBidAdapter_spec.js | 19 ++ 4 files changed, 368 insertions(+), 12 deletions(-) create mode 100644 modules/yieldmoBidAdapter.txt diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index d904791d29a..df8d36c1aa7 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -18,6 +18,7 @@ export const spec = { * @return boolean, true if valid, otherwise false */ isBidRequestValid: function(bid) { + console.log('this is the bid! ', bid); return !!(bid && bid.adUnitCode && bid.bidId); }, /** @@ -27,6 +28,7 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests) { + console.log('bid request: ', bidRequests); let serverRequest = { p: [], page_url: utils.getTopWindowUrl(), @@ -43,13 +45,14 @@ export const spec = { bidRequests.forEach((request) => { serverRequest.p.push(addPlacement(request)); - const userId = getUserId(request) - if (userId) { - const pubcid = userId.pubcid; - serverRequest.pubcid = pubcid; + const pubcId = getPubcId(request); + console.log('request: ', request); + if (pubcId) { + serverRequest.pubcid = pubcId; } else { serverRequest.pubcid = request.crumbs.pubcid; } + }); serverRequest.p = '[' + serverRequest.p.toString() + ']'; return { @@ -103,8 +106,13 @@ function addPlacement(request) { callback_id: request.bidId, sizes: request.sizes } - if (request.params && request.params.placementId) { - placementInfo.ym_placement_id = request.params.placementId + if (request.params) { + + } if(request.params.placementId) { + placementInfo.ym_placement_id = request.params.placementId; + } + if (request.params.bidFloor) { + placementInfo.bidFloor = request.params.bidFloor; } return JSON.stringify(placementInfo); } @@ -311,10 +319,10 @@ function isMraid() { return !!(window.mraid); } -function getUserId(request) { - let userId; - if (request && request.userId && typeof request.userId === 'object') { - userId = request.userId; +function getPubcId(request) { + let pubcid; + if (request && request.userId && request.userId.pubcid && typeof request.userId === 'object') { + pubcid = request.userId.pubcid; } - return userId; + return pubcid; } diff --git a/modules/yieldmoBidAdapter.md b/modules/yieldmoBidAdapter.md index 8c60202d7ea..7221f2ebdd0 100644 --- a/modules/yieldmoBidAdapter.md +++ b/modules/yieldmoBidAdapter.md @@ -23,7 +23,8 @@ var adUnits = [ bids: [{ bidder: 'yieldmo', params: { - placementId: '1779781193098233305' // string with at most 19 characters (may include numbers only) + placementId: '1779781193098233305', // string with at most 19 characters (may include numbers only) + bidFloor: .28 // optional param } }] } diff --git a/modules/yieldmoBidAdapter.txt b/modules/yieldmoBidAdapter.txt new file mode 100644 index 00000000000..df8d36c1aa7 --- /dev/null +++ b/modules/yieldmoBidAdapter.txt @@ -0,0 +1,328 @@ +import * as utils from '../src/utils'; +import { registerBidder } from '../src/adapters/bidderFactory'; + +const BIDDER_CODE = 'yieldmo'; +const CURRENCY = 'USD'; +const TIME_TO_LIVE = 300; +const NET_REVENUE = true; +const SYNC_ENDPOINT = 'https://static.yieldmo.com/blank.min.html?orig='; +const SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; +const localWindow = getTopWindow(); + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: ['banner'], + /** + * Determines whether or not the given bid request is valid. + * @param {object} bid, bid to validate + * @return boolean, true if valid, otherwise false + */ + isBidRequestValid: function(bid) { + console.log('this is the bid! ', bid); + return !!(bid && bid.adUnitCode && bid.bidId); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(bidRequests) { + console.log('bid request: ', bidRequests); + let serverRequest = { + p: [], + page_url: utils.getTopWindowUrl(), + bust: new Date().getTime().toString(), + pr: utils.getTopWindowReferrer(), + scrd: localWindow.devicePixelRatio || 0, + dnt: getDNT(), + e: getEnvironment(), + description: getPageDescription(), + title: localWindow.document.title || '', + w: localWindow.innerWidth, + h: localWindow.innerHeight + }; + + bidRequests.forEach((request) => { + serverRequest.p.push(addPlacement(request)); + const pubcId = getPubcId(request); + console.log('request: ', request); + if (pubcId) { + serverRequest.pubcid = pubcId; + } else { + serverRequest.pubcid = request.crumbs.pubcid; + } + + }); + serverRequest.p = '[' + serverRequest.p.toString() + ']'; + return { + method: 'GET', + url: SERVER_ENDPOINT, + data: serverRequest + } + }, + /** + * Makes Yieldmo Ad Server response compatible to Prebid specs + * @param serverResponse successful response from Ad Server + * @param bidderRequest original bidRequest + * @return {Bid[]} an array of bids + */ + interpretResponse: function(serverResponse) { + let bids = []; + let data = serverResponse.body; + if (data.length > 0) { + data.forEach((response) => { + if (response.cpm && response.cpm > 0) { + bids.push(createNewBid(response)); + } + }); + } + return bids; + }, + getUserSync: function(syncOptions) { + if (trackingEnabled(syncOptions)) { + return [{ + type: 'iframe', + url: SYNC_ENDPOINT + utils.getOrigin() + }]; + } else { + return []; + } + } +} +registerBidder(spec); + +/*************************************** + * Helper Functions + ***************************************/ + +/** + * Adds placement information to array + * @param request bid request + */ +function addPlacement(request) { + const placementInfo = { + placement_id: request.adUnitCode, + callback_id: request.bidId, + sizes: request.sizes + } + if (request.params) { + + } if(request.params.placementId) { + placementInfo.ym_placement_id = request.params.placementId; + } + if (request.params.bidFloor) { + placementInfo.bidFloor = request.params.bidFloor; + } + return JSON.stringify(placementInfo); +} + +/** + * creates a new bid with response information + * @param response server response + */ +function createNewBid(response) { + return { + requestId: response['callback_id'], + cpm: response.cpm, + width: response.width, + height: response.height, + creativeId: response.creative_id, + currency: CURRENCY, + netRevenue: NET_REVENUE, + ttl: TIME_TO_LIVE, + ad: response.ad + }; +} + +/** + * Detects if tracking is allowed + * @returns false if dnt or if not iframe/pixel enabled + */ +function trackingEnabled(options) { + return (isIOS() && !getDNT() && options.iframeEnabled); +} + +/** + * Detects whether we're in iOS + * @returns true if in iOS + */ +function isIOS() { + return /iPhone|iPad|iPod/i.test(window.navigator.userAgent); +} + +/** + * Detects whether dnt is true + * @returns true if user enabled dnt + */ +function getDNT() { + return window.doNotTrack === '1' || window.navigator.doNotTrack === '1' || false; +} + +/** + * get page description + */ +function getPageDescription() { + if (document.querySelector('meta[name="description"]')) { + return document.querySelector('meta[name="description"]').getAttribute('content'); // Value of the description metadata from the publisher's page. + } else { + return ''; + } +} + +function getTopWindow() { + try { + return window.top; + } catch (e) { + return window; + } +} + +/*************************************** + * Detect Environment Helper Functions + ***************************************/ + +/** + * Represents a method for loading Yieldmo ads. Environments affect + * which formats can be loaded into the page + * Environments: + * CodeOnPage: 0, // div directly on publisher's page + * Amp: 1, // google Accelerate Mobile Pages ampproject.org + * Mraid = 2, // native loaded through the MRAID spec, without Yieldmo's SDK https://www.iab.net/media/file/IAB_MRAID_v2_FINAL.pdf + * Dfp: 4, // google doubleclick for publishers https://www.doubleclickbygoogle.com/ + * DfpInAmp: 5, // AMP page containing a DFP iframe + * SafeFrame: 10, + * DfpSafeFrame: 11,Sandboxed: 16, // An iframe that can't get to the top window. + * SuperSandboxed: 89, // An iframe without allow-same-origin + * Unknown: 90, // A default sandboxed implementation delivered by EnvironmentDispatch when all positive environment checks fail + */ + +/** + * Detects what environment we're in + * @returns Environment kind + */ +function getEnvironment() { + if (isSuperSandboxedIframe()) { + return 89; + } else if (isDfpInAmp()) { + return 5; + } else if (isDfp()) { + return 4; + } else if (isAmp()) { + return 1; + } else if (isDFPSafeFrame()) { + return 11; + } else if (isSafeFrame()) { + return 10; + } else if (isMraid()) { + return 2; + } else if (isCodeOnPage()) { + return 0; + } else if (isSandboxedIframe()) { + return 16; + } else { + return 90; + } +} + +/** + * @returns true if we are running on the top window at dispatch time + */ +function isCodeOnPage() { + return window === window.parent; +} + +/** + * @returns true if the environment is both DFP and AMP + */ +function isDfpInAmp() { + return isDfp() && isAmp(); +} + +/** + * @returns true if the window is in an iframe whose id and parent element id match DFP + */ +function isDfp() { + try { + const frameElement = window.frameElement; + const parentElement = window.frameElement.parentNode; + if (frameElement && parentElement) { + return frameElement.id.indexOf('google_ads_iframe') > -1 && parentElement.id.indexOf('google_ads_iframe') > -1; + } + return false; + } catch (e) { + return false; + } +} + +/** +* @returns true if there is an AMP context object +*/ +function isAmp() { + try { + const ampContext = window.context || window.parent.context; + if (ampContext && ampContext.pageViewId) { + return ampContext; + } + return false; + } catch (e) { + return false; + } +} + +/** + * @returns true if the environment is a SafeFrame. + */ +function isSafeFrame() { + return window.$sf && window.$sf.ext; +} + +/** + * @returns true if the environment is a dfp safe frame. + */ +function isDFPSafeFrame() { + if (window.location && window.location.href) { + const href = window.location.href; + return isSafeFrame() && href.indexOf('google') !== -1 && href.indexOf('safeframe') !== -1; + } + return false; +} + +/** + * Return true if we are in an iframe and can't access the top window. + */ +function isSandboxedIframe() { + return window.top !== window && !window.frameElement; +} + +/** + * Return true if we cannot document.write to a child iframe (this implies no allow-same-origin) + */ +function isSuperSandboxedIframe() { + const sacrificialIframe = window.document.createElement('iframe'); + try { + sacrificialIframe.setAttribute('style', 'display:none'); + window.document.body.appendChild(sacrificialIframe); + sacrificialIframe.contentWindow._testVar = true; + window.document.body.removeChild(sacrificialIframe); + return false; + } catch (e) { + window.document.body.removeChild(sacrificialIframe); + return true; + } +} + +/** + * @returns true if the window has the attribute identifying MRAID + */ +function isMraid() { + return !!(window.mraid); +} + +function getPubcId(request) { + let pubcid; + if (request && request.userId && request.userId.pubcid && typeof request.userId === 'object') { + pubcid = request.userId.pubcid; + } + return pubcid; +} diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 80a9265a5c2..cb39f96a544 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -115,6 +115,25 @@ describe('YieldmoAdapter', function () { const data = spec.buildRequests([pubcidBid]).data; expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); }) + + it('should add bidFloor as parameter of request if given', function () { + const bidFloorBid = { + bidder: 'yieldmo', + params: { + bidFloor: 5 + }, + adUnitCode: 'adunit-code', + sizes: [[300, 250], [300, 600]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: { + pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' + } + }; + const data = spec.buildRequests([bidFloorBid]).data; + expect(data.bidFloor).to.deep.equal(5); + }) }); describe('interpretResponse', function () { From ae9e9e43660e05302b7c2a270c4a3ff00d9d6d0e Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Wed, 5 Jun 2019 10:05:05 -0400 Subject: [PATCH 2/8] removes consolelogs --- modules/yieldmoBidAdapter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index 501fce7aab7..e1c91b0170d 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -18,7 +18,6 @@ export const spec = { * @return boolean, true if valid, otherwise false */ isBidRequestValid: function(bid) { - console.log('this is the bid! ', bid); return !!(bid && bid.adUnitCode && bid.bidId); }, /** @@ -28,7 +27,6 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests) { - console.log('bid request: ', bidRequests); let serverRequest = { p: [], page_url: utils.getTopWindowUrl(), From 4dd50a5f9b255b42a96a0d323920774992d41694 Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Wed, 5 Jun 2019 10:49:34 -0400 Subject: [PATCH 3/8] removes .txt file --- modules/yieldmoBidAdapter.txt | 328 ---------------------------------- 1 file changed, 328 deletions(-) delete mode 100644 modules/yieldmoBidAdapter.txt diff --git a/modules/yieldmoBidAdapter.txt b/modules/yieldmoBidAdapter.txt deleted file mode 100644 index df8d36c1aa7..00000000000 --- a/modules/yieldmoBidAdapter.txt +++ /dev/null @@ -1,328 +0,0 @@ -import * as utils from '../src/utils'; -import { registerBidder } from '../src/adapters/bidderFactory'; - -const BIDDER_CODE = 'yieldmo'; -const CURRENCY = 'USD'; -const TIME_TO_LIVE = 300; -const NET_REVENUE = true; -const SYNC_ENDPOINT = 'https://static.yieldmo.com/blank.min.html?orig='; -const SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; -const localWindow = getTopWindow(); - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: ['banner'], - /** - * Determines whether or not the given bid request is valid. - * @param {object} bid, bid to validate - * @return boolean, true if valid, otherwise false - */ - isBidRequestValid: function(bid) { - console.log('this is the bid! ', bid); - return !!(bid && bid.adUnitCode && bid.bidId); - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests) { - console.log('bid request: ', bidRequests); - let serverRequest = { - p: [], - page_url: utils.getTopWindowUrl(), - bust: new Date().getTime().toString(), - pr: utils.getTopWindowReferrer(), - scrd: localWindow.devicePixelRatio || 0, - dnt: getDNT(), - e: getEnvironment(), - description: getPageDescription(), - title: localWindow.document.title || '', - w: localWindow.innerWidth, - h: localWindow.innerHeight - }; - - bidRequests.forEach((request) => { - serverRequest.p.push(addPlacement(request)); - const pubcId = getPubcId(request); - console.log('request: ', request); - if (pubcId) { - serverRequest.pubcid = pubcId; - } else { - serverRequest.pubcid = request.crumbs.pubcid; - } - - }); - serverRequest.p = '[' + serverRequest.p.toString() + ']'; - return { - method: 'GET', - url: SERVER_ENDPOINT, - data: serverRequest - } - }, - /** - * Makes Yieldmo Ad Server response compatible to Prebid specs - * @param serverResponse successful response from Ad Server - * @param bidderRequest original bidRequest - * @return {Bid[]} an array of bids - */ - interpretResponse: function(serverResponse) { - let bids = []; - let data = serverResponse.body; - if (data.length > 0) { - data.forEach((response) => { - if (response.cpm && response.cpm > 0) { - bids.push(createNewBid(response)); - } - }); - } - return bids; - }, - getUserSync: function(syncOptions) { - if (trackingEnabled(syncOptions)) { - return [{ - type: 'iframe', - url: SYNC_ENDPOINT + utils.getOrigin() - }]; - } else { - return []; - } - } -} -registerBidder(spec); - -/*************************************** - * Helper Functions - ***************************************/ - -/** - * Adds placement information to array - * @param request bid request - */ -function addPlacement(request) { - const placementInfo = { - placement_id: request.adUnitCode, - callback_id: request.bidId, - sizes: request.sizes - } - if (request.params) { - - } if(request.params.placementId) { - placementInfo.ym_placement_id = request.params.placementId; - } - if (request.params.bidFloor) { - placementInfo.bidFloor = request.params.bidFloor; - } - return JSON.stringify(placementInfo); -} - -/** - * creates a new bid with response information - * @param response server response - */ -function createNewBid(response) { - return { - requestId: response['callback_id'], - cpm: response.cpm, - width: response.width, - height: response.height, - creativeId: response.creative_id, - currency: CURRENCY, - netRevenue: NET_REVENUE, - ttl: TIME_TO_LIVE, - ad: response.ad - }; -} - -/** - * Detects if tracking is allowed - * @returns false if dnt or if not iframe/pixel enabled - */ -function trackingEnabled(options) { - return (isIOS() && !getDNT() && options.iframeEnabled); -} - -/** - * Detects whether we're in iOS - * @returns true if in iOS - */ -function isIOS() { - return /iPhone|iPad|iPod/i.test(window.navigator.userAgent); -} - -/** - * Detects whether dnt is true - * @returns true if user enabled dnt - */ -function getDNT() { - return window.doNotTrack === '1' || window.navigator.doNotTrack === '1' || false; -} - -/** - * get page description - */ -function getPageDescription() { - if (document.querySelector('meta[name="description"]')) { - return document.querySelector('meta[name="description"]').getAttribute('content'); // Value of the description metadata from the publisher's page. - } else { - return ''; - } -} - -function getTopWindow() { - try { - return window.top; - } catch (e) { - return window; - } -} - -/*************************************** - * Detect Environment Helper Functions - ***************************************/ - -/** - * Represents a method for loading Yieldmo ads. Environments affect - * which formats can be loaded into the page - * Environments: - * CodeOnPage: 0, // div directly on publisher's page - * Amp: 1, // google Accelerate Mobile Pages ampproject.org - * Mraid = 2, // native loaded through the MRAID spec, without Yieldmo's SDK https://www.iab.net/media/file/IAB_MRAID_v2_FINAL.pdf - * Dfp: 4, // google doubleclick for publishers https://www.doubleclickbygoogle.com/ - * DfpInAmp: 5, // AMP page containing a DFP iframe - * SafeFrame: 10, - * DfpSafeFrame: 11,Sandboxed: 16, // An iframe that can't get to the top window. - * SuperSandboxed: 89, // An iframe without allow-same-origin - * Unknown: 90, // A default sandboxed implementation delivered by EnvironmentDispatch when all positive environment checks fail - */ - -/** - * Detects what environment we're in - * @returns Environment kind - */ -function getEnvironment() { - if (isSuperSandboxedIframe()) { - return 89; - } else if (isDfpInAmp()) { - return 5; - } else if (isDfp()) { - return 4; - } else if (isAmp()) { - return 1; - } else if (isDFPSafeFrame()) { - return 11; - } else if (isSafeFrame()) { - return 10; - } else if (isMraid()) { - return 2; - } else if (isCodeOnPage()) { - return 0; - } else if (isSandboxedIframe()) { - return 16; - } else { - return 90; - } -} - -/** - * @returns true if we are running on the top window at dispatch time - */ -function isCodeOnPage() { - return window === window.parent; -} - -/** - * @returns true if the environment is both DFP and AMP - */ -function isDfpInAmp() { - return isDfp() && isAmp(); -} - -/** - * @returns true if the window is in an iframe whose id and parent element id match DFP - */ -function isDfp() { - try { - const frameElement = window.frameElement; - const parentElement = window.frameElement.parentNode; - if (frameElement && parentElement) { - return frameElement.id.indexOf('google_ads_iframe') > -1 && parentElement.id.indexOf('google_ads_iframe') > -1; - } - return false; - } catch (e) { - return false; - } -} - -/** -* @returns true if there is an AMP context object -*/ -function isAmp() { - try { - const ampContext = window.context || window.parent.context; - if (ampContext && ampContext.pageViewId) { - return ampContext; - } - return false; - } catch (e) { - return false; - } -} - -/** - * @returns true if the environment is a SafeFrame. - */ -function isSafeFrame() { - return window.$sf && window.$sf.ext; -} - -/** - * @returns true if the environment is a dfp safe frame. - */ -function isDFPSafeFrame() { - if (window.location && window.location.href) { - const href = window.location.href; - return isSafeFrame() && href.indexOf('google') !== -1 && href.indexOf('safeframe') !== -1; - } - return false; -} - -/** - * Return true if we are in an iframe and can't access the top window. - */ -function isSandboxedIframe() { - return window.top !== window && !window.frameElement; -} - -/** - * Return true if we cannot document.write to a child iframe (this implies no allow-same-origin) - */ -function isSuperSandboxedIframe() { - const sacrificialIframe = window.document.createElement('iframe'); - try { - sacrificialIframe.setAttribute('style', 'display:none'); - window.document.body.appendChild(sacrificialIframe); - sacrificialIframe.contentWindow._testVar = true; - window.document.body.removeChild(sacrificialIframe); - return false; - } catch (e) { - window.document.body.removeChild(sacrificialIframe); - return true; - } -} - -/** - * @returns true if the window has the attribute identifying MRAID - */ -function isMraid() { - return !!(window.mraid); -} - -function getPubcId(request) { - let pubcid; - if (request && request.userId && request.userId.pubcid && typeof request.userId === 'object') { - pubcid = request.userId.pubcid; - } - return pubcid; -} From 983f1359cf6f4c8ab68e9059f7dd64f1d4e4c7ac Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Wed, 5 Jun 2019 13:21:46 -0400 Subject: [PATCH 4/8] fixes test --- modules/yieldmoBidAdapter.js | 9 ++--- test/spec/modules/yieldmoBidAdapter_spec.js | 40 +++++++-------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index e1c91b0170d..4e6db50fe6d 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -43,12 +43,13 @@ export const spec = { bidRequests.forEach((request) => { serverRequest.p.push(addPlacement(request)); - const userId = getPubcId(request) - if (userId) { - const pubcid = userId.pubcid; + const pubcid = getPubcId(request) + if (pubcid) { serverRequest.pubcid = pubcid; } else if (request.crumbs) { - serverRequest.pubcid = request.crumbs.pubcid; + if (request.crumbs.pubcid) { + serverRequest.pubcid = request.crumbs.pubcid; + } } }); serverRequest.p = '[' + serverRequest.p.toString() + ']'; diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 30ff39247b8..2a94dc7e5c9 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -9,7 +9,9 @@ describe('YieldmoAdapter', function () { let bid = { bidder: 'yieldmo', - params: {}, + params: { + bidFloor: 0.1 + }, adUnitCode: 'adunit-code', sizes: [[300, 250], [300, 600]], bidId: '30b31c1838de1e', @@ -59,11 +61,13 @@ describe('YieldmoAdapter', function () { it('should place bid information into the p parameter of data', function () { let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]]}]'); + expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]'); bidArray.push({ bidder: 'yieldmo', - params: {}, + params: { + bidFloor: 0.2 + }, adUnitCode: 'adunit-code-1', sizes: [[300, 250], [300, 600]], bidId: '123456789', @@ -77,19 +81,19 @@ describe('YieldmoAdapter', function () { // multiple placements placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]]},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]]}]'); + expect(placementInfo).to.equal('[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},{"placement_id":"adunit-code-1","callback_id":"123456789","sizes":[[300,250],[300,600]],"bidFloor":0.2}]'); }); it('should add placement id if given', function () { bidArray[0].params.placementId = 'ym_1293871298'; let placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"}'); - expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"}'); + expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); + expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"'); bidArray[1].params.placementId = 'ym_0987654321'; placementInfo = spec.buildRequests(bidArray).data.p; - expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"}'); - expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"}'); + expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); + expect(placementInfo).to.include('"ym_placement_id":"ym_0987654321"'); }); it('should add additional information to data parameter of request', function () { @@ -104,6 +108,7 @@ describe('YieldmoAdapter', function () { expect(data.hasOwnProperty('title')).to.be.true; expect(data.hasOwnProperty('h')).to.be.true; expect(data.hasOwnProperty('w')).to.be.true; + expect(data.hasOwnProperty('pubcid')).to.be.true; }) it('should add pubcid as parameter of request', function () { @@ -122,25 +127,6 @@ describe('YieldmoAdapter', function () { const data = spec.buildRequests([pubcidBid]).data; expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2'); }) - - it('should add bidFloor as parameter of request if given', function () { - const bidFloorBid = { - bidder: 'yieldmo', - params: { - bidFloor: 5 - }, - adUnitCode: 'adunit-code', - sizes: [[300, 250], [300, 600]], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - userId: { - pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2' - } - }; - const data = spec.buildRequests([bidFloorBid]).data; - expect(data.bidFloor).to.deep.equal(5); - }) }); describe('interpretResponse', function () { From f1bce7763e11e9ca2885295e643952fa6fa1fa07 Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Wed, 5 Jun 2019 13:56:56 -0400 Subject: [PATCH 5/8] make the if statement useful --- modules/yieldmoBidAdapter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index 4e6db50fe6d..b21a79b63e5 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -105,14 +105,14 @@ function addPlacement(request) { sizes: request.sizes } if (request.params) { - - } if (request.params.placementId) { - placementInfo.ym_placement_id = request.params.placementId; - } - if (request.params.bidFloor) { - placementInfo.bidFloor = request.params.bidFloor; - } + if (request.params.placementId) { + placementInfo.ym_placement_id = request.params.placementId; + } + if (request.params.bidFloor) { + placementInfo.bidFloor = request.params.bidFloor; + } return JSON.stringify(placementInfo); + } } /** From 51a38493eb096801fb4da3c301011d00a1d03702 Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Wed, 5 Jun 2019 14:03:14 -0400 Subject: [PATCH 6/8] fix indentation --- modules/yieldmoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index b21a79b63e5..b4bd73abf6e 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -111,7 +111,7 @@ function addPlacement(request) { if (request.params.bidFloor) { placementInfo.bidFloor = request.params.bidFloor; } - return JSON.stringify(placementInfo); + return JSON.stringify(placementInfo); } } From 4afab12baaa1fa4a22a8862e874b2284f232b021 Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Thu, 6 Jun 2019 10:21:27 -0400 Subject: [PATCH 7/8] move return back to the correct place --- modules/yieldmoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index b4bd73abf6e..d99b4fa1857 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -111,8 +111,8 @@ function addPlacement(request) { if (request.params.bidFloor) { placementInfo.bidFloor = request.params.bidFloor; } - return JSON.stringify(placementInfo); } + return JSON.stringify(placementInfo); } /** From cf337fe2698406395913a11a8275521e834a1257 Mon Sep 17 00:00:00 2001 From: Andrew Holz Date: Thu, 6 Jun 2019 10:24:48 -0400 Subject: [PATCH 8/8] fix indent --- modules/yieldmoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index d99b4fa1857..299baf49042 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -112,7 +112,7 @@ function addPlacement(request) { placementInfo.bidFloor = request.params.bidFloor; } } - return JSON.stringify(placementInfo); + return JSON.stringify(placementInfo); } /**