diff --git a/modules/smaatoBidAdapter.js b/modules/smaatoBidAdapter.js index 9a0a0f75623..8f325aa13c9 100644 --- a/modules/smaatoBidAdapter.js +++ b/modules/smaatoBidAdapter.js @@ -19,7 +19,7 @@ import {ortbConverter} from '../libraries/ortbConverter/converter.js'; const BIDDER_CODE = 'smaato'; const SMAATO_ENDPOINT = 'https://prebid.ad.smaato.net/oapi/prebid'; -const SMAATO_CLIENT = 'prebid_js_$prebid.version$_2.0' +const SMAATO_CLIENT = 'prebid_js_$prebid.version$_3.0' const TTL = 300; const CURRENCY = 'USD'; const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO, NATIVE]; @@ -160,12 +160,8 @@ export const spec = { } else { switch (smtAdType) { case 'Img': - resultingBid.ad = createImgAd(bid.adm); - resultingBid.mediaType = BANNER; - bids.push(resultingBid); - break; case 'Richmedia': - resultingBid.ad = createRichmediaAd(bid.adm); + resultingBid.ad = createBannerAd(bid); resultingBid.mediaType = BANNER; bids.push(resultingBid); break; @@ -370,37 +366,17 @@ const converter = ortbConverter({ } }); -const createImgAd = (adm) => { - const image = JSON.parse(adm).image; - +const createBannerAd = (bid) => { let clickEvent = ''; - image.clicktrackers.forEach(src => { - clickEvent += `fetch(decodeURIComponent('${encodeURIComponent(src)}'), {cache: 'no-cache'});`; - }) - - let markup = `
`; - - image.impressiontrackers.forEach(src => { - markup += ``; - }); - - return markup + '
'; -}; - -const createRichmediaAd = (adm) => { - const rich = JSON.parse(adm).richmedia; - let clickEvent = ''; - rich.clicktrackers.forEach(src => { - clickEvent += `fetch(decodeURIComponent('${encodeURIComponent(src)}'), {cache: 'no-cache'});`; - }) - - let markup = `
${rich.mediadata.content}`; - - rich.impressiontrackers.forEach(src => { - markup += ``; - }); + if (bid.ext && bid.ext.curls) { + let clicks = '' + bid.ext.curls.forEach(src => { + clicks += `fetch(decodeURIComponent('${encodeURIComponent(src)}'), {cache: 'no-cache'});`; + }) + clickEvent = `onclick="${clicks}"` + } - return markup + '
'; + return `
${bid.adm}
`; }; const createNativeAd = (adm) => { diff --git a/test/spec/modules/smaatoBidAdapter_spec.js b/test/spec/modules/smaatoBidAdapter_spec.js index 28fd06c4b8d..2ac2a1e5c33 100644 --- a/test/spec/modules/smaatoBidAdapter_spec.js +++ b/test/spec/modules/smaatoBidAdapter_spec.js @@ -13,7 +13,6 @@ import 'modules/consentManagementUsp.js'; import 'modules/schain.js'; const ADTYPE_IMG = 'Img'; -const ADTYPE_RICHMEDIA = 'Richmedia'; const ADTYPE_VIDEO = 'Video'; const ADTYPE_NATIVE = 'Native'; @@ -1300,43 +1299,7 @@ describe('smaatoBidAdapterTest', () => { switch (adType) { case ADTYPE_IMG: - adm = JSON.stringify( - { - image: { - img: { - url: 'https://prebid/static/ad.jpg', - w: 320, - h: 50, - ctaurl: 'https://prebid/track/ctaurl' - }, - impressiontrackers: [ - 'https://prebid/track/imp/1', - 'https://prebid/track/imp/2' - ], - clicktrackers: [ - 'https://prebid/track/click/1' - ] - } - }); - break; - case ADTYPE_RICHMEDIA: - adm = JSON.stringify( - { - richmedia: { - mediadata: { - content: '

RICHMEDIA CONTENT

', - w: 800, - h: 600 - }, - impressiontrackers: [ - 'https://prebid/track/imp/1', - 'https://prebid/track/imp/2' - ], - clicktrackers: [ - 'https://prebid/track/click/1' - ] - } - }); + adm = '' break; case ADTYPE_VIDEO: adm = ''; @@ -1372,7 +1335,10 @@ describe('smaatoBidAdapterTest', () => { 'nurl': 'https://prebid/nurl', 'price': 0.01, 'w': 350, - 'h': 50 + 'h': 50, + 'ext': { + curls: ['https://prebid/track/click/1'] + } } ], seat: 'CM6523' @@ -1398,7 +1364,7 @@ describe('smaatoBidAdapterTest', () => { }); describe('non ad pod', () => { - it('single image response', () => { + it('single banner response', () => { const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_IMG), buildBidRequest()); expect(bids).to.deep.equal([ @@ -1407,33 +1373,7 @@ describe('smaatoBidAdapterTest', () => { cpm: 0.01, width: 350, height: 50, - ad: '
', - ttl: 300, - creativeId: 'CR69381', - dealId: '12345', - netRevenue: true, - currency: 'USD', - mediaType: 'banner', - meta: { - advertiserDomains: ['smaato.com'], - agencyId: 'CM6523', - networkName: 'smaato', - mediaType: 'banner' - } - } - ]); - }); - - it('single richmedia response', () => { - const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_RICHMEDIA), buildBidRequest()); - - expect(bids).to.deep.equal([ - { - requestId: '226416e6e6bf41', - cpm: 0.01, - width: 350, - height: 50, - ad: '

RICHMEDIA CONTENT

', + ad: '
', ttl: 300, creativeId: 'CR69381', dealId: '12345',