Skip to content

Commit

Permalink
Sonobi Adapter - Enable size overrides (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Studnicky authored and dbemiller committed May 2, 2017
1 parent b58c9db commit 441455d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/adapters/sonobi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var SonobiAdapter = function SonobiAdapter(){
var adSlots = request.bids || [];
var bidderRequestId = request.bidderRequestId;
var ref = (window.frameElement) ? '&ref=' + encodeURI(top.location.host || document.referrer) : '';
adloader.loadScript(trinity + JSON.stringify(_keymaker(adSlots)) + '&cv=' + _operator(bidderRequestId) + ref );
adloader.loadScript(trinity + JSON.stringify(_keymaker(adSlots)) + '&cv=' + _operator(bidderRequestId) + ref);
}

function _keymaker(adSlots){
Expand All @@ -23,11 +23,15 @@ var SonobiAdapter = function SonobiAdapter(){
var floor = (bidRequest.params.floor) ? bidRequest.params.floor : null;
// Mandatory
var slotIdentifier = (bidRequest.params.ad_unit) ? bidRequest.params.ad_unit : (bidRequest.params.placement_id) ? bidRequest.params.placement_id : null;
var sizes = utils.parseSizesInput(bidRequest.sizes).toString() || null;
var bidId = bidRequest.bidId;
var sizes = (bidRequest.params.sizes) ? bidRequest.params.sizes : bidRequest.sizes || null;
sizes = utils.parseSizesInput(sizes).toString();

if (utils.isEmpty(sizes)){
utils.logError('Sonobi adapter expects sizes for ' + bidRequest.placementCode);
}

var bidId = bidRequest.bidId;

var args = (sizes) ? ((floor) ? (sizes + '|f=' + floor) : (sizes)) : (floor) ? ('f=' + floor) : '';
if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)){
slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier;
Expand Down Expand Up @@ -100,11 +104,11 @@ var SonobiAdapter = function SonobiAdapter(){
}

return {
callBids: _phone_in,
formRequest: _keymaker,
callBids: _phone_in,
formRequest: _keymaker,
parseResponse: _trinity,
success: _success,
failure: _failure
success: _success,
failure: _failure
};
};

Expand Down
14 changes: 14 additions & 0 deletions test/spec/adapters/sonobi_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ describe('Sonobi adapter tests', () => {
}
}]
};

const adUnit_as = {
code: 'sbi_s',
sizes: [[120, 600], [300, 600], [160, 600]],
bids: [{
bidder: 'sonobi',
params: {
ad_unit: '/7780971/sparks_prebid_LB',
sizes: [[300, 250], [300, 600]]
}
}]
};

const adUnit_ad = {
bidderCode: 'sonobi',
bids: [{
Expand Down Expand Up @@ -227,6 +240,7 @@ describe('Sonobi adapter tests', () => {
'adUnit_pd' : adUnit_pd,
'adUnit_pdf' : adUnit_pdf,
'adUnit_a' : adUnit_a,
'adUnit_as' : adUnit_as,
'adUnit_ad' : adUnit_ad,
'adUnit_af' : adUnit_af,
'adUnit_adf' : adUnit_adf,
Expand Down

0 comments on commit 441455d

Please sign in to comment.