diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 9aabca9518a0..bda63b5521e2 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -1,6 +1,6 @@ import { registerBidder } from 'src/adapters/bidderFactory'; -const VERSION = '3.0.0'; +const VERSION = '3.0.1'; const BIDDER_CODE = 'sharethrough'; const STR_ENDPOINT = document.location.protocol + '//btlr.sharethrough.com/header-bid/v1'; @@ -32,6 +32,7 @@ export const sharethroughAdapterSpec = { // but we need as part of interpretResponse() const strData = { stayInIframe: bid.params.iframe, + iframeSize: bid.params.iframeSize, sizes: bid.sizes } @@ -52,7 +53,9 @@ export const sharethroughAdapterSpec = { const creative = body.creatives[0]; let size = [0, 0]; if (req.strData.stayInIframe) { - size = getLargestSize(req.strData.sizes); + size = req.strData.iframeSize != undefined + ? req.strData.iframeSize + : getLargestSize(req.strData.sizes); } return [{ diff --git a/modules/sharethroughBidAdapter.md b/modules/sharethroughBidAdapter.md index d2d8030c5f73..ab183a41496b 100644 --- a/modules/sharethroughBidAdapter.md +++ b/modules/sharethroughBidAdapter.md @@ -12,30 +12,27 @@ Module that connects to Sharethrough's demand sources # Test Parameters ``` - var adUnits = [ - { - code: 'test-div', - sizes: [[1, 1]], // a display size - bids: [ - { - bidder: "sharethrough", - params: { - pkey: 'LuB3vxGGFrBZJa6tifXW4xgK' - } - } - ] - },{ - code: 'test-div', - sizes: [[300,250], [1, 1]], // a mobile size - bids: [ - { - bidder: "sharethrough", - params: { - pkey: 'LuB3vxGGFrBZJa6tifXW4xgK', - iframe: true - } - } - ] - } - ]; -``` \ No newline at end of file + var adUnits = [ + { + code: 'test-div', + sizes: [[300,250], [1, 1]], + bids: [ + { + bidder: "sharethrough", + params: { + // REQUIRED - The placement key + pkey: 'LuB3vxGGFrBZJa6tifXW4xgK', + + // OPTIONAL - Render Sharethrough creative in an iframe, defaults to false + iframe: true, + + // OPTIONAL - If iframeSize is provided, we'll use this size for the iframe + // otherwise we'll grab the largest size from the sizes array + // This is ignored if iframe: false + iframeSize: [250, 250] + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index a599ce6cdc80..85fc6daf758a 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -22,7 +22,19 @@ const bidderRequest = [ pkey: 'bbbb2222', iframe: true } - }]; + }, + { + bidder: 'sharethrough', + bidId: 'bidId3', + sizes: [[700, 400]], + placementCode: 'coconut', + params: { + pkey: 'cccc3333', + iframe: true, + iframeSize: [500, 500] + }, + }, +]; const prebidRequests = [ { @@ -49,6 +61,19 @@ const prebidRequests = [ sizes: [[300, 250], [300, 300], [250, 250], [600, 50]] } }, + { + method: 'GET', + url: document.location.protocol + '//btlr.sharethrough.com' + '/header-bid/v1', + data: { + bidId: 'bidId', + placement_key: 'pKey' + }, + strData: { + stayInIframe: true, + iframeSize: [500, 500], + sizes: [[300, 250], [300, 300], [250, 250], [600, 50]] + } + }, ]; const bidderResponse = { @@ -169,6 +194,20 @@ describe('sharethrough adapter spec', () => { }); }); + it('returns a correctly parsed out response with explicitly defined size when strData.stayInIframe is true and strData.iframeSize is provided', () => { + expect(spec.interpretResponse(bidderResponse, prebidRequests[2])[0]).to.include( + { + width: 500, + height: 500, + cpm: 12.34, + creativeId: 'aCreativeId', + dealId: 'aDealId', + currency: 'USD', + netRevenue: true, + ttl: 360, + }); + }); + it('returns a blank array if there are no creatives', () => { const bidResponse = { body: { creatives: [] } }; expect(spec.interpretResponse(bidResponse, prebidRequests[0])).to.be.an('array').that.is.empty;