Skip to content

Commit

Permalink
Handle iframeSize parameter to allow Pub to explicitly call out the s…
Browse files Browse the repository at this point in the history
…ize (prebid#2782)

we render in
  • Loading branch information
jchau87 authored and dluxemburg committed Jul 17, 2018
1 parent 97dea42 commit 3627b42
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 30 deletions.
7 changes: 5 additions & 2 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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
}

Expand All @@ -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 [{
Expand Down
51 changes: 24 additions & 27 deletions modules/sharethroughBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
]
}
];
```
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]
}
}
]
}
];
```
41 changes: 40 additions & 1 deletion test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand All @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3627b42

Please sign in to comment.