diff --git a/src/adapters/sonobi.js b/src/adapters/sonobi.js index f923d979f99..cca84bb8829 100644 --- a/src/adapters/sonobi.js +++ b/src/adapters/sonobi.js @@ -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){ @@ -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; @@ -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 }; }; diff --git a/test/spec/adapters/sonobi_spec.js b/test/spec/adapters/sonobi_spec.js index 9a8c3f0a11a..ca0cd6735ee 100644 --- a/test/spec/adapters/sonobi_spec.js +++ b/test/spec/adapters/sonobi_spec.js @@ -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: [{ @@ -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,